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