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