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