001    /**
002     * Copyright (c) 2000-2013 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;
016    
017    import com.liferay.counter.NoSuchCounterException;
018    import com.liferay.counter.model.Counter;
019    import com.liferay.counter.model.impl.CounterImpl;
020    import com.liferay.counter.model.impl.CounterModelImpl;
021    
022    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
023    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025    import com.liferay.portal.kernel.dao.orm.FinderPath;
026    import com.liferay.portal.kernel.dao.orm.Query;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.Session;
029    import com.liferay.portal.kernel.exception.SystemException;
030    import com.liferay.portal.kernel.log.Log;
031    import com.liferay.portal.kernel.log.LogFactoryUtil;
032    import com.liferay.portal.kernel.util.GetterUtil;
033    import com.liferay.portal.kernel.util.InstanceFactory;
034    import com.liferay.portal.kernel.util.OrderByComparator;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.UnmodifiableList;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import java.io.Serializable;
043    
044    import java.util.ArrayList;
045    import java.util.Collections;
046    import java.util.List;
047    
048    /**
049     * The persistence implementation for the counter service.
050     *
051     * <p>
052     * Caching information and settings can be found in <code>portal.properties</code>
053     * </p>
054     *
055     * @author Brian Wing Shun Chan
056     * @see CounterPersistence
057     * @see CounterUtil
058     * @generated
059     */
060    public class CounterPersistenceImpl extends BasePersistenceImpl<Counter>
061            implements CounterPersistence {
062            /*
063             * NOTE FOR DEVELOPERS:
064             *
065             * 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.
066             */
067            public static final String FINDER_CLASS_NAME_ENTITY = CounterImpl.class.getName();
068            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
069                    ".List1";
070            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071                    ".List2";
072            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(CounterModelImpl.ENTITY_CACHE_ENABLED,
073                            CounterModelImpl.FINDER_CACHE_ENABLED, CounterImpl.class,
074                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
075            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(CounterModelImpl.ENTITY_CACHE_ENABLED,
076                            CounterModelImpl.FINDER_CACHE_ENABLED, CounterImpl.class,
077                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
078            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CounterModelImpl.ENTITY_CACHE_ENABLED,
079                            CounterModelImpl.FINDER_CACHE_ENABLED, Long.class,
080                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
081    
082            public CounterPersistenceImpl() {
083                    setModelClass(Counter.class);
084            }
085    
086            /**
087             * Caches the counter in the entity cache if it is enabled.
088             *
089             * @param counter the counter
090             */
091            @Override
092            public void cacheResult(Counter counter) {
093                    EntityCacheUtil.putResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
094                            CounterImpl.class, counter.getPrimaryKey(), counter);
095    
096                    counter.resetOriginalValues();
097            }
098    
099            /**
100             * Caches the counters in the entity cache if it is enabled.
101             *
102             * @param counters the counters
103             */
104            @Override
105            public void cacheResult(List<Counter> counters) {
106                    for (Counter counter : counters) {
107                            if (EntityCacheUtil.getResult(
108                                                    CounterModelImpl.ENTITY_CACHE_ENABLED,
109                                                    CounterImpl.class, counter.getPrimaryKey()) == null) {
110                                    cacheResult(counter);
111                            }
112                            else {
113                                    counter.resetOriginalValues();
114                            }
115                    }
116            }
117    
118            /**
119             * Clears the cache for all counters.
120             *
121             * <p>
122             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
123             * </p>
124             */
125            @Override
126            public void clearCache() {
127                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
128                            CacheRegistryUtil.clear(CounterImpl.class.getName());
129                    }
130    
131                    EntityCacheUtil.clearCache(CounterImpl.class.getName());
132    
133                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
134                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
135                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
136            }
137    
138            /**
139             * Clears the cache for the counter.
140             *
141             * <p>
142             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
143             * </p>
144             */
145            @Override
146            public void clearCache(Counter counter) {
147                    EntityCacheUtil.removeResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
148                            CounterImpl.class, counter.getPrimaryKey());
149    
150                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
151                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
152            }
153    
154            @Override
155            public void clearCache(List<Counter> counters) {
156                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
157                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
158    
159                    for (Counter counter : counters) {
160                            EntityCacheUtil.removeResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
161                                    CounterImpl.class, counter.getPrimaryKey());
162                    }
163            }
164    
165            /**
166             * Creates a new counter with the primary key. Does not add the counter to the database.
167             *
168             * @param name the primary key for the new counter
169             * @return the new counter
170             */
171            @Override
172            public Counter create(String name) {
173                    Counter counter = new CounterImpl();
174    
175                    counter.setNew(true);
176                    counter.setPrimaryKey(name);
177    
178                    return counter;
179            }
180    
181            /**
182             * Removes the counter with the primary key from the database. Also notifies the appropriate model listeners.
183             *
184             * @param name the primary key of the counter
185             * @return the counter that was removed
186             * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found
187             * @throws SystemException if a system exception occurred
188             */
189            @Override
190            public Counter remove(String name)
191                    throws NoSuchCounterException, SystemException {
192                    return remove((Serializable)name);
193            }
194    
195            /**
196             * Removes the counter with the primary key from the database. Also notifies the appropriate model listeners.
197             *
198             * @param primaryKey the primary key of the counter
199             * @return the counter that was removed
200             * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found
201             * @throws SystemException if a system exception occurred
202             */
203            @Override
204            public Counter remove(Serializable primaryKey)
205                    throws NoSuchCounterException, SystemException {
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) throws SystemException {
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                    throws SystemException {
270                    counter = toUnwrappedModel(counter);
271    
272                    boolean isNew = counter.isNew();
273    
274                    Session session = null;
275    
276                    try {
277                            session = openSession();
278    
279                            if (counter.isNew()) {
280                                    session.save(counter);
281    
282                                    counter.setNew(false);
283                            }
284                            else {
285                                    session.merge(counter);
286                            }
287                    }
288                    catch (Exception e) {
289                            throw processException(e);
290                    }
291                    finally {
292                            closeSession(session);
293                    }
294    
295                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
296    
297                    if (isNew) {
298                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
299                    }
300    
301                    EntityCacheUtil.putResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
302                            CounterImpl.class, counter.getPrimaryKey(), counter);
303    
304                    return counter;
305            }
306    
307            protected Counter toUnwrappedModel(Counter counter) {
308                    if (counter instanceof CounterImpl) {
309                            return counter;
310                    }
311    
312                    CounterImpl counterImpl = new CounterImpl();
313    
314                    counterImpl.setNew(counter.isNew());
315                    counterImpl.setPrimaryKey(counter.getPrimaryKey());
316    
317                    counterImpl.setName(counter.getName());
318                    counterImpl.setCurrentId(counter.getCurrentId());
319    
320                    return counterImpl;
321            }
322    
323            /**
324             * Returns the counter with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
325             *
326             * @param primaryKey the primary key of the counter
327             * @return the counter
328             * @throws com.liferay.counter.NoSuchCounterException if a counter with the primary key could not be found
329             * @throws SystemException if a system exception occurred
330             */
331            @Override
332            public Counter findByPrimaryKey(Serializable primaryKey)
333                    throws NoSuchCounterException, SystemException {
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             * @throws SystemException if a system exception occurred
355             */
356            @Override
357            public Counter findByPrimaryKey(String name)
358                    throws NoSuchCounterException, SystemException {
359                    return findByPrimaryKey((Serializable)name);
360            }
361    
362            /**
363             * Returns the counter with the primary key or returns <code>null</code> if it could not be found.
364             *
365             * @param primaryKey the primary key of the counter
366             * @return the counter, or <code>null</code> if a counter with the primary key could not be found
367             * @throws SystemException if a system exception occurred
368             */
369            @Override
370            public Counter fetchByPrimaryKey(Serializable primaryKey)
371                    throws SystemException {
372                    Counter counter = (Counter)EntityCacheUtil.getResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
373                                    CounterImpl.class, primaryKey);
374    
375                    if (counter == _nullCounter) {
376                            return null;
377                    }
378    
379                    if (counter == null) {
380                            Session session = null;
381    
382                            try {
383                                    session = openSession();
384    
385                                    counter = (Counter)session.get(CounterImpl.class, primaryKey);
386    
387                                    if (counter != null) {
388                                            cacheResult(counter);
389                                    }
390                                    else {
391                                            EntityCacheUtil.putResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
392                                                    CounterImpl.class, primaryKey, _nullCounter);
393                                    }
394                            }
395                            catch (Exception e) {
396                                    EntityCacheUtil.removeResult(CounterModelImpl.ENTITY_CACHE_ENABLED,
397                                            CounterImpl.class, primaryKey);
398    
399                                    throw processException(e);
400                            }
401                            finally {
402                                    closeSession(session);
403                            }
404                    }
405    
406                    return counter;
407            }
408    
409            /**
410             * Returns the counter with the primary key or returns <code>null</code> if it could not be found.
411             *
412             * @param name the primary key of the counter
413             * @return the counter, or <code>null</code> if a counter with the primary key could not be found
414             * @throws SystemException if a system exception occurred
415             */
416            @Override
417            public Counter fetchByPrimaryKey(String name) throws SystemException {
418                    return fetchByPrimaryKey((Serializable)name);
419            }
420    
421            /**
422             * Returns all the counters.
423             *
424             * @return the counters
425             * @throws SystemException if a system exception occurred
426             */
427            @Override
428            public List<Counter> findAll() throws SystemException {
429                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
430            }
431    
432            /**
433             * Returns a range of all the counters.
434             *
435             * <p>
436             * 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.
437             * </p>
438             *
439             * @param start the lower bound of the range of counters
440             * @param end the upper bound of the range of counters (not inclusive)
441             * @return the range of counters
442             * @throws SystemException if a system exception occurred
443             */
444            @Override
445            public List<Counter> findAll(int start, int end) throws SystemException {
446                    return findAll(start, end, null);
447            }
448    
449            /**
450             * Returns an ordered range of all the counters.
451             *
452             * <p>
453             * 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.
454             * </p>
455             *
456             * @param start the lower bound of the range of counters
457             * @param end the upper bound of the range of counters (not inclusive)
458             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
459             * @return the ordered range of counters
460             * @throws SystemException if a system exception occurred
461             */
462            @Override
463            public List<Counter> findAll(int start, int end,
464                    OrderByComparator orderByComparator) throws SystemException {
465                    boolean pagination = true;
466                    FinderPath finderPath = null;
467                    Object[] finderArgs = null;
468    
469                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
470                                    (orderByComparator == null)) {
471                            pagination = false;
472                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
473                            finderArgs = FINDER_ARGS_EMPTY;
474                    }
475                    else {
476                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
477                            finderArgs = new Object[] { start, end, orderByComparator };
478                    }
479    
480                    List<Counter> list = (List<Counter>)FinderCacheUtil.getResult(finderPath,
481                                    finderArgs, this);
482    
483                    if (list == null) {
484                            StringBundler query = null;
485                            String sql = null;
486    
487                            if (orderByComparator != null) {
488                                    query = new StringBundler(2 +
489                                                    (orderByComparator.getOrderByFields().length * 3));
490    
491                                    query.append(_SQL_SELECT_COUNTER);
492    
493                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
494                                            orderByComparator);
495    
496                                    sql = query.toString();
497                            }
498                            else {
499                                    sql = _SQL_SELECT_COUNTER;
500    
501                                    if (pagination) {
502                                            sql = sql.concat(CounterModelImpl.ORDER_BY_JPQL);
503                                    }
504                            }
505    
506                            Session session = null;
507    
508                            try {
509                                    session = openSession();
510    
511                                    Query q = session.createQuery(sql);
512    
513                                    if (!pagination) {
514                                            list = (List<Counter>)QueryUtil.list(q, getDialect(),
515                                                            start, end, false);
516    
517                                            Collections.sort(list);
518    
519                                            list = new UnmodifiableList<Counter>(list);
520                                    }
521                                    else {
522                                            list = (List<Counter>)QueryUtil.list(q, getDialect(),
523                                                            start, end);
524                                    }
525    
526                                    cacheResult(list);
527    
528                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
529                            }
530                            catch (Exception e) {
531                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
532    
533                                    throw processException(e);
534                            }
535                            finally {
536                                    closeSession(session);
537                            }
538                    }
539    
540                    return list;
541            }
542    
543            /**
544             * Removes all the counters from the database.
545             *
546             * @throws SystemException if a system exception occurred
547             */
548            @Override
549            public void removeAll() throws SystemException {
550                    for (Counter counter : findAll()) {
551                            remove(counter);
552                    }
553            }
554    
555            /**
556             * Returns the number of counters.
557             *
558             * @return the number of counters
559             * @throws SystemException if a system exception occurred
560             */
561            @Override
562            public int countAll() throws SystemException {
563                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
564                                    FINDER_ARGS_EMPTY, this);
565    
566                    if (count == null) {
567                            Session session = null;
568    
569                            try {
570                                    session = openSession();
571    
572                                    Query q = session.createQuery(_SQL_COUNT_COUNTER);
573    
574                                    count = (Long)q.uniqueResult();
575    
576                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
577                                            FINDER_ARGS_EMPTY, count);
578                            }
579                            catch (Exception e) {
580                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
581                                            FINDER_ARGS_EMPTY);
582    
583                                    throw processException(e);
584                            }
585                            finally {
586                                    closeSession(session);
587                            }
588                    }
589    
590                    return count.intValue();
591            }
592    
593            /**
594             * Initializes the counter persistence.
595             */
596            public void afterPropertiesSet() {
597                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
598                                            com.liferay.portal.util.PropsUtil.get(
599                                                    "value.object.listener.com.liferay.counter.model.Counter")));
600    
601                    if (listenerClassNames.length > 0) {
602                            try {
603                                    List<ModelListener<Counter>> listenersList = new ArrayList<ModelListener<Counter>>();
604    
605                                    for (String listenerClassName : listenerClassNames) {
606                                            listenersList.add((ModelListener<Counter>)InstanceFactory.newInstance(
607                                                            getClassLoader(), listenerClassName));
608                                    }
609    
610                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
611                            }
612                            catch (Exception e) {
613                                    _log.error(e);
614                            }
615                    }
616            }
617    
618            public void destroy() {
619                    EntityCacheUtil.removeCache(CounterImpl.class.getName());
620                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
621                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
622                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
623            }
624    
625            private static final String _SQL_SELECT_COUNTER = "SELECT counter FROM Counter counter";
626            private static final String _SQL_COUNT_COUNTER = "SELECT COUNT(counter) FROM Counter counter";
627            private static final String _ORDER_BY_ENTITY_ALIAS = "counter.";
628            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Counter exists with the primary key ";
629            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
630            private static Log _log = LogFactoryUtil.getLog(CounterPersistenceImpl.class);
631            private static Counter _nullCounter = new CounterImpl() {
632                            @Override
633                            public Object clone() {
634                                    return this;
635                            }
636    
637                            @Override
638                            public CacheModel<Counter> toCacheModel() {
639                                    return _nullCounterCacheModel;
640                            }
641                    };
642    
643            private static CacheModel<Counter> _nullCounterCacheModel = new CacheModel<Counter>() {
644                            @Override
645                            public Counter toEntityModel() {
646                                    return _nullCounter;
647                            }
648                    };
649    }