1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portal.service.persistence;
16  
17  import com.liferay.portal.NoSuchListTypeException;
18  import com.liferay.portal.NoSuchModelException;
19  import com.liferay.portal.SystemException;
20  import com.liferay.portal.kernel.annotation.BeanReference;
21  import com.liferay.portal.kernel.cache.CacheRegistry;
22  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
23  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
25  import com.liferay.portal.kernel.dao.orm.FinderPath;
26  import com.liferay.portal.kernel.dao.orm.Query;
27  import com.liferay.portal.kernel.dao.orm.QueryPos;
28  import com.liferay.portal.kernel.dao.orm.QueryUtil;
29  import com.liferay.portal.kernel.dao.orm.Session;
30  import com.liferay.portal.kernel.log.Log;
31  import com.liferay.portal.kernel.log.LogFactoryUtil;
32  import com.liferay.portal.kernel.util.GetterUtil;
33  import com.liferay.portal.kernel.util.OrderByComparator;
34  import com.liferay.portal.kernel.util.StringBundler;
35  import com.liferay.portal.kernel.util.StringPool;
36  import com.liferay.portal.kernel.util.StringUtil;
37  import com.liferay.portal.model.ListType;
38  import com.liferay.portal.model.ModelListener;
39  import com.liferay.portal.model.impl.ListTypeImpl;
40  import com.liferay.portal.model.impl.ListTypeModelImpl;
41  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42  
43  import java.io.Serializable;
44  
45  import java.util.ArrayList;
46  import java.util.Collections;
47  import java.util.List;
48  
49  /**
50   * <a href="ListTypePersistenceImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       ListTypePersistence
59   * @see       ListTypeUtil
60   * @generated
61   */
62  public class ListTypePersistenceImpl extends BasePersistenceImpl<ListType>
63      implements ListTypePersistence {
64      public static final String FINDER_CLASS_NAME_ENTITY = ListTypeImpl.class.getName();
65      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66          ".List";
67      public static final FinderPath FINDER_PATH_FIND_BY_TYPE = new FinderPath(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
68              ListTypeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
69              "findByType", new String[] { String.class.getName() });
70      public static final FinderPath FINDER_PATH_FIND_BY_OBC_TYPE = new FinderPath(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
71              ListTypeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
72              "findByType",
73              new String[] {
74                  String.class.getName(),
75                  
76              "java.lang.Integer", "java.lang.Integer",
77                  "com.liferay.portal.kernel.util.OrderByComparator"
78              });
79      public static final FinderPath FINDER_PATH_COUNT_BY_TYPE = new FinderPath(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
80              ListTypeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81              "countByType", new String[] { String.class.getName() });
82      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
83              ListTypeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
84              "findAll", new String[0]);
85      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
86              ListTypeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
87              "countAll", new String[0]);
88  
89      public void cacheResult(ListType listType) {
90          EntityCacheUtil.putResult(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
91              ListTypeImpl.class, listType.getPrimaryKey(), listType);
92      }
93  
94      public void cacheResult(List<ListType> listTypes) {
95          for (ListType listType : listTypes) {
96              if (EntityCacheUtil.getResult(
97                          ListTypeModelImpl.ENTITY_CACHE_ENABLED,
98                          ListTypeImpl.class, listType.getPrimaryKey(), this) == null) {
99                  cacheResult(listType);
100             }
101         }
102     }
103 
104     public void clearCache() {
105         CacheRegistry.clear(ListTypeImpl.class.getName());
106         EntityCacheUtil.clearCache(ListTypeImpl.class.getName());
107         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
108         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
109     }
110 
111     public ListType create(int listTypeId) {
112         ListType listType = new ListTypeImpl();
113 
114         listType.setNew(true);
115         listType.setPrimaryKey(listTypeId);
116 
117         return listType;
118     }
119 
120     public ListType remove(Serializable primaryKey)
121         throws NoSuchModelException, SystemException {
122         return remove(((Integer)primaryKey).intValue());
123     }
124 
125     public ListType remove(int listTypeId)
126         throws NoSuchListTypeException, SystemException {
127         Session session = null;
128 
129         try {
130             session = openSession();
131 
132             ListType listType = (ListType)session.get(ListTypeImpl.class,
133                     new Integer(listTypeId));
134 
135             if (listType == null) {
136                 if (_log.isWarnEnabled()) {
137                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + listTypeId);
138                 }
139 
140                 throw new NoSuchListTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
141                     listTypeId);
142             }
143 
144             return remove(listType);
145         }
146         catch (NoSuchListTypeException nsee) {
147             throw nsee;
148         }
149         catch (Exception e) {
150             throw processException(e);
151         }
152         finally {
153             closeSession(session);
154         }
155     }
156 
157     public ListType remove(ListType listType) throws SystemException {
158         for (ModelListener<ListType> listener : listeners) {
159             listener.onBeforeRemove(listType);
160         }
161 
162         listType = removeImpl(listType);
163 
164         for (ModelListener<ListType> listener : listeners) {
165             listener.onAfterRemove(listType);
166         }
167 
168         return listType;
169     }
170 
171     protected ListType removeImpl(ListType listType) throws SystemException {
172         listType = toUnwrappedModel(listType);
173 
174         Session session = null;
175 
176         try {
177             session = openSession();
178 
179             if (listType.isCachedModel() || BatchSessionUtil.isEnabled()) {
180                 Object staleObject = session.get(ListTypeImpl.class,
181                         listType.getPrimaryKeyObj());
182 
183                 if (staleObject != null) {
184                     session.evict(staleObject);
185                 }
186             }
187 
188             session.delete(listType);
189 
190             session.flush();
191         }
192         catch (Exception e) {
193             throw processException(e);
194         }
195         finally {
196             closeSession(session);
197         }
198 
199         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
200 
201         EntityCacheUtil.removeResult(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
202             ListTypeImpl.class, listType.getPrimaryKey());
203 
204         return listType;
205     }
206 
207     /**
208      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
209      */
210     public ListType update(ListType listType) throws SystemException {
211         if (_log.isWarnEnabled()) {
212             _log.warn(
213                 "Using the deprecated update(ListType listType) method. Use update(ListType listType, boolean merge) instead.");
214         }
215 
216         return update(listType, false);
217     }
218 
219     public ListType updateImpl(com.liferay.portal.model.ListType listType,
220         boolean merge) throws SystemException {
221         listType = toUnwrappedModel(listType);
222 
223         Session session = null;
224 
225         try {
226             session = openSession();
227 
228             BatchSessionUtil.update(session, listType, merge);
229 
230             listType.setNew(false);
231         }
232         catch (Exception e) {
233             throw processException(e);
234         }
235         finally {
236             closeSession(session);
237         }
238 
239         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
240 
241         EntityCacheUtil.putResult(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
242             ListTypeImpl.class, listType.getPrimaryKey(), listType);
243 
244         return listType;
245     }
246 
247     protected ListType toUnwrappedModel(ListType listType) {
248         if (listType instanceof ListTypeImpl) {
249             return listType;
250         }
251 
252         ListTypeImpl listTypeImpl = new ListTypeImpl();
253 
254         listTypeImpl.setNew(listType.isNew());
255         listTypeImpl.setPrimaryKey(listType.getPrimaryKey());
256 
257         listTypeImpl.setListTypeId(listType.getListTypeId());
258         listTypeImpl.setName(listType.getName());
259         listTypeImpl.setType(listType.getType());
260 
261         return listTypeImpl;
262     }
263 
264     public ListType findByPrimaryKey(Serializable primaryKey)
265         throws NoSuchModelException, SystemException {
266         return findByPrimaryKey(((Integer)primaryKey).intValue());
267     }
268 
269     public ListType findByPrimaryKey(int listTypeId)
270         throws NoSuchListTypeException, SystemException {
271         ListType listType = fetchByPrimaryKey(listTypeId);
272 
273         if (listType == null) {
274             if (_log.isWarnEnabled()) {
275                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + listTypeId);
276             }
277 
278             throw new NoSuchListTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
279                 listTypeId);
280         }
281 
282         return listType;
283     }
284 
285     public ListType fetchByPrimaryKey(Serializable primaryKey)
286         throws SystemException {
287         return fetchByPrimaryKey(((Integer)primaryKey).intValue());
288     }
289 
290     public ListType fetchByPrimaryKey(int listTypeId) throws SystemException {
291         ListType listType = (ListType)EntityCacheUtil.getResult(ListTypeModelImpl.ENTITY_CACHE_ENABLED,
292                 ListTypeImpl.class, listTypeId, this);
293 
294         if (listType == null) {
295             Session session = null;
296 
297             try {
298                 session = openSession();
299 
300                 listType = (ListType)session.get(ListTypeImpl.class,
301                         new Integer(listTypeId));
302             }
303             catch (Exception e) {
304                 throw processException(e);
305             }
306             finally {
307                 if (listType != null) {
308                     cacheResult(listType);
309                 }
310 
311                 closeSession(session);
312             }
313         }
314 
315         return listType;
316     }
317 
318     public List<ListType> findByType(String type) throws SystemException {
319         Object[] finderArgs = new Object[] { type };
320 
321         List<ListType> list = (List<ListType>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_TYPE,
322                 finderArgs, this);
323 
324         if (list == null) {
325             Session session = null;
326 
327             try {
328                 session = openSession();
329 
330                 StringBundler query = new StringBundler(3);
331 
332                 query.append(_SQL_SELECT_LISTTYPE_WHERE);
333 
334                 if (type == null) {
335                     query.append(_FINDER_COLUMN_TYPE_TYPE_1);
336                 }
337                 else {
338                     if (type.equals(StringPool.BLANK)) {
339                         query.append(_FINDER_COLUMN_TYPE_TYPE_3);
340                     }
341                     else {
342                         query.append(_FINDER_COLUMN_TYPE_TYPE_2);
343                     }
344                 }
345 
346                 query.append(ListTypeModelImpl.ORDER_BY_JPQL);
347 
348                 String sql = query.toString();
349 
350                 Query q = session.createQuery(sql);
351 
352                 QueryPos qPos = QueryPos.getInstance(q);
353 
354                 if (type != null) {
355                     qPos.add(type);
356                 }
357 
358                 list = q.list();
359             }
360             catch (Exception e) {
361                 throw processException(e);
362             }
363             finally {
364                 if (list == null) {
365                     list = new ArrayList<ListType>();
366                 }
367 
368                 cacheResult(list);
369 
370                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_TYPE, finderArgs,
371                     list);
372 
373                 closeSession(session);
374             }
375         }
376 
377         return list;
378     }
379 
380     public List<ListType> findByType(String type, int start, int end)
381         throws SystemException {
382         return findByType(type, start, end, null);
383     }
384 
385     public List<ListType> findByType(String type, int start, int end,
386         OrderByComparator obc) throws SystemException {
387         Object[] finderArgs = new Object[] {
388                 type,
389                 
390                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
391             };
392 
393         List<ListType> list = (List<ListType>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_TYPE,
394                 finderArgs, this);
395 
396         if (list == null) {
397             Session session = null;
398 
399             try {
400                 session = openSession();
401 
402                 StringBundler query = null;
403 
404                 if (obc != null) {
405                     query = new StringBundler(3 +
406                             (obc.getOrderByFields().length * 3));
407                 }
408                 else {
409                     query = new StringBundler(3);
410                 }
411 
412                 query.append(_SQL_SELECT_LISTTYPE_WHERE);
413 
414                 if (type == null) {
415                     query.append(_FINDER_COLUMN_TYPE_TYPE_1);
416                 }
417                 else {
418                     if (type.equals(StringPool.BLANK)) {
419                         query.append(_FINDER_COLUMN_TYPE_TYPE_3);
420                     }
421                     else {
422                         query.append(_FINDER_COLUMN_TYPE_TYPE_2);
423                     }
424                 }
425 
426                 if (obc != null) {
427                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
428                 }
429 
430                 else {
431                     query.append(ListTypeModelImpl.ORDER_BY_JPQL);
432                 }
433 
434                 String sql = query.toString();
435 
436                 Query q = session.createQuery(sql);
437 
438                 QueryPos qPos = QueryPos.getInstance(q);
439 
440                 if (type != null) {
441                     qPos.add(type);
442                 }
443 
444                 list = (List<ListType>)QueryUtil.list(q, getDialect(), start,
445                         end);
446             }
447             catch (Exception e) {
448                 throw processException(e);
449             }
450             finally {
451                 if (list == null) {
452                     list = new ArrayList<ListType>();
453                 }
454 
455                 cacheResult(list);
456 
457                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_TYPE,
458                     finderArgs, list);
459 
460                 closeSession(session);
461             }
462         }
463 
464         return list;
465     }
466 
467     public ListType findByType_First(String type, OrderByComparator obc)
468         throws NoSuchListTypeException, SystemException {
469         List<ListType> list = findByType(type, 0, 1, obc);
470 
471         if (list.isEmpty()) {
472             StringBundler msg = new StringBundler(4);
473 
474             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
475 
476             msg.append("type=");
477             msg.append(type);
478 
479             msg.append(StringPool.CLOSE_CURLY_BRACE);
480 
481             throw new NoSuchListTypeException(msg.toString());
482         }
483         else {
484             return list.get(0);
485         }
486     }
487 
488     public ListType findByType_Last(String type, OrderByComparator obc)
489         throws NoSuchListTypeException, SystemException {
490         int count = countByType(type);
491 
492         List<ListType> list = findByType(type, count - 1, count, obc);
493 
494         if (list.isEmpty()) {
495             StringBundler msg = new StringBundler(4);
496 
497             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
498 
499             msg.append("type=");
500             msg.append(type);
501 
502             msg.append(StringPool.CLOSE_CURLY_BRACE);
503 
504             throw new NoSuchListTypeException(msg.toString());
505         }
506         else {
507             return list.get(0);
508         }
509     }
510 
511     public ListType[] findByType_PrevAndNext(int listTypeId, String type,
512         OrderByComparator obc) throws NoSuchListTypeException, SystemException {
513         ListType listType = findByPrimaryKey(listTypeId);
514 
515         int count = countByType(type);
516 
517         Session session = null;
518 
519         try {
520             session = openSession();
521 
522             StringBundler query = null;
523 
524             if (obc != null) {
525                 query = new StringBundler(3 +
526                         (obc.getOrderByFields().length * 3));
527             }
528             else {
529                 query = new StringBundler(3);
530             }
531 
532             query.append(_SQL_SELECT_LISTTYPE_WHERE);
533 
534             if (type == null) {
535                 query.append(_FINDER_COLUMN_TYPE_TYPE_1);
536             }
537             else {
538                 if (type.equals(StringPool.BLANK)) {
539                     query.append(_FINDER_COLUMN_TYPE_TYPE_3);
540                 }
541                 else {
542                     query.append(_FINDER_COLUMN_TYPE_TYPE_2);
543                 }
544             }
545 
546             if (obc != null) {
547                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
548             }
549 
550             else {
551                 query.append(ListTypeModelImpl.ORDER_BY_JPQL);
552             }
553 
554             String sql = query.toString();
555 
556             Query q = session.createQuery(sql);
557 
558             QueryPos qPos = QueryPos.getInstance(q);
559 
560             if (type != null) {
561                 qPos.add(type);
562             }
563 
564             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, listType);
565 
566             ListType[] array = new ListTypeImpl[3];
567 
568             array[0] = (ListType)objArray[0];
569             array[1] = (ListType)objArray[1];
570             array[2] = (ListType)objArray[2];
571 
572             return array;
573         }
574         catch (Exception e) {
575             throw processException(e);
576         }
577         finally {
578             closeSession(session);
579         }
580     }
581 
582     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
583         throws SystemException {
584         Session session = null;
585 
586         try {
587             session = openSession();
588 
589             dynamicQuery.compile(session);
590 
591             return dynamicQuery.list();
592         }
593         catch (Exception e) {
594             throw processException(e);
595         }
596         finally {
597             closeSession(session);
598         }
599     }
600 
601     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
602         int start, int end) throws SystemException {
603         Session session = null;
604 
605         try {
606             session = openSession();
607 
608             dynamicQuery.setLimit(start, end);
609 
610             dynamicQuery.compile(session);
611 
612             return dynamicQuery.list();
613         }
614         catch (Exception e) {
615             throw processException(e);
616         }
617         finally {
618             closeSession(session);
619         }
620     }
621 
622     public List<ListType> findAll() throws SystemException {
623         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
624     }
625 
626     public List<ListType> findAll(int start, int end) throws SystemException {
627         return findAll(start, end, null);
628     }
629 
630     public List<ListType> findAll(int start, int end, OrderByComparator obc)
631         throws SystemException {
632         Object[] finderArgs = new Object[] {
633                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
634             };
635 
636         List<ListType> list = (List<ListType>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
637                 finderArgs, this);
638 
639         if (list == null) {
640             Session session = null;
641 
642             try {
643                 session = openSession();
644 
645                 StringBundler query = null;
646                 String sql = null;
647 
648                 if (obc != null) {
649                     query = new StringBundler(2 +
650                             (obc.getOrderByFields().length * 3));
651 
652                     query.append(_SQL_SELECT_LISTTYPE);
653 
654                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
655 
656                     sql = query.toString();
657                 }
658 
659                 else {
660                     sql = _SQL_SELECT_LISTTYPE.concat(ListTypeModelImpl.ORDER_BY_JPQL);
661                 }
662 
663                 Query q = session.createQuery(sql);
664 
665                 if (obc == null) {
666                     list = (List<ListType>)QueryUtil.list(q, getDialect(),
667                             start, end, false);
668 
669                     Collections.sort(list);
670                 }
671                 else {
672                     list = (List<ListType>)QueryUtil.list(q, getDialect(),
673                             start, end);
674                 }
675             }
676             catch (Exception e) {
677                 throw processException(e);
678             }
679             finally {
680                 if (list == null) {
681                     list = new ArrayList<ListType>();
682                 }
683 
684                 cacheResult(list);
685 
686                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
687 
688                 closeSession(session);
689             }
690         }
691 
692         return list;
693     }
694 
695     public void removeByType(String type) throws SystemException {
696         for (ListType listType : findByType(type)) {
697             remove(listType);
698         }
699     }
700 
701     public void removeAll() throws SystemException {
702         for (ListType listType : findAll()) {
703             remove(listType);
704         }
705     }
706 
707     public int countByType(String type) throws SystemException {
708         Object[] finderArgs = new Object[] { type };
709 
710         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TYPE,
711                 finderArgs, this);
712 
713         if (count == null) {
714             Session session = null;
715 
716             try {
717                 session = openSession();
718 
719                 StringBundler query = new StringBundler(2);
720 
721                 query.append(_SQL_COUNT_LISTTYPE_WHERE);
722 
723                 if (type == null) {
724                     query.append(_FINDER_COLUMN_TYPE_TYPE_1);
725                 }
726                 else {
727                     if (type.equals(StringPool.BLANK)) {
728                         query.append(_FINDER_COLUMN_TYPE_TYPE_3);
729                     }
730                     else {
731                         query.append(_FINDER_COLUMN_TYPE_TYPE_2);
732                     }
733                 }
734 
735                 String sql = query.toString();
736 
737                 Query q = session.createQuery(sql);
738 
739                 QueryPos qPos = QueryPos.getInstance(q);
740 
741                 if (type != null) {
742                     qPos.add(type);
743                 }
744 
745                 count = (Long)q.uniqueResult();
746             }
747             catch (Exception e) {
748                 throw processException(e);
749             }
750             finally {
751                 if (count == null) {
752                     count = Long.valueOf(0);
753                 }
754 
755                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TYPE,
756                     finderArgs, count);
757 
758                 closeSession(session);
759             }
760         }
761 
762         return count.intValue();
763     }
764 
765     public int countAll() throws SystemException {
766         Object[] finderArgs = new Object[0];
767 
768         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
769                 finderArgs, this);
770 
771         if (count == null) {
772             Session session = null;
773 
774             try {
775                 session = openSession();
776 
777                 Query q = session.createQuery(_SQL_COUNT_LISTTYPE);
778 
779                 count = (Long)q.uniqueResult();
780             }
781             catch (Exception e) {
782                 throw processException(e);
783             }
784             finally {
785                 if (count == null) {
786                     count = Long.valueOf(0);
787                 }
788 
789                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
790                     count);
791 
792                 closeSession(session);
793             }
794         }
795 
796         return count.intValue();
797     }
798 
799     public void afterPropertiesSet() {
800         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
801                     com.liferay.portal.util.PropsUtil.get(
802                         "value.object.listener.com.liferay.portal.model.ListType")));
803 
804         if (listenerClassNames.length > 0) {
805             try {
806                 List<ModelListener<ListType>> listenersList = new ArrayList<ModelListener<ListType>>();
807 
808                 for (String listenerClassName : listenerClassNames) {
809                     listenersList.add((ModelListener<ListType>)Class.forName(
810                             listenerClassName).newInstance());
811                 }
812 
813                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
814             }
815             catch (Exception e) {
816                 _log.error(e);
817             }
818         }
819     }
820 
821     @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
822     protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
823     @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
824     protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
825     @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
826     protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
827     @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
828     protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
829     @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
830     protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
831     @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
832     protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
833     @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
834     protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
835     @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
836     protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
837     @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
838     protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
839     @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
840     protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
841     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
842     protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
843     @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
844     protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
845     @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
846     protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
847     @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
848     protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
849     @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
850     protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
851     @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
852     protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
853     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
854     protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
855     @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
856     protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
857     @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
858     protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
859     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
860     protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
861     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
862     protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
863     @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
864     protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
865     @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
866     protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
867     @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
868     protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
869     @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
870     protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
871     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
872     protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
873     @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
874     protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
875     @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
876     protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
877     @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
878     protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
879     @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
880     protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
881     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
882     protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
883     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
884     protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
885     @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
886     protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
887     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
888     protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
889     @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
890     protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
891     @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
892     protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
893     @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
894     protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
895     @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
896     protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
897     @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
898     protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
899     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
900     protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
901     @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
902     protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
903     @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
904     protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
905     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
906     protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
907     @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
908     protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
909     @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
910     protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
911     @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
912     protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
913     private static final String _SQL_SELECT_LISTTYPE = "SELECT listType FROM ListType listType";
914     private static final String _SQL_SELECT_LISTTYPE_WHERE = "SELECT listType FROM ListType listType WHERE ";
915     private static final String _SQL_COUNT_LISTTYPE = "SELECT COUNT(listType) FROM ListType listType";
916     private static final String _SQL_COUNT_LISTTYPE_WHERE = "SELECT COUNT(listType) FROM ListType listType WHERE ";
917     private static final String _FINDER_COLUMN_TYPE_TYPE_1 = "listType.type IS NULL";
918     private static final String _FINDER_COLUMN_TYPE_TYPE_2 = "listType.type = ?";
919     private static final String _FINDER_COLUMN_TYPE_TYPE_3 = "(listType.type IS NULL OR listType.type = ?)";
920     private static final String _ORDER_BY_ENTITY_ALIAS = "listType.";
921     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ListType exists with the primary key ";
922     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ListType exists with the key {";
923     private static Log _log = LogFactoryUtil.getLog(ListTypePersistenceImpl.class);
924 }