001    /**
002     * Copyright (c) 2000-present 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.counter.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.counter.NoSuchCounterException;
020    import com.liferay.counter.model.Counter;
021    import com.liferay.counter.model.impl.CounterImpl;
022    import com.liferay.counter.model.impl.CounterModelImpl;
023    import com.liferay.counter.service.persistence.CounterPersistence;
024    
025    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
026    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028    import com.liferay.portal.kernel.dao.orm.FinderPath;
029    import com.liferay.portal.kernel.dao.orm.Query;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.Session;
032    import com.liferay.portal.kernel.log.Log;
033    import com.liferay.portal.kernel.log.LogFactoryUtil;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
039    
040    import java.io.Serializable;
041    
042    import java.util.Collections;
043    import java.util.HashMap;
044    import java.util.HashSet;
045    import java.util.Iterator;
046    import java.util.List;
047    import java.util.Map;
048    import java.util.Set;
049    
050    /**
051     * The persistence implementation for the counter service.
052     *
053     * <p>
054     * Caching information and settings can be found in <code>portal.properties</code>
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see CounterPersistence
059     * @see CounterUtil
060     * @generated
061     */
062    @ProviderType
063    public class CounterPersistenceImpl extends BasePersistenceImpl<Counter>
064            implements CounterPersistence {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. Always use {@link CounterUtil} to access the counter persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
069             */
070            public static final String FINDER_CLASS_NAME_ENTITY = CounterImpl.class.getName();
071            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072                    ".List1";
073            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List2";
075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(CounterModelImpl.ENTITY_CACHE_ENABLED,
076                            CounterModelImpl.FINDER_CACHE_ENABLED, CounterImpl.class,
077                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
078            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(CounterModelImpl.ENTITY_CACHE_ENABLED,
079                            CounterModelImpl.FINDER_CACHE_ENABLED, CounterImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CounterModelImpl.ENTITY_CACHE_ENABLED,
082                            CounterModelImpl.FINDER_CACHE_ENABLED, Long.class,
083                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
084    
085            public CounterPersistenceImpl() {
086                    setModelClass(Counter.class);
087            }
088    
089            /**
090             * Caches the counter in the entity cache if it is enabled.
091             *
092             * @param counter the counter
093             */
094            @Override
095            public void cacheResult(Counter counter) {
096                    EntityCacheUtil.putResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
097                            CounterImpl.class, counter.getPrimaryKey(), counter);
098    
099                    counter.resetOriginalValues();
100            }
101    
102            /**
103             * Caches the counters in the entity cache if it is enabled.
104             *
105             * @param counters the counters
106             */
107            @Override
108            public void cacheResult(List<Counter> counters) {
109                    for (Counter counter : counters) {
110                            if (EntityCacheUtil.getResult(
111                                                    CounterModelImpl.ENTITY_CACHE_ENABLED,
112                                                    CounterImpl.class, counter.getPrimaryKey()) == null) {
113                                    cacheResult(counter);
114                            }
115                            else {
116                                    counter.resetOriginalValues();
117                            }
118                    }
119            }
120    
121            /**
122             * Clears the cache for all counters.
123             *
124             * <p>
125             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
126             * </p>
127             */
128            @Override
129            public void clearCache() {
130                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
131                            CacheRegistryUtil.clear(CounterImpl.class.getName());
132                    }
133    
134                    EntityCacheUtil.clearCache(CounterImpl.class);
135    
136                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
137                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
138                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
139            }
140    
141            /**
142             * Clears the cache for the counter.
143             *
144             * <p>
145             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
146             * </p>
147             */
148            @Override
149            public void clearCache(Counter counter) {
150                    EntityCacheUtil.removeResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
151                            CounterImpl.class, counter.getPrimaryKey());
152    
153                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
154                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
155            }
156    
157            @Override
158            public void clearCache(List<Counter> counters) {
159                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
160                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
161    
162                    for (Counter counter : counters) {
163                            EntityCacheUtil.removeResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
164                                    CounterImpl.class, counter.getPrimaryKey());
165                    }
166            }
167    
168            /**
169             * Creates a new counter with the primary key. Does not add the counter to the database.
170             *
171             * @param name the primary key for the new counter
172             * @return the new counter
173             */
174            @Override
175            public Counter create(String name) {
176                    Counter counter = new CounterImpl();
177    
178                    counter.setNew(true);
179                    counter.setPrimaryKey(name);
180    
181                    return counter;
182            }
183    
184            /**
185             * Removes the counter with the primary key from the database. Also notifies the appropriate model listeners.
186             *
187             * @param name the primary key of the counter
188             * @return the counter that was removed
189             * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found
190             */
191            @Override
192            public Counter remove(String name) throws NoSuchCounterException {
193                    return remove((Serializable)name);
194            }
195    
196            /**
197             * Removes the counter with the primary key from the database. Also notifies the appropriate model listeners.
198             *
199             * @param primaryKey the primary key of the counter
200             * @return the counter that was removed
201             * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found
202             */
203            @Override
204            public Counter remove(Serializable primaryKey)
205                    throws NoSuchCounterException {
206                    Session session = null;
207    
208                    try {
209                            session = openSession();
210    
211                            Counter counter = (Counter)session.get(CounterImpl.class, primaryKey);
212    
213                            if (counter == null) {
214                                    if (_log.isWarnEnabled()) {
215                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
216                                    }
217    
218                                    throw new NoSuchCounterException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
219                                            primaryKey);
220                            }
221    
222                            return remove(counter);
223                    }
224                    catch (NoSuchCounterException nsee) {
225                            throw nsee;
226                    }
227                    catch (Exception e) {
228                            throw processException(e);
229                    }
230                    finally {
231                            closeSession(session);
232                    }
233            }
234    
235            @Override
236            protected Counter removeImpl(Counter counter) {
237                    counter = toUnwrappedModel(counter);
238    
239                    Session session = null;
240    
241                    try {
242                            session = openSession();
243    
244                            if (!session.contains(counter)) {
245                                    counter = (Counter)session.get(CounterImpl.class,
246                                                    counter.getPrimaryKeyObj());
247                            }
248    
249                            if (counter != null) {
250                                    session.delete(counter);
251                            }
252                    }
253                    catch (Exception e) {
254                            throw processException(e);
255                    }
256                    finally {
257                            closeSession(session);
258                    }
259    
260                    if (counter != null) {
261                            clearCache(counter);
262                    }
263    
264                    return counter;
265            }
266    
267            @Override
268            public Counter updateImpl(com.liferay.counter.model.Counter counter) {
269                    counter = toUnwrappedModel(counter);
270    
271                    boolean isNew = counter.isNew();
272    
273                    Session session = null;
274    
275                    try {
276                            session = openSession();
277    
278                            if (counter.isNew()) {
279                                    session.save(counter);
280    
281                                    counter.setNew(false);
282                            }
283                            else {
284                                    session.merge(counter);
285                            }
286                    }
287                    catch (Exception e) {
288                            throw processException(e);
289                    }
290                    finally {
291                            closeSession(session);
292                    }
293    
294                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
295    
296                    if (isNew) {
297                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
298                    }
299    
300                    EntityCacheUtil.putResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
301                            CounterImpl.class, counter.getPrimaryKey(), counter, false);
302    
303                    counter.resetOriginalValues();
304    
305                    return counter;
306            }
307    
308            protected Counter toUnwrappedModel(Counter counter) {
309                    if (counter instanceof CounterImpl) {
310                            return counter;
311                    }
312    
313                    CounterImpl counterImpl = new CounterImpl();
314    
315                    counterImpl.setNew(counter.isNew());
316                    counterImpl.setPrimaryKey(counter.getPrimaryKey());
317    
318                    counterImpl.setName(counter.getName());
319                    counterImpl.setCurrentId(counter.getCurrentId());
320    
321                    return counterImpl;
322            }
323    
324            /**
325             * Returns the counter with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
326             *
327             * @param primaryKey the primary key of the counter
328             * @return the counter
329             * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found
330             */
331            @Override
332            public Counter findByPrimaryKey(Serializable primaryKey)
333                    throws NoSuchCounterException {
334                    Counter counter = fetchByPrimaryKey(primaryKey);
335    
336                    if (counter == null) {
337                            if (_log.isWarnEnabled()) {
338                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
339                            }
340    
341                            throw new NoSuchCounterException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
342                                    primaryKey);
343                    }
344    
345                    return counter;
346            }
347    
348            /**
349             * Returns the counter with the primary key or throws a {@link com.liferay.counter.NoSuchCounterException} if it could not be found.
350             *
351             * @param name the primary key of the counter
352             * @return the counter
353             * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found
354             */
355            @Override
356            public Counter findByPrimaryKey(String name) throws NoSuchCounterException {
357                    return findByPrimaryKey((Serializable)name);
358            }
359    
360            /**
361             * Returns the counter with the primary key or returns <code>null</code> if it could not be found.
362             *
363             * @param primaryKey the primary key of the counter
364             * @return the counter, or <code>null</code> if a counter with the primary key could not be found
365             */
366            @Override
367            public Counter fetchByPrimaryKey(Serializable primaryKey) {
368                    Counter counter = (Counter)EntityCacheUtil.getResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
369                                    CounterImpl.class, primaryKey);
370    
371                    if (counter == _nullCounter) {
372                            return null;
373                    }
374    
375                    if (counter == null) {
376                            Session session = null;
377    
378                            try {
379                                    session = openSession();
380    
381                                    counter = (Counter)session.get(CounterImpl.class, primaryKey);
382    
383                                    if (counter != null) {
384                                            cacheResult(counter);
385                                    }
386                                    else {
387                                            EntityCacheUtil.putResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
388                                                    CounterImpl.class, primaryKey, _nullCounter);
389                                    }
390                            }
391                            catch (Exception e) {
392                                    EntityCacheUtil.removeResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
393                                            CounterImpl.class, primaryKey);
394    
395                                    throw processException(e);
396                            }
397                            finally {
398                                    closeSession(session);
399                            }
400                    }
401    
402                    return counter;
403            }
404    
405            /**
406             * Returns the counter with the primary key or returns <code>null</code> if it could not be found.
407             *
408             * @param name the primary key of the counter
409             * @return the counter, or <code>null</code> if a counter with the primary key could not be found
410             */
411            @Override
412            public Counter fetchByPrimaryKey(String name) {
413                    return fetchByPrimaryKey((Serializable)name);
414            }
415    
416            @Override
417            public Map<Serializable, Counter> fetchByPrimaryKeys(
418                    Set<Serializable> primaryKeys) {
419                    if (primaryKeys.isEmpty()) {
420                            return Collections.emptyMap();
421                    }
422    
423                    Map<Serializable, Counter> map = new HashMap<Serializable, Counter>();
424    
425                    if (primaryKeys.size() == 1) {
426                            Iterator<Serializable> iterator = primaryKeys.iterator();
427    
428                            Serializable primaryKey = iterator.next();
429    
430                            Counter counter = fetchByPrimaryKey(primaryKey);
431    
432                            if (counter != null) {
433                                    map.put(primaryKey, counter);
434                            }
435    
436                            return map;
437                    }
438    
439                    Set<Serializable> uncachedPrimaryKeys = null;
440    
441                    for (Serializable primaryKey : primaryKeys) {
442                            Counter counter = (Counter)EntityCacheUtil.getResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
443                                            CounterImpl.class, primaryKey);
444    
445                            if (counter == null) {
446                                    if (uncachedPrimaryKeys == null) {
447                                            uncachedPrimaryKeys = new HashSet<Serializable>();
448                                    }
449    
450                                    uncachedPrimaryKeys.add(primaryKey);
451                            }
452                            else {
453                                    map.put(primaryKey, counter);
454                            }
455                    }
456    
457                    if (uncachedPrimaryKeys == null) {
458                            return map;
459                    }
460    
461                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 4) +
462                                    1);
463    
464                    query.append(_SQL_SELECT_COUNTER_WHERE_PKS_IN);
465    
466                    for (Serializable primaryKey : uncachedPrimaryKeys) {
467                            query.append(StringPool.QUOTE);
468                            query.append((String)primaryKey);
469                            query.append(StringPool.QUOTE);
470    
471                            query.append(StringPool.COMMA);
472                    }
473    
474                    query.setIndex(query.index() - 1);
475    
476                    query.append(StringPool.CLOSE_PARENTHESIS);
477    
478                    String sql = query.toString();
479    
480                    Session session = null;
481    
482                    try {
483                            session = openSession();
484    
485                            Query q = session.createQuery(sql);
486    
487                            for (Counter counter : (List<Counter>)q.list()) {
488                                    map.put(counter.getPrimaryKeyObj(), counter);
489    
490                                    cacheResult(counter);
491    
492                                    uncachedPrimaryKeys.remove(counter.getPrimaryKeyObj());
493                            }
494    
495                            for (Serializable primaryKey : uncachedPrimaryKeys) {
496                                    EntityCacheUtil.putResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
497                                            CounterImpl.class, primaryKey, _nullCounter);
498                            }
499                    }
500                    catch (Exception e) {
501                            throw processException(e);
502                    }
503                    finally {
504                            closeSession(session);
505                    }
506    
507                    return map;
508            }
509    
510            /**
511             * Returns all the counters.
512             *
513             * @return the counters
514             */
515            @Override
516            public List<Counter> findAll() {
517                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
518            }
519    
520            /**
521             * Returns a range of all the counters.
522             *
523             * <p>
524             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.counter.model.impl.CounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
525             * </p>
526             *
527             * @param start the lower bound of the range of counters
528             * @param end the upper bound of the range of counters (not inclusive)
529             * @return the range of counters
530             */
531            @Override
532            public List<Counter> findAll(int start, int end) {
533                    return findAll(start, end, null);
534            }
535    
536            /**
537             * Returns an ordered range of all the counters.
538             *
539             * <p>
540             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.counter.model.impl.CounterModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
541             * </p>
542             *
543             * @param start the lower bound of the range of counters
544             * @param end the upper bound of the range of counters (not inclusive)
545             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
546             * @return the ordered range of counters
547             */
548            @Override
549            public List<Counter> findAll(int start, int end,
550                    OrderByComparator<Counter> orderByComparator) {
551                    boolean pagination = true;
552                    FinderPath finderPath = null;
553                    Object[] finderArgs = null;
554    
555                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
556                                    (orderByComparator == null)) {
557                            pagination = false;
558                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
559                            finderArgs = FINDER_ARGS_EMPTY;
560                    }
561                    else {
562                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
563                            finderArgs = new Object[] { start, end, orderByComparator };
564                    }
565    
566                    List<Counter> list = (List<Counter>)FinderCacheUtil.getResult(finderPath,
567                                    finderArgs, this);
568    
569                    if (list == null) {
570                            StringBundler query = null;
571                            String sql = null;
572    
573                            if (orderByComparator != null) {
574                                    query = new StringBundler(2 +
575                                                    (orderByComparator.getOrderByFields().length * 3));
576    
577                                    query.append(_SQL_SELECT_COUNTER);
578    
579                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
580                                            orderByComparator);
581    
582                                    sql = query.toString();
583                            }
584                            else {
585                                    sql = _SQL_SELECT_COUNTER;
586    
587                                    if (pagination) {
588                                            sql = sql.concat(CounterModelImpl.ORDER_BY_JPQL);
589                                    }
590                            }
591    
592                            Session session = null;
593    
594                            try {
595                                    session = openSession();
596    
597                                    Query q = session.createQuery(sql);
598    
599                                    if (!pagination) {
600                                            list = (List<Counter>)QueryUtil.list(q, getDialect(),
601                                                            start, end, false);
602    
603                                            Collections.sort(list);
604    
605                                            list = Collections.unmodifiableList(list);
606                                    }
607                                    else {
608                                            list = (List<Counter>)QueryUtil.list(q, getDialect(),
609                                                            start, end);
610                                    }
611    
612                                    cacheResult(list);
613    
614                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
615                            }
616                            catch (Exception e) {
617                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
618    
619                                    throw processException(e);
620                            }
621                            finally {
622                                    closeSession(session);
623                            }
624                    }
625    
626                    return list;
627            }
628    
629            /**
630             * Removes all the counters from the database.
631             *
632             */
633            @Override
634            public void removeAll() {
635                    for (Counter counter : findAll()) {
636                            remove(counter);
637                    }
638            }
639    
640            /**
641             * Returns the number of counters.
642             *
643             * @return the number of counters
644             */
645            @Override
646            public int countAll() {
647                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
648                                    FINDER_ARGS_EMPTY, this);
649    
650                    if (count == null) {
651                            Session session = null;
652    
653                            try {
654                                    session = openSession();
655    
656                                    Query q = session.createQuery(_SQL_COUNT_COUNTER);
657    
658                                    count = (Long)q.uniqueResult();
659    
660                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
661                                            FINDER_ARGS_EMPTY, count);
662                            }
663                            catch (Exception e) {
664                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
665                                            FINDER_ARGS_EMPTY);
666    
667                                    throw processException(e);
668                            }
669                            finally {
670                                    closeSession(session);
671                            }
672                    }
673    
674                    return count.intValue();
675            }
676    
677            /**
678             * Initializes the counter persistence.
679             */
680            public void afterPropertiesSet() {
681            }
682    
683            public void destroy() {
684                    EntityCacheUtil.removeCache(CounterImpl.class.getName());
685                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
686                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
687                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
688            }
689    
690            private static final String _SQL_SELECT_COUNTER = "SELECT counter FROM Counter counter";
691            private static final String _SQL_SELECT_COUNTER_WHERE_PKS_IN = "SELECT counter FROM Counter counter WHERE name IN (";
692            private static final String _SQL_COUNT_COUNTER = "SELECT COUNT(counter) FROM Counter counter";
693            private static final String _ORDER_BY_ENTITY_ALIAS = "counter.";
694            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Counter exists with the primary key ";
695            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
696            private static final Log _log = LogFactoryUtil.getLog(CounterPersistenceImpl.class);
697            private static final Counter _nullCounter = new CounterImpl() {
698                            @Override
699                            public Object clone() {
700                                    return this;
701                            }
702    
703                            @Override
704                            public CacheModel<Counter> toCacheModel() {
705                                    return _nullCounterCacheModel;
706                            }
707                    };
708    
709            private static final CacheModel<Counter> _nullCounterCacheModel = new CacheModel<Counter>() {
710                            @Override
711                            public Counter toEntityModel() {
712                                    return _nullCounter;
713                            }
714                    };
715    }