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