1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.NoSuchPortletItemException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderPath;
24  import com.liferay.portal.kernel.dao.orm.Query;
25  import com.liferay.portal.kernel.dao.orm.QueryPos;
26  import com.liferay.portal.kernel.dao.orm.QueryUtil;
27  import com.liferay.portal.kernel.dao.orm.Session;
28  import com.liferay.portal.kernel.exception.SystemException;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.OrderByComparator;
33  import com.liferay.portal.kernel.util.StringBundler;
34  import com.liferay.portal.kernel.util.StringPool;
35  import com.liferay.portal.kernel.util.StringUtil;
36  import com.liferay.portal.kernel.util.Validator;
37  import com.liferay.portal.model.ModelListener;
38  import com.liferay.portal.model.PortletItem;
39  import com.liferay.portal.model.impl.PortletItemImpl;
40  import com.liferay.portal.model.impl.PortletItemModelImpl;
41  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42  
43  import java.io.Serializable;
44  
45  import java.util.ArrayList;
46  import java.util.Collections;
47  import java.util.List;
48  
49  /**
50   * <a href="PortletItemPersistenceImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       PortletItemPersistence
59   * @see       PortletItemUtil
60   * @generated
61   */
62  public class PortletItemPersistenceImpl extends BasePersistenceImpl<PortletItem>
63      implements PortletItemPersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = PortletItemImpl.class.getName();
65      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66          ".List";
67      public static final FinderPath FINDER_PATH_FIND_BY_G_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
68              PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
69              "findByG_C",
70              new String[] { Long.class.getName(), Long.class.getName() });
71      public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
72              PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
73              "findByG_C",
74              new String[] {
75                  Long.class.getName(), Long.class.getName(),
76                  
77              "java.lang.Integer", "java.lang.Integer",
78                  "com.liferay.portal.kernel.util.OrderByComparator"
79              });
80      public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
81              PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
82              "countByG_C",
83              new String[] { Long.class.getName(), Long.class.getName() });
84      public static final FinderPath FINDER_PATH_FIND_BY_G_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
85              PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
86              "findByG_P_C",
87              new String[] {
88                  Long.class.getName(), String.class.getName(),
89                  Long.class.getName()
90              });
91      public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
92              PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
93              "findByG_P_C",
94              new String[] {
95                  Long.class.getName(), String.class.getName(),
96                  Long.class.getName(),
97                  
98              "java.lang.Integer", "java.lang.Integer",
99                  "com.liferay.portal.kernel.util.OrderByComparator"
100             });
101     public static final FinderPath FINDER_PATH_COUNT_BY_G_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
102             PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103             "countByG_P_C",
104             new String[] {
105                 Long.class.getName(), String.class.getName(),
106                 Long.class.getName()
107             });
108     public static final FinderPath FINDER_PATH_FETCH_BY_G_N_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
109             PortletItemModelImpl.FINDER_CACHE_ENABLED,
110             FINDER_CLASS_NAME_ENTITY, "fetchByG_N_P_C",
111             new String[] {
112                 Long.class.getName(), String.class.getName(),
113                 String.class.getName(), Long.class.getName()
114             });
115     public static final FinderPath FINDER_PATH_COUNT_BY_G_N_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
116             PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117             "countByG_N_P_C",
118             new String[] {
119                 Long.class.getName(), String.class.getName(),
120                 String.class.getName(), Long.class.getName()
121             });
122     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
123             PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
124             "findAll", new String[0]);
125     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
126             PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
127             "countAll", new String[0]);
128 
129     public void cacheResult(PortletItem portletItem) {
130         EntityCacheUtil.putResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
131             PortletItemImpl.class, portletItem.getPrimaryKey(), portletItem);
132 
133         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
134             new Object[] {
135                 new Long(portletItem.getGroupId()),
136                 
137             portletItem.getName(),
138                 
139             portletItem.getPortletId(), new Long(portletItem.getClassNameId())
140             }, portletItem);
141     }
142 
143     public void cacheResult(List<PortletItem> portletItems) {
144         for (PortletItem portletItem : portletItems) {
145             if (EntityCacheUtil.getResult(
146                         PortletItemModelImpl.ENTITY_CACHE_ENABLED,
147                         PortletItemImpl.class, portletItem.getPrimaryKey(), this) == null) {
148                 cacheResult(portletItem);
149             }
150         }
151     }
152 
153     public void clearCache() {
154         CacheRegistry.clear(PortletItemImpl.class.getName());
155         EntityCacheUtil.clearCache(PortletItemImpl.class.getName());
156         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
157         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
158     }
159 
160     public PortletItem create(long portletItemId) {
161         PortletItem portletItem = new PortletItemImpl();
162 
163         portletItem.setNew(true);
164         portletItem.setPrimaryKey(portletItemId);
165 
166         return portletItem;
167     }
168 
169     public PortletItem remove(Serializable primaryKey)
170         throws NoSuchModelException, SystemException {
171         return remove(((Long)primaryKey).longValue());
172     }
173 
174     public PortletItem remove(long portletItemId)
175         throws NoSuchPortletItemException, SystemException {
176         Session session = null;
177 
178         try {
179             session = openSession();
180 
181             PortletItem portletItem = (PortletItem)session.get(PortletItemImpl.class,
182                     new Long(portletItemId));
183 
184             if (portletItem == null) {
185                 if (_log.isWarnEnabled()) {
186                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + portletItemId);
187                 }
188 
189                 throw new NoSuchPortletItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
190                     portletItemId);
191             }
192 
193             return remove(portletItem);
194         }
195         catch (NoSuchPortletItemException nsee) {
196             throw nsee;
197         }
198         catch (Exception e) {
199             throw processException(e);
200         }
201         finally {
202             closeSession(session);
203         }
204     }
205 
206     public PortletItem remove(PortletItem portletItem)
207         throws SystemException {
208         for (ModelListener<PortletItem> listener : listeners) {
209             listener.onBeforeRemove(portletItem);
210         }
211 
212         portletItem = removeImpl(portletItem);
213 
214         for (ModelListener<PortletItem> listener : listeners) {
215             listener.onAfterRemove(portletItem);
216         }
217 
218         return portletItem;
219     }
220 
221     protected PortletItem removeImpl(PortletItem portletItem)
222         throws SystemException {
223         portletItem = toUnwrappedModel(portletItem);
224 
225         Session session = null;
226 
227         try {
228             session = openSession();
229 
230             if (portletItem.isCachedModel() || BatchSessionUtil.isEnabled()) {
231                 Object staleObject = session.get(PortletItemImpl.class,
232                         portletItem.getPrimaryKeyObj());
233 
234                 if (staleObject != null) {
235                     session.evict(staleObject);
236                 }
237             }
238 
239             session.delete(portletItem);
240 
241             session.flush();
242         }
243         catch (Exception e) {
244             throw processException(e);
245         }
246         finally {
247             closeSession(session);
248         }
249 
250         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
251 
252         PortletItemModelImpl portletItemModelImpl = (PortletItemModelImpl)portletItem;
253 
254         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N_P_C,
255             new Object[] {
256                 new Long(portletItemModelImpl.getOriginalGroupId()),
257                 
258             portletItemModelImpl.getOriginalName(),
259                 
260             portletItemModelImpl.getOriginalPortletId(),
261                 new Long(portletItemModelImpl.getOriginalClassNameId())
262             });
263 
264         EntityCacheUtil.removeResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
265             PortletItemImpl.class, portletItem.getPrimaryKey());
266 
267         return portletItem;
268     }
269 
270     public PortletItem updateImpl(
271         com.liferay.portal.model.PortletItem portletItem, boolean merge)
272         throws SystemException {
273         portletItem = toUnwrappedModel(portletItem);
274 
275         boolean isNew = portletItem.isNew();
276 
277         PortletItemModelImpl portletItemModelImpl = (PortletItemModelImpl)portletItem;
278 
279         Session session = null;
280 
281         try {
282             session = openSession();
283 
284             BatchSessionUtil.update(session, portletItem, merge);
285 
286             portletItem.setNew(false);
287         }
288         catch (Exception e) {
289             throw processException(e);
290         }
291         finally {
292             closeSession(session);
293         }
294 
295         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
296 
297         EntityCacheUtil.putResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
298             PortletItemImpl.class, portletItem.getPrimaryKey(), portletItem);
299 
300         if (!isNew &&
301                 ((portletItem.getGroupId() != portletItemModelImpl.getOriginalGroupId()) ||
302                 !Validator.equals(portletItem.getName(),
303                     portletItemModelImpl.getOriginalName()) ||
304                 !Validator.equals(portletItem.getPortletId(),
305                     portletItemModelImpl.getOriginalPortletId()) ||
306                 (portletItem.getClassNameId() != portletItemModelImpl.getOriginalClassNameId()))) {
307             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N_P_C,
308                 new Object[] {
309                     new Long(portletItemModelImpl.getOriginalGroupId()),
310                     
311                 portletItemModelImpl.getOriginalName(),
312                     
313                 portletItemModelImpl.getOriginalPortletId(),
314                     new Long(portletItemModelImpl.getOriginalClassNameId())
315                 });
316         }
317 
318         if (isNew ||
319                 ((portletItem.getGroupId() != portletItemModelImpl.getOriginalGroupId()) ||
320                 !Validator.equals(portletItem.getName(),
321                     portletItemModelImpl.getOriginalName()) ||
322                 !Validator.equals(portletItem.getPortletId(),
323                     portletItemModelImpl.getOriginalPortletId()) ||
324                 (portletItem.getClassNameId() != portletItemModelImpl.getOriginalClassNameId()))) {
325             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
326                 new Object[] {
327                     new Long(portletItem.getGroupId()),
328                     
329                 portletItem.getName(),
330                     
331                 portletItem.getPortletId(),
332                     new Long(portletItem.getClassNameId())
333                 }, portletItem);
334         }
335 
336         return portletItem;
337     }
338 
339     protected PortletItem toUnwrappedModel(PortletItem portletItem) {
340         if (portletItem instanceof PortletItemImpl) {
341             return portletItem;
342         }
343 
344         PortletItemImpl portletItemImpl = new PortletItemImpl();
345 
346         portletItemImpl.setNew(portletItem.isNew());
347         portletItemImpl.setPrimaryKey(portletItem.getPrimaryKey());
348 
349         portletItemImpl.setPortletItemId(portletItem.getPortletItemId());
350         portletItemImpl.setGroupId(portletItem.getGroupId());
351         portletItemImpl.setCompanyId(portletItem.getCompanyId());
352         portletItemImpl.setUserId(portletItem.getUserId());
353         portletItemImpl.setUserName(portletItem.getUserName());
354         portletItemImpl.setCreateDate(portletItem.getCreateDate());
355         portletItemImpl.setModifiedDate(portletItem.getModifiedDate());
356         portletItemImpl.setName(portletItem.getName());
357         portletItemImpl.setPortletId(portletItem.getPortletId());
358         portletItemImpl.setClassNameId(portletItem.getClassNameId());
359 
360         return portletItemImpl;
361     }
362 
363     public PortletItem findByPrimaryKey(Serializable primaryKey)
364         throws NoSuchModelException, SystemException {
365         return findByPrimaryKey(((Long)primaryKey).longValue());
366     }
367 
368     public PortletItem findByPrimaryKey(long portletItemId)
369         throws NoSuchPortletItemException, SystemException {
370         PortletItem portletItem = fetchByPrimaryKey(portletItemId);
371 
372         if (portletItem == null) {
373             if (_log.isWarnEnabled()) {
374                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + portletItemId);
375             }
376 
377             throw new NoSuchPortletItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
378                 portletItemId);
379         }
380 
381         return portletItem;
382     }
383 
384     public PortletItem fetchByPrimaryKey(Serializable primaryKey)
385         throws SystemException {
386         return fetchByPrimaryKey(((Long)primaryKey).longValue());
387     }
388 
389     public PortletItem fetchByPrimaryKey(long portletItemId)
390         throws SystemException {
391         PortletItem portletItem = (PortletItem)EntityCacheUtil.getResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
392                 PortletItemImpl.class, portletItemId, this);
393 
394         if (portletItem == null) {
395             Session session = null;
396 
397             try {
398                 session = openSession();
399 
400                 portletItem = (PortletItem)session.get(PortletItemImpl.class,
401                         new Long(portletItemId));
402             }
403             catch (Exception e) {
404                 throw processException(e);
405             }
406             finally {
407                 if (portletItem != null) {
408                     cacheResult(portletItem);
409                 }
410 
411                 closeSession(session);
412             }
413         }
414 
415         return portletItem;
416     }
417 
418     public List<PortletItem> findByG_C(long groupId, long classNameId)
419         throws SystemException {
420         Object[] finderArgs = new Object[] {
421                 new Long(groupId), new Long(classNameId)
422             };
423 
424         List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C,
425                 finderArgs, this);
426 
427         if (list == null) {
428             Session session = null;
429 
430             try {
431                 session = openSession();
432 
433                 StringBundler query = new StringBundler(3);
434 
435                 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
436 
437                 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
438 
439                 query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
440 
441                 String sql = query.toString();
442 
443                 Query q = session.createQuery(sql);
444 
445                 QueryPos qPos = QueryPos.getInstance(q);
446 
447                 qPos.add(groupId);
448 
449                 qPos.add(classNameId);
450 
451                 list = q.list();
452             }
453             catch (Exception e) {
454                 throw processException(e);
455             }
456             finally {
457                 if (list == null) {
458                     list = new ArrayList<PortletItem>();
459                 }
460 
461                 cacheResult(list);
462 
463                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C, finderArgs,
464                     list);
465 
466                 closeSession(session);
467             }
468         }
469 
470         return list;
471     }
472 
473     public List<PortletItem> findByG_C(long groupId, long classNameId,
474         int start, int end) throws SystemException {
475         return findByG_C(groupId, classNameId, start, end, null);
476     }
477 
478     public List<PortletItem> findByG_C(long groupId, long classNameId,
479         int start, int end, OrderByComparator orderByComparator)
480         throws SystemException {
481         Object[] finderArgs = new Object[] {
482                 new Long(groupId), new Long(classNameId),
483                 
484                 String.valueOf(start), String.valueOf(end),
485                 String.valueOf(orderByComparator)
486             };
487 
488         List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_C,
489                 finderArgs, this);
490 
491         if (list == null) {
492             Session session = null;
493 
494             try {
495                 session = openSession();
496 
497                 StringBundler query = null;
498 
499                 if (orderByComparator != null) {
500                     query = new StringBundler(4 +
501                             (orderByComparator.getOrderByFields().length * 3));
502                 }
503                 else {
504                     query = new StringBundler(3);
505                 }
506 
507                 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
508 
509                 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
510 
511                 query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
512 
513                 if (orderByComparator != null) {
514                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
515                         orderByComparator);
516                 }
517 
518                 String sql = query.toString();
519 
520                 Query q = session.createQuery(sql);
521 
522                 QueryPos qPos = QueryPos.getInstance(q);
523 
524                 qPos.add(groupId);
525 
526                 qPos.add(classNameId);
527 
528                 list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
529                         start, end);
530             }
531             catch (Exception e) {
532                 throw processException(e);
533             }
534             finally {
535                 if (list == null) {
536                     list = new ArrayList<PortletItem>();
537                 }
538 
539                 cacheResult(list);
540 
541                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_C,
542                     finderArgs, list);
543 
544                 closeSession(session);
545             }
546         }
547 
548         return list;
549     }
550 
551     public PortletItem findByG_C_First(long groupId, long classNameId,
552         OrderByComparator orderByComparator)
553         throws NoSuchPortletItemException, SystemException {
554         List<PortletItem> list = findByG_C(groupId, classNameId, 0, 1,
555                 orderByComparator);
556 
557         if (list.isEmpty()) {
558             StringBundler msg = new StringBundler(6);
559 
560             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
561 
562             msg.append("groupId=");
563             msg.append(groupId);
564 
565             msg.append(", classNameId=");
566             msg.append(classNameId);
567 
568             msg.append(StringPool.CLOSE_CURLY_BRACE);
569 
570             throw new NoSuchPortletItemException(msg.toString());
571         }
572         else {
573             return list.get(0);
574         }
575     }
576 
577     public PortletItem findByG_C_Last(long groupId, long classNameId,
578         OrderByComparator orderByComparator)
579         throws NoSuchPortletItemException, SystemException {
580         int count = countByG_C(groupId, classNameId);
581 
582         List<PortletItem> list = findByG_C(groupId, classNameId, count - 1,
583                 count, orderByComparator);
584 
585         if (list.isEmpty()) {
586             StringBundler msg = new StringBundler(6);
587 
588             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
589 
590             msg.append("groupId=");
591             msg.append(groupId);
592 
593             msg.append(", classNameId=");
594             msg.append(classNameId);
595 
596             msg.append(StringPool.CLOSE_CURLY_BRACE);
597 
598             throw new NoSuchPortletItemException(msg.toString());
599         }
600         else {
601             return list.get(0);
602         }
603     }
604 
605     public PortletItem[] findByG_C_PrevAndNext(long portletItemId,
606         long groupId, long classNameId, OrderByComparator orderByComparator)
607         throws NoSuchPortletItemException, SystemException {
608         PortletItem portletItem = findByPrimaryKey(portletItemId);
609 
610         int count = countByG_C(groupId, classNameId);
611 
612         Session session = null;
613 
614         try {
615             session = openSession();
616 
617             StringBundler query = null;
618 
619             if (orderByComparator != null) {
620                 query = new StringBundler(4 +
621                         (orderByComparator.getOrderByFields().length * 3));
622             }
623             else {
624                 query = new StringBundler(3);
625             }
626 
627             query.append(_SQL_SELECT_PORTLETITEM_WHERE);
628 
629             query.append(_FINDER_COLUMN_G_C_GROUPID_2);
630 
631             query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
632 
633             if (orderByComparator != null) {
634                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
635                     orderByComparator);
636             }
637 
638             String sql = query.toString();
639 
640             Query q = session.createQuery(sql);
641 
642             QueryPos qPos = QueryPos.getInstance(q);
643 
644             qPos.add(groupId);
645 
646             qPos.add(classNameId);
647 
648             Object[] objArray = QueryUtil.getPrevAndNext(q, count,
649                     orderByComparator, portletItem);
650 
651             PortletItem[] array = new PortletItemImpl[3];
652 
653             array[0] = (PortletItem)objArray[0];
654             array[1] = (PortletItem)objArray[1];
655             array[2] = (PortletItem)objArray[2];
656 
657             return array;
658         }
659         catch (Exception e) {
660             throw processException(e);
661         }
662         finally {
663             closeSession(session);
664         }
665     }
666 
667     public List<PortletItem> findByG_P_C(long groupId, String portletId,
668         long classNameId) throws SystemException {
669         Object[] finderArgs = new Object[] {
670                 new Long(groupId),
671                 
672                 portletId, new Long(classNameId)
673             };
674 
675         List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_C,
676                 finderArgs, this);
677 
678         if (list == null) {
679             Session session = null;
680 
681             try {
682                 session = openSession();
683 
684                 StringBundler query = new StringBundler(4);
685 
686                 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
687 
688                 query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
689 
690                 if (portletId == null) {
691                     query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
692                 }
693                 else {
694                     if (portletId.equals(StringPool.BLANK)) {
695                         query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
696                     }
697                     else {
698                         query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
699                     }
700                 }
701 
702                 query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
703 
704                 String sql = query.toString();
705 
706                 Query q = session.createQuery(sql);
707 
708                 QueryPos qPos = QueryPos.getInstance(q);
709 
710                 qPos.add(groupId);
711 
712                 if (portletId != null) {
713                     qPos.add(portletId);
714                 }
715 
716                 qPos.add(classNameId);
717 
718                 list = q.list();
719             }
720             catch (Exception e) {
721                 throw processException(e);
722             }
723             finally {
724                 if (list == null) {
725                     list = new ArrayList<PortletItem>();
726                 }
727 
728                 cacheResult(list);
729 
730                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_C,
731                     finderArgs, list);
732 
733                 closeSession(session);
734             }
735         }
736 
737         return list;
738     }
739 
740     public List<PortletItem> findByG_P_C(long groupId, String portletId,
741         long classNameId, int start, int end) throws SystemException {
742         return findByG_P_C(groupId, portletId, classNameId, start, end, null);
743     }
744 
745     public List<PortletItem> findByG_P_C(long groupId, String portletId,
746         long classNameId, int start, int end,
747         OrderByComparator orderByComparator) throws SystemException {
748         Object[] finderArgs = new Object[] {
749                 new Long(groupId),
750                 
751                 portletId, new Long(classNameId),
752                 
753                 String.valueOf(start), String.valueOf(end),
754                 String.valueOf(orderByComparator)
755             };
756 
757         List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P_C,
758                 finderArgs, this);
759 
760         if (list == null) {
761             Session session = null;
762 
763             try {
764                 session = openSession();
765 
766                 StringBundler query = null;
767 
768                 if (orderByComparator != null) {
769                     query = new StringBundler(5 +
770                             (orderByComparator.getOrderByFields().length * 3));
771                 }
772                 else {
773                     query = new StringBundler(4);
774                 }
775 
776                 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
777 
778                 query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
779 
780                 if (portletId == null) {
781                     query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
782                 }
783                 else {
784                     if (portletId.equals(StringPool.BLANK)) {
785                         query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
786                     }
787                     else {
788                         query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
789                     }
790                 }
791 
792                 query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
793 
794                 if (orderByComparator != null) {
795                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
796                         orderByComparator);
797                 }
798 
799                 String sql = query.toString();
800 
801                 Query q = session.createQuery(sql);
802 
803                 QueryPos qPos = QueryPos.getInstance(q);
804 
805                 qPos.add(groupId);
806 
807                 if (portletId != null) {
808                     qPos.add(portletId);
809                 }
810 
811                 qPos.add(classNameId);
812 
813                 list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
814                         start, end);
815             }
816             catch (Exception e) {
817                 throw processException(e);
818             }
819             finally {
820                 if (list == null) {
821                     list = new ArrayList<PortletItem>();
822                 }
823 
824                 cacheResult(list);
825 
826                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P_C,
827                     finderArgs, list);
828 
829                 closeSession(session);
830             }
831         }
832 
833         return list;
834     }
835 
836     public PortletItem findByG_P_C_First(long groupId, String portletId,
837         long classNameId, OrderByComparator orderByComparator)
838         throws NoSuchPortletItemException, SystemException {
839         List<PortletItem> list = findByG_P_C(groupId, portletId, classNameId,
840                 0, 1, orderByComparator);
841 
842         if (list.isEmpty()) {
843             StringBundler msg = new StringBundler(8);
844 
845             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
846 
847             msg.append("groupId=");
848             msg.append(groupId);
849 
850             msg.append(", portletId=");
851             msg.append(portletId);
852 
853             msg.append(", classNameId=");
854             msg.append(classNameId);
855 
856             msg.append(StringPool.CLOSE_CURLY_BRACE);
857 
858             throw new NoSuchPortletItemException(msg.toString());
859         }
860         else {
861             return list.get(0);
862         }
863     }
864 
865     public PortletItem findByG_P_C_Last(long groupId, String portletId,
866         long classNameId, OrderByComparator orderByComparator)
867         throws NoSuchPortletItemException, SystemException {
868         int count = countByG_P_C(groupId, portletId, classNameId);
869 
870         List<PortletItem> list = findByG_P_C(groupId, portletId, classNameId,
871                 count - 1, count, orderByComparator);
872 
873         if (list.isEmpty()) {
874             StringBundler msg = new StringBundler(8);
875 
876             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
877 
878             msg.append("groupId=");
879             msg.append(groupId);
880 
881             msg.append(", portletId=");
882             msg.append(portletId);
883 
884             msg.append(", classNameId=");
885             msg.append(classNameId);
886 
887             msg.append(StringPool.CLOSE_CURLY_BRACE);
888 
889             throw new NoSuchPortletItemException(msg.toString());
890         }
891         else {
892             return list.get(0);
893         }
894     }
895 
896     public PortletItem[] findByG_P_C_PrevAndNext(long portletItemId,
897         long groupId, String portletId, long classNameId,
898         OrderByComparator orderByComparator)
899         throws NoSuchPortletItemException, SystemException {
900         PortletItem portletItem = findByPrimaryKey(portletItemId);
901 
902         int count = countByG_P_C(groupId, portletId, classNameId);
903 
904         Session session = null;
905 
906         try {
907             session = openSession();
908 
909             StringBundler query = null;
910 
911             if (orderByComparator != null) {
912                 query = new StringBundler(5 +
913                         (orderByComparator.getOrderByFields().length * 3));
914             }
915             else {
916                 query = new StringBundler(4);
917             }
918 
919             query.append(_SQL_SELECT_PORTLETITEM_WHERE);
920 
921             query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
922 
923             if (portletId == null) {
924                 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
925             }
926             else {
927                 if (portletId.equals(StringPool.BLANK)) {
928                     query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
929                 }
930                 else {
931                     query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
932                 }
933             }
934 
935             query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
936 
937             if (orderByComparator != null) {
938                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
939                     orderByComparator);
940             }
941 
942             String sql = query.toString();
943 
944             Query q = session.createQuery(sql);
945 
946             QueryPos qPos = QueryPos.getInstance(q);
947 
948             qPos.add(groupId);
949 
950             if (portletId != null) {
951                 qPos.add(portletId);
952             }
953 
954             qPos.add(classNameId);
955 
956             Object[] objArray = QueryUtil.getPrevAndNext(q, count,
957                     orderByComparator, portletItem);
958 
959             PortletItem[] array = new PortletItemImpl[3];
960 
961             array[0] = (PortletItem)objArray[0];
962             array[1] = (PortletItem)objArray[1];
963             array[2] = (PortletItem)objArray[2];
964 
965             return array;
966         }
967         catch (Exception e) {
968             throw processException(e);
969         }
970         finally {
971             closeSession(session);
972         }
973     }
974 
975     public PortletItem findByG_N_P_C(long groupId, String name,
976         String portletId, long classNameId)
977         throws NoSuchPortletItemException, SystemException {
978         PortletItem portletItem = fetchByG_N_P_C(groupId, name, portletId,
979                 classNameId);
980 
981         if (portletItem == null) {
982             StringBundler msg = new StringBundler(10);
983 
984             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
985 
986             msg.append("groupId=");
987             msg.append(groupId);
988 
989             msg.append(", name=");
990             msg.append(name);
991 
992             msg.append(", portletId=");
993             msg.append(portletId);
994 
995             msg.append(", classNameId=");
996             msg.append(classNameId);
997 
998             msg.append(StringPool.CLOSE_CURLY_BRACE);
999 
1000            if (_log.isWarnEnabled()) {
1001                _log.warn(msg.toString());
1002            }
1003
1004            throw new NoSuchPortletItemException(msg.toString());
1005        }
1006
1007        return portletItem;
1008    }
1009
1010    public PortletItem fetchByG_N_P_C(long groupId, String name,
1011        String portletId, long classNameId) throws SystemException {
1012        return fetchByG_N_P_C(groupId, name, portletId, classNameId, true);
1013    }
1014
1015    public PortletItem fetchByG_N_P_C(long groupId, String name,
1016        String portletId, long classNameId, boolean retrieveFromCache)
1017        throws SystemException {
1018        Object[] finderArgs = new Object[] {
1019                new Long(groupId),
1020                
1021                name,
1022                
1023                portletId, new Long(classNameId)
1024            };
1025
1026        Object result = null;
1027
1028        if (retrieveFromCache) {
1029            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1030                    finderArgs, this);
1031        }
1032
1033        if (result == null) {
1034            Session session = null;
1035
1036            try {
1037                session = openSession();
1038
1039                StringBundler query = new StringBundler(5);
1040
1041                query.append(_SQL_SELECT_PORTLETITEM_WHERE);
1042
1043                query.append(_FINDER_COLUMN_G_N_P_C_GROUPID_2);
1044
1045                if (name == null) {
1046                    query.append(_FINDER_COLUMN_G_N_P_C_NAME_1);
1047                }
1048                else {
1049                    if (name.equals(StringPool.BLANK)) {
1050                        query.append(_FINDER_COLUMN_G_N_P_C_NAME_3);
1051                    }
1052                    else {
1053                        query.append(_FINDER_COLUMN_G_N_P_C_NAME_2);
1054                    }
1055                }
1056
1057                if (portletId == null) {
1058                    query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_1);
1059                }
1060                else {
1061                    if (portletId.equals(StringPool.BLANK)) {
1062                        query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_3);
1063                    }
1064                    else {
1065                        query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_2);
1066                    }
1067                }
1068
1069                query.append(_FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2);
1070
1071                String sql = query.toString();
1072
1073                Query q = session.createQuery(sql);
1074
1075                QueryPos qPos = QueryPos.getInstance(q);
1076
1077                qPos.add(groupId);
1078
1079                if (name != null) {
1080                    qPos.add(name);
1081                }
1082
1083                if (portletId != null) {
1084                    qPos.add(portletId);
1085                }
1086
1087                qPos.add(classNameId);
1088
1089                List<PortletItem> list = q.list();
1090
1091                result = list;
1092
1093                PortletItem portletItem = null;
1094
1095                if (list.isEmpty()) {
1096                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1097                        finderArgs, list);
1098                }
1099                else {
1100                    portletItem = list.get(0);
1101
1102                    cacheResult(portletItem);
1103
1104                    if ((portletItem.getGroupId() != groupId) ||
1105                            (portletItem.getName() == null) ||
1106                            !portletItem.getName().equals(name) ||
1107                            (portletItem.getPortletId() == null) ||
1108                            !portletItem.getPortletId().equals(portletId) ||
1109                            (portletItem.getClassNameId() != classNameId)) {
1110                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1111                            finderArgs, portletItem);
1112                    }
1113                }
1114
1115                return portletItem;
1116            }
1117            catch (Exception e) {
1118                throw processException(e);
1119            }
1120            finally {
1121                if (result == null) {
1122                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1123                        finderArgs, new ArrayList<PortletItem>());
1124                }
1125
1126                closeSession(session);
1127            }
1128        }
1129        else {
1130            if (result instanceof List<?>) {
1131                return null;
1132            }
1133            else {
1134                return (PortletItem)result;
1135            }
1136        }
1137    }
1138
1139    public List<PortletItem> findAll() throws SystemException {
1140        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1141    }
1142
1143    public List<PortletItem> findAll(int start, int end)
1144        throws SystemException {
1145        return findAll(start, end, null);
1146    }
1147
1148    public List<PortletItem> findAll(int start, int end,
1149        OrderByComparator orderByComparator) throws SystemException {
1150        Object[] finderArgs = new Object[] {
1151                String.valueOf(start), String.valueOf(end),
1152                String.valueOf(orderByComparator)
1153            };
1154
1155        List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1156                finderArgs, this);
1157
1158        if (list == null) {
1159            Session session = null;
1160
1161            try {
1162                session = openSession();
1163
1164                StringBundler query = null;
1165                String sql = null;
1166
1167                if (orderByComparator != null) {
1168                    query = new StringBundler(2 +
1169                            (orderByComparator.getOrderByFields().length * 3));
1170
1171                    query.append(_SQL_SELECT_PORTLETITEM);
1172
1173                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1174                        orderByComparator);
1175
1176                    sql = query.toString();
1177                }
1178
1179                sql = _SQL_SELECT_PORTLETITEM;
1180
1181                Query q = session.createQuery(sql);
1182
1183                if (orderByComparator == null) {
1184                    list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
1185                            start, end, false);
1186
1187                    Collections.sort(list);
1188                }
1189                else {
1190                    list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
1191                            start, end);
1192                }
1193            }
1194            catch (Exception e) {
1195                throw processException(e);
1196            }
1197            finally {
1198                if (list == null) {
1199                    list = new ArrayList<PortletItem>();
1200                }
1201
1202                cacheResult(list);
1203
1204                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1205
1206                closeSession(session);
1207            }
1208        }
1209
1210        return list;
1211    }
1212
1213    public void removeByG_C(long groupId, long classNameId)
1214        throws SystemException {
1215        for (PortletItem portletItem : findByG_C(groupId, classNameId)) {
1216            remove(portletItem);
1217        }
1218    }
1219
1220    public void removeByG_P_C(long groupId, String portletId, long classNameId)
1221        throws SystemException {
1222        for (PortletItem portletItem : findByG_P_C(groupId, portletId,
1223                classNameId)) {
1224            remove(portletItem);
1225        }
1226    }
1227
1228    public void removeByG_N_P_C(long groupId, String name, String portletId,
1229        long classNameId) throws NoSuchPortletItemException, SystemException {
1230        PortletItem portletItem = findByG_N_P_C(groupId, name, portletId,
1231                classNameId);
1232
1233        remove(portletItem);
1234    }
1235
1236    public void removeAll() throws SystemException {
1237        for (PortletItem portletItem : findAll()) {
1238            remove(portletItem);
1239        }
1240    }
1241
1242    public int countByG_C(long groupId, long classNameId)
1243        throws SystemException {
1244        Object[] finderArgs = new Object[] {
1245                new Long(groupId), new Long(classNameId)
1246            };
1247
1248        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
1249                finderArgs, this);
1250
1251        if (count == null) {
1252            Session session = null;
1253
1254            try {
1255                session = openSession();
1256
1257                StringBundler query = new StringBundler(3);
1258
1259                query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1260
1261                query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1262
1263                query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
1264
1265                String sql = query.toString();
1266
1267                Query q = session.createQuery(sql);
1268
1269                QueryPos qPos = QueryPos.getInstance(q);
1270
1271                qPos.add(groupId);
1272
1273                qPos.add(classNameId);
1274
1275                count = (Long)q.uniqueResult();
1276            }
1277            catch (Exception e) {
1278                throw processException(e);
1279            }
1280            finally {
1281                if (count == null) {
1282                    count = Long.valueOf(0);
1283                }
1284
1285                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
1286                    count);
1287
1288                closeSession(session);
1289            }
1290        }
1291
1292        return count.intValue();
1293    }
1294
1295    public int countByG_P_C(long groupId, String portletId, long classNameId)
1296        throws SystemException {
1297        Object[] finderArgs = new Object[] {
1298                new Long(groupId),
1299                
1300                portletId, new Long(classNameId)
1301            };
1302
1303        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_C,
1304                finderArgs, this);
1305
1306        if (count == null) {
1307            Session session = null;
1308
1309            try {
1310                session = openSession();
1311
1312                StringBundler query = new StringBundler(4);
1313
1314                query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1315
1316                query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
1317
1318                if (portletId == null) {
1319                    query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
1320                }
1321                else {
1322                    if (portletId.equals(StringPool.BLANK)) {
1323                        query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
1324                    }
1325                    else {
1326                        query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
1327                    }
1328                }
1329
1330                query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
1331
1332                String sql = query.toString();
1333
1334                Query q = session.createQuery(sql);
1335
1336                QueryPos qPos = QueryPos.getInstance(q);
1337
1338                qPos.add(groupId);
1339
1340                if (portletId != null) {
1341                    qPos.add(portletId);
1342                }
1343
1344                qPos.add(classNameId);
1345
1346                count = (Long)q.uniqueResult();
1347            }
1348            catch (Exception e) {
1349                throw processException(e);
1350            }
1351            finally {
1352                if (count == null) {
1353                    count = Long.valueOf(0);
1354                }
1355
1356                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_C,
1357                    finderArgs, count);
1358
1359                closeSession(session);
1360            }
1361        }
1362
1363        return count.intValue();
1364    }
1365
1366    public int countByG_N_P_C(long groupId, String name, String portletId,
1367        long classNameId) throws SystemException {
1368        Object[] finderArgs = new Object[] {
1369                new Long(groupId),
1370                
1371                name,
1372                
1373                portletId, new Long(classNameId)
1374            };
1375
1376        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_P_C,
1377                finderArgs, this);
1378
1379        if (count == null) {
1380            Session session = null;
1381
1382            try {
1383                session = openSession();
1384
1385                StringBundler query = new StringBundler(5);
1386
1387                query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1388
1389                query.append(_FINDER_COLUMN_G_N_P_C_GROUPID_2);
1390
1391                if (name == null) {
1392                    query.append(_FINDER_COLUMN_G_N_P_C_NAME_1);
1393                }
1394                else {
1395                    if (name.equals(StringPool.BLANK)) {
1396                        query.append(_FINDER_COLUMN_G_N_P_C_NAME_3);
1397                    }
1398                    else {
1399                        query.append(_FINDER_COLUMN_G_N_P_C_NAME_2);
1400                    }
1401                }
1402
1403                if (portletId == null) {
1404                    query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_1);
1405                }
1406                else {
1407                    if (portletId.equals(StringPool.BLANK)) {
1408                        query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_3);
1409                    }
1410                    else {
1411                        query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_2);
1412                    }
1413                }
1414
1415                query.append(_FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2);
1416
1417                String sql = query.toString();
1418
1419                Query q = session.createQuery(sql);
1420
1421                QueryPos qPos = QueryPos.getInstance(q);
1422
1423                qPos.add(groupId);
1424
1425                if (name != null) {
1426                    qPos.add(name);
1427                }
1428
1429                if (portletId != null) {
1430                    qPos.add(portletId);
1431                }
1432
1433                qPos.add(classNameId);
1434
1435                count = (Long)q.uniqueResult();
1436            }
1437            catch (Exception e) {
1438                throw processException(e);
1439            }
1440            finally {
1441                if (count == null) {
1442                    count = Long.valueOf(0);
1443                }
1444
1445                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_P_C,
1446                    finderArgs, count);
1447
1448                closeSession(session);
1449            }
1450        }
1451
1452        return count.intValue();
1453    }
1454
1455    public int countAll() throws SystemException {
1456        Object[] finderArgs = new Object[0];
1457
1458        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1459                finderArgs, this);
1460
1461        if (count == null) {
1462            Session session = null;
1463
1464            try {
1465                session = openSession();
1466
1467                Query q = session.createQuery(_SQL_COUNT_PORTLETITEM);
1468
1469                count = (Long)q.uniqueResult();
1470            }
1471            catch (Exception e) {
1472                throw processException(e);
1473            }
1474            finally {
1475                if (count == null) {
1476                    count = Long.valueOf(0);
1477                }
1478
1479                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1480                    count);
1481
1482                closeSession(session);
1483            }
1484        }
1485
1486        return count.intValue();
1487    }
1488
1489    public void afterPropertiesSet() {
1490        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1491                    com.liferay.portal.util.PropsUtil.get(
1492                        "value.object.listener.com.liferay.portal.model.PortletItem")));
1493
1494        if (listenerClassNames.length > 0) {
1495            try {
1496                List<ModelListener<PortletItem>> listenersList = new ArrayList<ModelListener<PortletItem>>();
1497
1498                for (String listenerClassName : listenerClassNames) {
1499                    listenersList.add((ModelListener<PortletItem>)Class.forName(
1500                            listenerClassName).newInstance());
1501                }
1502
1503                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1504            }
1505            catch (Exception e) {
1506                _log.error(e);
1507            }
1508        }
1509    }
1510
1511    @BeanReference(type = AccountPersistence.class)
1512    protected AccountPersistence accountPersistence;
1513    @BeanReference(type = AddressPersistence.class)
1514    protected AddressPersistence addressPersistence;
1515    @BeanReference(type = BrowserTrackerPersistence.class)
1516    protected BrowserTrackerPersistence browserTrackerPersistence;
1517    @BeanReference(type = ClassNamePersistence.class)
1518    protected ClassNamePersistence classNamePersistence;
1519    @BeanReference(type = CompanyPersistence.class)
1520    protected CompanyPersistence companyPersistence;
1521    @BeanReference(type = ContactPersistence.class)
1522    protected ContactPersistence contactPersistence;
1523    @BeanReference(type = CountryPersistence.class)
1524    protected CountryPersistence countryPersistence;
1525    @BeanReference(type = EmailAddressPersistence.class)
1526    protected EmailAddressPersistence emailAddressPersistence;
1527    @BeanReference(type = GroupPersistence.class)
1528    protected GroupPersistence groupPersistence;
1529    @BeanReference(type = ImagePersistence.class)
1530    protected ImagePersistence imagePersistence;
1531    @BeanReference(type = LayoutPersistence.class)
1532    protected LayoutPersistence layoutPersistence;
1533    @BeanReference(type = LayoutPrototypePersistence.class)
1534    protected LayoutPrototypePersistence layoutPrototypePersistence;
1535    @BeanReference(type = LayoutSetPersistence.class)
1536    protected LayoutSetPersistence layoutSetPersistence;
1537    @BeanReference(type = LayoutSetPrototypePersistence.class)
1538    protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1539    @BeanReference(type = ListTypePersistence.class)
1540    protected ListTypePersistence listTypePersistence;
1541    @BeanReference(type = LockPersistence.class)
1542    protected LockPersistence lockPersistence;
1543    @BeanReference(type = MembershipRequestPersistence.class)
1544    protected MembershipRequestPersistence membershipRequestPersistence;
1545    @BeanReference(type = OrganizationPersistence.class)
1546    protected OrganizationPersistence organizationPersistence;
1547    @BeanReference(type = OrgGroupPermissionPersistence.class)
1548    protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1549    @BeanReference(type = OrgGroupRolePersistence.class)
1550    protected OrgGroupRolePersistence orgGroupRolePersistence;
1551    @BeanReference(type = OrgLaborPersistence.class)
1552    protected OrgLaborPersistence orgLaborPersistence;
1553    @BeanReference(type = PasswordPolicyPersistence.class)
1554    protected PasswordPolicyPersistence passwordPolicyPersistence;
1555    @BeanReference(type = PasswordPolicyRelPersistence.class)
1556    protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1557    @BeanReference(type = PasswordTrackerPersistence.class)
1558    protected PasswordTrackerPersistence passwordTrackerPersistence;
1559    @BeanReference(type = PermissionPersistence.class)
1560    protected PermissionPersistence permissionPersistence;
1561    @BeanReference(type = PhonePersistence.class)
1562    protected PhonePersistence phonePersistence;
1563    @BeanReference(type = PluginSettingPersistence.class)
1564    protected PluginSettingPersistence pluginSettingPersistence;
1565    @BeanReference(type = PortletPersistence.class)
1566    protected PortletPersistence portletPersistence;
1567    @BeanReference(type = PortletItemPersistence.class)
1568    protected PortletItemPersistence portletItemPersistence;
1569    @BeanReference(type = PortletPreferencesPersistence.class)
1570    protected PortletPreferencesPersistence portletPreferencesPersistence;
1571    @BeanReference(type = RegionPersistence.class)
1572    protected RegionPersistence regionPersistence;
1573    @BeanReference(type = ReleasePersistence.class)
1574    protected ReleasePersistence releasePersistence;
1575    @BeanReference(type = ResourcePersistence.class)
1576    protected ResourcePersistence resourcePersistence;
1577    @BeanReference(type = ResourceActionPersistence.class)
1578    protected ResourceActionPersistence resourceActionPersistence;
1579    @BeanReference(type = ResourceCodePersistence.class)
1580    protected ResourceCodePersistence resourceCodePersistence;
1581    @BeanReference(type = ResourcePermissionPersistence.class)
1582    protected ResourcePermissionPersistence resourcePermissionPersistence;
1583    @BeanReference(type = RolePersistence.class)
1584    protected RolePersistence rolePersistence;
1585    @BeanReference(type = ServiceComponentPersistence.class)
1586    protected ServiceComponentPersistence serviceComponentPersistence;
1587    @BeanReference(type = ShardPersistence.class)
1588    protected ShardPersistence shardPersistence;
1589    @BeanReference(type = SubscriptionPersistence.class)
1590    protected SubscriptionPersistence subscriptionPersistence;
1591    @BeanReference(type = TeamPersistence.class)
1592    protected TeamPersistence teamPersistence;
1593    @BeanReference(type = UserPersistence.class)
1594    protected UserPersistence userPersistence;
1595    @BeanReference(type = UserGroupPersistence.class)
1596    protected UserGroupPersistence userGroupPersistence;
1597    @BeanReference(type = UserGroupGroupRolePersistence.class)
1598    protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1599    @BeanReference(type = UserGroupRolePersistence.class)
1600    protected UserGroupRolePersistence userGroupRolePersistence;
1601    @BeanReference(type = UserIdMapperPersistence.class)
1602    protected UserIdMapperPersistence userIdMapperPersistence;
1603    @BeanReference(type = UserTrackerPersistence.class)
1604    protected UserTrackerPersistence userTrackerPersistence;
1605    @BeanReference(type = UserTrackerPathPersistence.class)
1606    protected UserTrackerPathPersistence userTrackerPathPersistence;
1607    @BeanReference(type = WebDAVPropsPersistence.class)
1608    protected WebDAVPropsPersistence webDAVPropsPersistence;
1609    @BeanReference(type = WebsitePersistence.class)
1610    protected WebsitePersistence websitePersistence;
1611    @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1612    protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1613    @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1614    protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1615    private static final String _SQL_SELECT_PORTLETITEM = "SELECT portletItem FROM PortletItem portletItem";
1616    private static final String _SQL_SELECT_PORTLETITEM_WHERE = "SELECT portletItem FROM PortletItem portletItem WHERE ";
1617    private static final String _SQL_COUNT_PORTLETITEM = "SELECT COUNT(portletItem) FROM PortletItem portletItem";
1618    private static final String _SQL_COUNT_PORTLETITEM_WHERE = "SELECT COUNT(portletItem) FROM PortletItem portletItem WHERE ";
1619    private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "portletItem.groupId = ? AND ";
1620    private static final String _FINDER_COLUMN_G_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
1621    private static final String _FINDER_COLUMN_G_P_C_GROUPID_2 = "portletItem.groupId = ? AND ";
1622    private static final String _FINDER_COLUMN_G_P_C_PORTLETID_1 = "portletItem.portletId IS NULL AND ";
1623    private static final String _FINDER_COLUMN_G_P_C_PORTLETID_2 = "portletItem.portletId = ? AND ";
1624    private static final String _FINDER_COLUMN_G_P_C_PORTLETID_3 = "(portletItem.portletId IS NULL OR portletItem.portletId = ?) AND ";
1625    private static final String _FINDER_COLUMN_G_P_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
1626    private static final String _FINDER_COLUMN_G_N_P_C_GROUPID_2 = "portletItem.groupId = ? AND ";
1627    private static final String _FINDER_COLUMN_G_N_P_C_NAME_1 = "portletItem.name IS NULL AND ";
1628    private static final String _FINDER_COLUMN_G_N_P_C_NAME_2 = "lower(portletItem.name) = ? AND ";
1629    private static final String _FINDER_COLUMN_G_N_P_C_NAME_3 = "(portletItem.name IS NULL OR lower(portletItem.name) = ?) AND ";
1630    private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_1 = "portletItem.portletId IS NULL AND ";
1631    private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_2 = "portletItem.portletId = ? AND ";
1632    private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_3 = "(portletItem.portletId IS NULL OR portletItem.portletId = ?) AND ";
1633    private static final String _FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
1634    private static final String _ORDER_BY_ENTITY_ALIAS = "portletItem.";
1635    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PortletItem exists with the primary key ";
1636    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PortletItem exists with the key {";
1637    private static Log _log = LogFactoryUtil.getLog(PortletItemPersistenceImpl.class);
1638}