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