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