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