001    /**
002     * Copyright (c) 2000-2012 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.portlet.asset.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.UserPersistence;
039    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
040    
041    import com.liferay.portlet.asset.NoSuchTagStatsException;
042    import com.liferay.portlet.asset.model.AssetTagStats;
043    import com.liferay.portlet.asset.model.impl.AssetTagStatsImpl;
044    import com.liferay.portlet.asset.model.impl.AssetTagStatsModelImpl;
045    
046    import java.io.Serializable;
047    
048    import java.util.ArrayList;
049    import java.util.Collections;
050    import java.util.List;
051    
052    /**
053     * The persistence implementation for the asset tag stats service.
054     *
055     * <p>
056     * Caching information and settings can be found in <code>portal.properties</code>
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see AssetTagStatsPersistence
061     * @see AssetTagStatsUtil
062     * @generated
063     */
064    public class AssetTagStatsPersistenceImpl extends BasePersistenceImpl<AssetTagStats>
065            implements AssetTagStatsPersistence {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. Always use {@link AssetTagStatsUtil} to access the asset tag stats persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
070             */
071            public static final String FINDER_CLASS_NAME_ENTITY = AssetTagStatsImpl.class.getName();
072            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073                    ".List1";
074            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List2";
076            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TAGID = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
077                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED,
078                            AssetTagStatsImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
079                            "findByTagId",
080                            new String[] {
081                                    Long.class.getName(),
082                                    
083                            "java.lang.Integer", "java.lang.Integer",
084                                    "com.liferay.portal.kernel.util.OrderByComparator"
085                            });
086            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TAGID = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
087                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED,
088                            AssetTagStatsImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
089                            "findByTagId", new String[] { Long.class.getName() },
090                            AssetTagStatsModelImpl.TAGID_COLUMN_BITMASK);
091            public static final FinderPath FINDER_PATH_COUNT_BY_TAGID = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
092                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByTagId",
094                            new String[] { Long.class.getName() });
095            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID =
096                    new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
097                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED,
098                            AssetTagStatsImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
099                            "findByClassNameId",
100                            new String[] {
101                                    Long.class.getName(),
102                                    
103                            "java.lang.Integer", "java.lang.Integer",
104                                    "com.liferay.portal.kernel.util.OrderByComparator"
105                            });
106            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID =
107                    new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
108                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED,
109                            AssetTagStatsImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
110                            "findByClassNameId", new String[] { Long.class.getName() },
111                            AssetTagStatsModelImpl.CLASSNAMEID_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_CLASSNAMEID = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
113                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassNameId",
115                            new String[] { Long.class.getName() });
116            public static final FinderPath FINDER_PATH_FETCH_BY_T_C = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
117                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED,
118                            AssetTagStatsImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByT_C",
119                            new String[] { Long.class.getName(), Long.class.getName() },
120                            AssetTagStatsModelImpl.TAGID_COLUMN_BITMASK |
121                            AssetTagStatsModelImpl.CLASSNAMEID_COLUMN_BITMASK);
122            public static final FinderPath FINDER_PATH_COUNT_BY_T_C = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
123                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED, Long.class,
124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_C",
125                            new String[] { Long.class.getName(), Long.class.getName() });
126            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
127                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED,
128                            AssetTagStatsImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
129                            "findAll", new String[0]);
130            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
131                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED,
132                            AssetTagStatsImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
133                            "findAll", new String[0]);
134            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
135                            AssetTagStatsModelImpl.FINDER_CACHE_ENABLED, Long.class,
136                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
137    
138            /**
139             * Caches the asset tag stats in the entity cache if it is enabled.
140             *
141             * @param assetTagStats the asset tag stats
142             */
143            public void cacheResult(AssetTagStats assetTagStats) {
144                    EntityCacheUtil.putResult(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
145                            AssetTagStatsImpl.class, assetTagStats.getPrimaryKey(),
146                            assetTagStats);
147    
148                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C,
149                            new Object[] {
150                                    Long.valueOf(assetTagStats.getTagId()),
151                                    Long.valueOf(assetTagStats.getClassNameId())
152                            }, assetTagStats);
153    
154                    assetTagStats.resetOriginalValues();
155            }
156    
157            /**
158             * Caches the asset tag statses in the entity cache if it is enabled.
159             *
160             * @param assetTagStatses the asset tag statses
161             */
162            public void cacheResult(List<AssetTagStats> assetTagStatses) {
163                    for (AssetTagStats assetTagStats : assetTagStatses) {
164                            if (EntityCacheUtil.getResult(
165                                                    AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
166                                                    AssetTagStatsImpl.class, assetTagStats.getPrimaryKey()) == null) {
167                                    cacheResult(assetTagStats);
168                            }
169                            else {
170                                    assetTagStats.resetOriginalValues();
171                            }
172                    }
173            }
174    
175            /**
176             * Clears the cache for all asset tag statses.
177             *
178             * <p>
179             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
180             * </p>
181             */
182            @Override
183            public void clearCache() {
184                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
185                            CacheRegistryUtil.clear(AssetTagStatsImpl.class.getName());
186                    }
187    
188                    EntityCacheUtil.clearCache(AssetTagStatsImpl.class.getName());
189    
190                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
191                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
192                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
193            }
194    
195            /**
196             * Clears the cache for the asset tag stats.
197             *
198             * <p>
199             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
200             * </p>
201             */
202            @Override
203            public void clearCache(AssetTagStats assetTagStats) {
204                    EntityCacheUtil.removeResult(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
205                            AssetTagStatsImpl.class, assetTagStats.getPrimaryKey());
206    
207                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
208                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
209    
210                    clearUniqueFindersCache(assetTagStats);
211            }
212    
213            @Override
214            public void clearCache(List<AssetTagStats> assetTagStatses) {
215                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
216                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
217    
218                    for (AssetTagStats assetTagStats : assetTagStatses) {
219                            EntityCacheUtil.removeResult(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
220                                    AssetTagStatsImpl.class, assetTagStats.getPrimaryKey());
221    
222                            clearUniqueFindersCache(assetTagStats);
223                    }
224            }
225    
226            protected void clearUniqueFindersCache(AssetTagStats assetTagStats) {
227                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_C,
228                            new Object[] {
229                                    Long.valueOf(assetTagStats.getTagId()),
230                                    Long.valueOf(assetTagStats.getClassNameId())
231                            });
232            }
233    
234            /**
235             * Creates a new asset tag stats with the primary key. Does not add the asset tag stats to the database.
236             *
237             * @param tagStatsId the primary key for the new asset tag stats
238             * @return the new asset tag stats
239             */
240            public AssetTagStats create(long tagStatsId) {
241                    AssetTagStats assetTagStats = new AssetTagStatsImpl();
242    
243                    assetTagStats.setNew(true);
244                    assetTagStats.setPrimaryKey(tagStatsId);
245    
246                    return assetTagStats;
247            }
248    
249            /**
250             * Removes the asset tag stats with the primary key from the database. Also notifies the appropriate model listeners.
251             *
252             * @param tagStatsId the primary key of the asset tag stats
253             * @return the asset tag stats that was removed
254             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a asset tag stats with the primary key could not be found
255             * @throws SystemException if a system exception occurred
256             */
257            public AssetTagStats remove(long tagStatsId)
258                    throws NoSuchTagStatsException, SystemException {
259                    return remove(Long.valueOf(tagStatsId));
260            }
261    
262            /**
263             * Removes the asset tag stats with the primary key from the database. Also notifies the appropriate model listeners.
264             *
265             * @param primaryKey the primary key of the asset tag stats
266             * @return the asset tag stats that was removed
267             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a asset tag stats with the primary key could not be found
268             * @throws SystemException if a system exception occurred
269             */
270            @Override
271            public AssetTagStats remove(Serializable primaryKey)
272                    throws NoSuchTagStatsException, SystemException {
273                    Session session = null;
274    
275                    try {
276                            session = openSession();
277    
278                            AssetTagStats assetTagStats = (AssetTagStats)session.get(AssetTagStatsImpl.class,
279                                            primaryKey);
280    
281                            if (assetTagStats == null) {
282                                    if (_log.isWarnEnabled()) {
283                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
284                                    }
285    
286                                    throw new NoSuchTagStatsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
287                                            primaryKey);
288                            }
289    
290                            return remove(assetTagStats);
291                    }
292                    catch (NoSuchTagStatsException nsee) {
293                            throw nsee;
294                    }
295                    catch (Exception e) {
296                            throw processException(e);
297                    }
298                    finally {
299                            closeSession(session);
300                    }
301            }
302    
303            @Override
304            protected AssetTagStats removeImpl(AssetTagStats assetTagStats)
305                    throws SystemException {
306                    assetTagStats = toUnwrappedModel(assetTagStats);
307    
308                    Session session = null;
309    
310                    try {
311                            session = openSession();
312    
313                            if (assetTagStats.isCachedModel()) {
314                                    assetTagStats = (AssetTagStats)session.get(AssetTagStatsImpl.class,
315                                                    assetTagStats.getPrimaryKeyObj());
316                            }
317    
318                            session.delete(assetTagStats);
319                    }
320                    catch (Exception e) {
321                            throw processException(e);
322                    }
323                    finally {
324                            closeSession(session);
325                    }
326    
327                    clearCache(assetTagStats);
328    
329                    return assetTagStats;
330            }
331    
332            @Override
333            public AssetTagStats updateImpl(
334                    com.liferay.portlet.asset.model.AssetTagStats assetTagStats)
335                    throws SystemException {
336                    assetTagStats = toUnwrappedModel(assetTagStats);
337    
338                    boolean isNew = assetTagStats.isNew();
339    
340                    AssetTagStatsModelImpl assetTagStatsModelImpl = (AssetTagStatsModelImpl)assetTagStats;
341    
342                    Session session = null;
343    
344                    try {
345                            session = openSession();
346    
347                            if (assetTagStats.isNew()) {
348                                    session.save(assetTagStats);
349    
350                                    assetTagStats.setNew(false);
351                            }
352                            else {
353                                    session.merge(assetTagStats);
354                            }
355                    }
356                    catch (Exception e) {
357                            throw processException(e);
358                    }
359                    finally {
360                            closeSession(session);
361                    }
362    
363                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
364    
365                    if (isNew || !AssetTagStatsModelImpl.COLUMN_BITMASK_ENABLED) {
366                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
367                    }
368    
369                    else {
370                            if ((assetTagStatsModelImpl.getColumnBitmask() &
371                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TAGID.getColumnBitmask()) != 0) {
372                                    Object[] args = new Object[] {
373                                                    Long.valueOf(assetTagStatsModelImpl.getOriginalTagId())
374                                            };
375    
376                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TAGID, args);
377                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TAGID,
378                                            args);
379    
380                                    args = new Object[] {
381                                                    Long.valueOf(assetTagStatsModelImpl.getTagId())
382                                            };
383    
384                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TAGID, args);
385                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TAGID,
386                                            args);
387                            }
388    
389                            if ((assetTagStatsModelImpl.getColumnBitmask() &
390                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID.getColumnBitmask()) != 0) {
391                                    Object[] args = new Object[] {
392                                                    Long.valueOf(assetTagStatsModelImpl.getOriginalClassNameId())
393                                            };
394    
395                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
396                                            args);
397                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
398                                            args);
399    
400                                    args = new Object[] {
401                                                    Long.valueOf(assetTagStatsModelImpl.getClassNameId())
402                                            };
403    
404                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
405                                            args);
406                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
407                                            args);
408                            }
409                    }
410    
411                    EntityCacheUtil.putResult(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
412                            AssetTagStatsImpl.class, assetTagStats.getPrimaryKey(),
413                            assetTagStats);
414    
415                    if (isNew) {
416                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C,
417                                    new Object[] {
418                                            Long.valueOf(assetTagStats.getTagId()),
419                                            Long.valueOf(assetTagStats.getClassNameId())
420                                    }, assetTagStats);
421                    }
422                    else {
423                            if ((assetTagStatsModelImpl.getColumnBitmask() &
424                                            FINDER_PATH_FETCH_BY_T_C.getColumnBitmask()) != 0) {
425                                    Object[] args = new Object[] {
426                                                    Long.valueOf(assetTagStatsModelImpl.getOriginalTagId()),
427                                                    Long.valueOf(assetTagStatsModelImpl.getOriginalClassNameId())
428                                            };
429    
430                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_C, args);
431    
432                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_C, args);
433    
434                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C,
435                                            new Object[] {
436                                                    Long.valueOf(assetTagStats.getTagId()),
437                                                    Long.valueOf(assetTagStats.getClassNameId())
438                                            }, assetTagStats);
439                            }
440                    }
441    
442                    return assetTagStats;
443            }
444    
445            protected AssetTagStats toUnwrappedModel(AssetTagStats assetTagStats) {
446                    if (assetTagStats instanceof AssetTagStatsImpl) {
447                            return assetTagStats;
448                    }
449    
450                    AssetTagStatsImpl assetTagStatsImpl = new AssetTagStatsImpl();
451    
452                    assetTagStatsImpl.setNew(assetTagStats.isNew());
453                    assetTagStatsImpl.setPrimaryKey(assetTagStats.getPrimaryKey());
454    
455                    assetTagStatsImpl.setTagStatsId(assetTagStats.getTagStatsId());
456                    assetTagStatsImpl.setTagId(assetTagStats.getTagId());
457                    assetTagStatsImpl.setClassNameId(assetTagStats.getClassNameId());
458                    assetTagStatsImpl.setAssetCount(assetTagStats.getAssetCount());
459    
460                    return assetTagStatsImpl;
461            }
462    
463            /**
464             * Returns the asset tag stats with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
465             *
466             * @param primaryKey the primary key of the asset tag stats
467             * @return the asset tag stats
468             * @throws com.liferay.portal.NoSuchModelException if a asset tag stats with the primary key could not be found
469             * @throws SystemException if a system exception occurred
470             */
471            @Override
472            public AssetTagStats findByPrimaryKey(Serializable primaryKey)
473                    throws NoSuchModelException, SystemException {
474                    return findByPrimaryKey(((Long)primaryKey).longValue());
475            }
476    
477            /**
478             * Returns the asset tag stats with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchTagStatsException} if it could not be found.
479             *
480             * @param tagStatsId the primary key of the asset tag stats
481             * @return the asset tag stats
482             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a asset tag stats with the primary key could not be found
483             * @throws SystemException if a system exception occurred
484             */
485            public AssetTagStats findByPrimaryKey(long tagStatsId)
486                    throws NoSuchTagStatsException, SystemException {
487                    AssetTagStats assetTagStats = fetchByPrimaryKey(tagStatsId);
488    
489                    if (assetTagStats == null) {
490                            if (_log.isWarnEnabled()) {
491                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + tagStatsId);
492                            }
493    
494                            throw new NoSuchTagStatsException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
495                                    tagStatsId);
496                    }
497    
498                    return assetTagStats;
499            }
500    
501            /**
502             * Returns the asset tag stats with the primary key or returns <code>null</code> if it could not be found.
503             *
504             * @param primaryKey the primary key of the asset tag stats
505             * @return the asset tag stats, or <code>null</code> if a asset tag stats with the primary key could not be found
506             * @throws SystemException if a system exception occurred
507             */
508            @Override
509            public AssetTagStats fetchByPrimaryKey(Serializable primaryKey)
510                    throws SystemException {
511                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
512            }
513    
514            /**
515             * Returns the asset tag stats with the primary key or returns <code>null</code> if it could not be found.
516             *
517             * @param tagStatsId the primary key of the asset tag stats
518             * @return the asset tag stats, or <code>null</code> if a asset tag stats with the primary key could not be found
519             * @throws SystemException if a system exception occurred
520             */
521            public AssetTagStats fetchByPrimaryKey(long tagStatsId)
522                    throws SystemException {
523                    AssetTagStats assetTagStats = (AssetTagStats)EntityCacheUtil.getResult(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
524                                    AssetTagStatsImpl.class, tagStatsId);
525    
526                    if (assetTagStats == _nullAssetTagStats) {
527                            return null;
528                    }
529    
530                    if (assetTagStats == null) {
531                            Session session = null;
532    
533                            boolean hasException = false;
534    
535                            try {
536                                    session = openSession();
537    
538                                    assetTagStats = (AssetTagStats)session.get(AssetTagStatsImpl.class,
539                                                    Long.valueOf(tagStatsId));
540                            }
541                            catch (Exception e) {
542                                    hasException = true;
543    
544                                    throw processException(e);
545                            }
546                            finally {
547                                    if (assetTagStats != null) {
548                                            cacheResult(assetTagStats);
549                                    }
550                                    else if (!hasException) {
551                                            EntityCacheUtil.putResult(AssetTagStatsModelImpl.ENTITY_CACHE_ENABLED,
552                                                    AssetTagStatsImpl.class, tagStatsId, _nullAssetTagStats);
553                                    }
554    
555                                    closeSession(session);
556                            }
557                    }
558    
559                    return assetTagStats;
560            }
561    
562            /**
563             * Returns all the asset tag statses where tagId = &#63;.
564             *
565             * @param tagId the tag ID
566             * @return the matching asset tag statses
567             * @throws SystemException if a system exception occurred
568             */
569            public List<AssetTagStats> findByTagId(long tagId)
570                    throws SystemException {
571                    return findByTagId(tagId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
572            }
573    
574            /**
575             * Returns a range of all the asset tag statses where tagId = &#63;.
576             *
577             * <p>
578             * 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.
579             * </p>
580             *
581             * @param tagId the tag ID
582             * @param start the lower bound of the range of asset tag statses
583             * @param end the upper bound of the range of asset tag statses (not inclusive)
584             * @return the range of matching asset tag statses
585             * @throws SystemException if a system exception occurred
586             */
587            public List<AssetTagStats> findByTagId(long tagId, int start, int end)
588                    throws SystemException {
589                    return findByTagId(tagId, start, end, null);
590            }
591    
592            /**
593             * Returns an ordered range of all the asset tag statses where tagId = &#63;.
594             *
595             * <p>
596             * 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.
597             * </p>
598             *
599             * @param tagId the tag ID
600             * @param start the lower bound of the range of asset tag statses
601             * @param end the upper bound of the range of asset tag statses (not inclusive)
602             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
603             * @return the ordered range of matching asset tag statses
604             * @throws SystemException if a system exception occurred
605             */
606            public List<AssetTagStats> findByTagId(long tagId, int start, int end,
607                    OrderByComparator orderByComparator) throws SystemException {
608                    FinderPath finderPath = null;
609                    Object[] finderArgs = null;
610    
611                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
612                                    (orderByComparator == null)) {
613                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TAGID;
614                            finderArgs = new Object[] { tagId };
615                    }
616                    else {
617                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TAGID;
618                            finderArgs = new Object[] { tagId, start, end, orderByComparator };
619                    }
620    
621                    List<AssetTagStats> list = (List<AssetTagStats>)FinderCacheUtil.getResult(finderPath,
622                                    finderArgs, this);
623    
624                    if ((list != null) && !list.isEmpty()) {
625                            for (AssetTagStats assetTagStats : list) {
626                                    if ((tagId != assetTagStats.getTagId())) {
627                                            list = null;
628    
629                                            break;
630                                    }
631                            }
632                    }
633    
634                    if (list == null) {
635                            StringBundler query = null;
636    
637                            if (orderByComparator != null) {
638                                    query = new StringBundler(3 +
639                                                    (orderByComparator.getOrderByFields().length * 3));
640                            }
641                            else {
642                                    query = new StringBundler(3);
643                            }
644    
645                            query.append(_SQL_SELECT_ASSETTAGSTATS_WHERE);
646    
647                            query.append(_FINDER_COLUMN_TAGID_TAGID_2);
648    
649                            if (orderByComparator != null) {
650                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
651                                            orderByComparator);
652                            }
653    
654                            else {
655                                    query.append(AssetTagStatsModelImpl.ORDER_BY_JPQL);
656                            }
657    
658                            String sql = query.toString();
659    
660                            Session session = null;
661    
662                            try {
663                                    session = openSession();
664    
665                                    Query q = session.createQuery(sql);
666    
667                                    QueryPos qPos = QueryPos.getInstance(q);
668    
669                                    qPos.add(tagId);
670    
671                                    list = (List<AssetTagStats>)QueryUtil.list(q, getDialect(),
672                                                    start, end);
673                            }
674                            catch (Exception e) {
675                                    throw processException(e);
676                            }
677                            finally {
678                                    if (list == null) {
679                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
680                                    }
681                                    else {
682                                            cacheResult(list);
683    
684                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
685                                    }
686    
687                                    closeSession(session);
688                            }
689                    }
690    
691                    return list;
692            }
693    
694            /**
695             * Returns the first asset tag stats in the ordered set where tagId = &#63;.
696             *
697             * @param tagId the tag ID
698             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
699             * @return the first matching asset tag stats
700             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a matching asset tag stats could not be found
701             * @throws SystemException if a system exception occurred
702             */
703            public AssetTagStats findByTagId_First(long tagId,
704                    OrderByComparator orderByComparator)
705                    throws NoSuchTagStatsException, SystemException {
706                    AssetTagStats assetTagStats = fetchByTagId_First(tagId,
707                                    orderByComparator);
708    
709                    if (assetTagStats != null) {
710                            return assetTagStats;
711                    }
712    
713                    StringBundler msg = new StringBundler(4);
714    
715                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
716    
717                    msg.append("tagId=");
718                    msg.append(tagId);
719    
720                    msg.append(StringPool.CLOSE_CURLY_BRACE);
721    
722                    throw new NoSuchTagStatsException(msg.toString());
723            }
724    
725            /**
726             * Returns the first asset tag stats in the ordered set where tagId = &#63;.
727             *
728             * @param tagId the tag ID
729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
730             * @return the first matching asset tag stats, or <code>null</code> if a matching asset tag stats could not be found
731             * @throws SystemException if a system exception occurred
732             */
733            public AssetTagStats fetchByTagId_First(long tagId,
734                    OrderByComparator orderByComparator) throws SystemException {
735                    List<AssetTagStats> list = findByTagId(tagId, 0, 1, orderByComparator);
736    
737                    if (!list.isEmpty()) {
738                            return list.get(0);
739                    }
740    
741                    return null;
742            }
743    
744            /**
745             * Returns the last asset tag stats in the ordered set where tagId = &#63;.
746             *
747             * @param tagId the tag ID
748             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
749             * @return the last matching asset tag stats
750             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a matching asset tag stats could not be found
751             * @throws SystemException if a system exception occurred
752             */
753            public AssetTagStats findByTagId_Last(long tagId,
754                    OrderByComparator orderByComparator)
755                    throws NoSuchTagStatsException, SystemException {
756                    AssetTagStats assetTagStats = fetchByTagId_Last(tagId, orderByComparator);
757    
758                    if (assetTagStats != null) {
759                            return assetTagStats;
760                    }
761    
762                    StringBundler msg = new StringBundler(4);
763    
764                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
765    
766                    msg.append("tagId=");
767                    msg.append(tagId);
768    
769                    msg.append(StringPool.CLOSE_CURLY_BRACE);
770    
771                    throw new NoSuchTagStatsException(msg.toString());
772            }
773    
774            /**
775             * Returns the last asset tag stats in the ordered set where tagId = &#63;.
776             *
777             * @param tagId the tag ID
778             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
779             * @return the last matching asset tag stats, or <code>null</code> if a matching asset tag stats could not be found
780             * @throws SystemException if a system exception occurred
781             */
782            public AssetTagStats fetchByTagId_Last(long tagId,
783                    OrderByComparator orderByComparator) throws SystemException {
784                    int count = countByTagId(tagId);
785    
786                    List<AssetTagStats> list = findByTagId(tagId, count - 1, count,
787                                    orderByComparator);
788    
789                    if (!list.isEmpty()) {
790                            return list.get(0);
791                    }
792    
793                    return null;
794            }
795    
796            /**
797             * Returns the asset tag statses before and after the current asset tag stats in the ordered set where tagId = &#63;.
798             *
799             * @param tagStatsId the primary key of the current asset tag stats
800             * @param tagId the tag ID
801             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
802             * @return the previous, current, and next asset tag stats
803             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a asset tag stats with the primary key could not be found
804             * @throws SystemException if a system exception occurred
805             */
806            public AssetTagStats[] findByTagId_PrevAndNext(long tagStatsId, long tagId,
807                    OrderByComparator orderByComparator)
808                    throws NoSuchTagStatsException, SystemException {
809                    AssetTagStats assetTagStats = findByPrimaryKey(tagStatsId);
810    
811                    Session session = null;
812    
813                    try {
814                            session = openSession();
815    
816                            AssetTagStats[] array = new AssetTagStatsImpl[3];
817    
818                            array[0] = getByTagId_PrevAndNext(session, assetTagStats, tagId,
819                                            orderByComparator, true);
820    
821                            array[1] = assetTagStats;
822    
823                            array[2] = getByTagId_PrevAndNext(session, assetTagStats, tagId,
824                                            orderByComparator, false);
825    
826                            return array;
827                    }
828                    catch (Exception e) {
829                            throw processException(e);
830                    }
831                    finally {
832                            closeSession(session);
833                    }
834            }
835    
836            protected AssetTagStats getByTagId_PrevAndNext(Session session,
837                    AssetTagStats assetTagStats, long tagId,
838                    OrderByComparator orderByComparator, boolean previous) {
839                    StringBundler query = null;
840    
841                    if (orderByComparator != null) {
842                            query = new StringBundler(6 +
843                                            (orderByComparator.getOrderByFields().length * 6));
844                    }
845                    else {
846                            query = new StringBundler(3);
847                    }
848    
849                    query.append(_SQL_SELECT_ASSETTAGSTATS_WHERE);
850    
851                    query.append(_FINDER_COLUMN_TAGID_TAGID_2);
852    
853                    if (orderByComparator != null) {
854                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
855    
856                            if (orderByConditionFields.length > 0) {
857                                    query.append(WHERE_AND);
858                            }
859    
860                            for (int i = 0; i < orderByConditionFields.length; i++) {
861                                    query.append(_ORDER_BY_ENTITY_ALIAS);
862                                    query.append(orderByConditionFields[i]);
863    
864                                    if ((i + 1) < orderByConditionFields.length) {
865                                            if (orderByComparator.isAscending() ^ previous) {
866                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
867                                            }
868                                            else {
869                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
870                                            }
871                                    }
872                                    else {
873                                            if (orderByComparator.isAscending() ^ previous) {
874                                                    query.append(WHERE_GREATER_THAN);
875                                            }
876                                            else {
877                                                    query.append(WHERE_LESSER_THAN);
878                                            }
879                                    }
880                            }
881    
882                            query.append(ORDER_BY_CLAUSE);
883    
884                            String[] orderByFields = orderByComparator.getOrderByFields();
885    
886                            for (int i = 0; i < orderByFields.length; i++) {
887                                    query.append(_ORDER_BY_ENTITY_ALIAS);
888                                    query.append(orderByFields[i]);
889    
890                                    if ((i + 1) < orderByFields.length) {
891                                            if (orderByComparator.isAscending() ^ previous) {
892                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
893                                            }
894                                            else {
895                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
896                                            }
897                                    }
898                                    else {
899                                            if (orderByComparator.isAscending() ^ previous) {
900                                                    query.append(ORDER_BY_ASC);
901                                            }
902                                            else {
903                                                    query.append(ORDER_BY_DESC);
904                                            }
905                                    }
906                            }
907                    }
908    
909                    else {
910                            query.append(AssetTagStatsModelImpl.ORDER_BY_JPQL);
911                    }
912    
913                    String sql = query.toString();
914    
915                    Query q = session.createQuery(sql);
916    
917                    q.setFirstResult(0);
918                    q.setMaxResults(2);
919    
920                    QueryPos qPos = QueryPos.getInstance(q);
921    
922                    qPos.add(tagId);
923    
924                    if (orderByComparator != null) {
925                            Object[] values = orderByComparator.getOrderByConditionValues(assetTagStats);
926    
927                            for (Object value : values) {
928                                    qPos.add(value);
929                            }
930                    }
931    
932                    List<AssetTagStats> list = q.list();
933    
934                    if (list.size() == 2) {
935                            return list.get(1);
936                    }
937                    else {
938                            return null;
939                    }
940            }
941    
942            /**
943             * Returns all the asset tag statses where classNameId = &#63;.
944             *
945             * @param classNameId the class name ID
946             * @return the matching asset tag statses
947             * @throws SystemException if a system exception occurred
948             */
949            public List<AssetTagStats> findByClassNameId(long classNameId)
950                    throws SystemException {
951                    return findByClassNameId(classNameId, QueryUtil.ALL_POS,
952                            QueryUtil.ALL_POS, null);
953            }
954    
955            /**
956             * Returns a range of all the asset tag statses where classNameId = &#63;.
957             *
958             * <p>
959             * 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.
960             * </p>
961             *
962             * @param classNameId the class name ID
963             * @param start the lower bound of the range of asset tag statses
964             * @param end the upper bound of the range of asset tag statses (not inclusive)
965             * @return the range of matching asset tag statses
966             * @throws SystemException if a system exception occurred
967             */
968            public List<AssetTagStats> findByClassNameId(long classNameId, int start,
969                    int end) throws SystemException {
970                    return findByClassNameId(classNameId, start, end, null);
971            }
972    
973            /**
974             * Returns an ordered range of all the asset tag statses where classNameId = &#63;.
975             *
976             * <p>
977             * 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.
978             * </p>
979             *
980             * @param classNameId the class name ID
981             * @param start the lower bound of the range of asset tag statses
982             * @param end the upper bound of the range of asset tag statses (not inclusive)
983             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
984             * @return the ordered range of matching asset tag statses
985             * @throws SystemException if a system exception occurred
986             */
987            public List<AssetTagStats> findByClassNameId(long classNameId, int start,
988                    int end, OrderByComparator orderByComparator) throws SystemException {
989                    FinderPath finderPath = null;
990                    Object[] finderArgs = null;
991    
992                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
993                                    (orderByComparator == null)) {
994                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID;
995                            finderArgs = new Object[] { classNameId };
996                    }
997                    else {
998                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID;
999                            finderArgs = new Object[] { classNameId, start, end, orderByComparator };
1000                    }
1001    
1002                    List<AssetTagStats> list = (List<AssetTagStats>)FinderCacheUtil.getResult(finderPath,
1003                                    finderArgs, this);
1004    
1005                    if ((list != null) && !list.isEmpty()) {
1006                            for (AssetTagStats assetTagStats : list) {
1007                                    if ((classNameId != assetTagStats.getClassNameId())) {
1008                                            list = null;
1009    
1010                                            break;
1011                                    }
1012                            }
1013                    }
1014    
1015                    if (list == null) {
1016                            StringBundler query = null;
1017    
1018                            if (orderByComparator != null) {
1019                                    query = new StringBundler(3 +
1020                                                    (orderByComparator.getOrderByFields().length * 3));
1021                            }
1022                            else {
1023                                    query = new StringBundler(3);
1024                            }
1025    
1026                            query.append(_SQL_SELECT_ASSETTAGSTATS_WHERE);
1027    
1028                            query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
1029    
1030                            if (orderByComparator != null) {
1031                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1032                                            orderByComparator);
1033                            }
1034    
1035                            else {
1036                                    query.append(AssetTagStatsModelImpl.ORDER_BY_JPQL);
1037                            }
1038    
1039                            String sql = query.toString();
1040    
1041                            Session session = null;
1042    
1043                            try {
1044                                    session = openSession();
1045    
1046                                    Query q = session.createQuery(sql);
1047    
1048                                    QueryPos qPos = QueryPos.getInstance(q);
1049    
1050                                    qPos.add(classNameId);
1051    
1052                                    list = (List<AssetTagStats>)QueryUtil.list(q, getDialect(),
1053                                                    start, end);
1054                            }
1055                            catch (Exception e) {
1056                                    throw processException(e);
1057                            }
1058                            finally {
1059                                    if (list == null) {
1060                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1061                                    }
1062                                    else {
1063                                            cacheResult(list);
1064    
1065                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1066                                    }
1067    
1068                                    closeSession(session);
1069                            }
1070                    }
1071    
1072                    return list;
1073            }
1074    
1075            /**
1076             * Returns the first asset tag stats in the ordered set where classNameId = &#63;.
1077             *
1078             * @param classNameId the class name ID
1079             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1080             * @return the first matching asset tag stats
1081             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a matching asset tag stats could not be found
1082             * @throws SystemException if a system exception occurred
1083             */
1084            public AssetTagStats findByClassNameId_First(long classNameId,
1085                    OrderByComparator orderByComparator)
1086                    throws NoSuchTagStatsException, SystemException {
1087                    AssetTagStats assetTagStats = fetchByClassNameId_First(classNameId,
1088                                    orderByComparator);
1089    
1090                    if (assetTagStats != null) {
1091                            return assetTagStats;
1092                    }
1093    
1094                    StringBundler msg = new StringBundler(4);
1095    
1096                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1097    
1098                    msg.append("classNameId=");
1099                    msg.append(classNameId);
1100    
1101                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1102    
1103                    throw new NoSuchTagStatsException(msg.toString());
1104            }
1105    
1106            /**
1107             * Returns the first asset tag stats in the ordered set where classNameId = &#63;.
1108             *
1109             * @param classNameId the class name ID
1110             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1111             * @return the first matching asset tag stats, or <code>null</code> if a matching asset tag stats could not be found
1112             * @throws SystemException if a system exception occurred
1113             */
1114            public AssetTagStats fetchByClassNameId_First(long classNameId,
1115                    OrderByComparator orderByComparator) throws SystemException {
1116                    List<AssetTagStats> list = findByClassNameId(classNameId, 0, 1,
1117                                    orderByComparator);
1118    
1119                    if (!list.isEmpty()) {
1120                            return list.get(0);
1121                    }
1122    
1123                    return null;
1124            }
1125    
1126            /**
1127             * Returns the last asset tag stats in the ordered set where classNameId = &#63;.
1128             *
1129             * @param classNameId the class name ID
1130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1131             * @return the last matching asset tag stats
1132             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a matching asset tag stats could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            public AssetTagStats findByClassNameId_Last(long classNameId,
1136                    OrderByComparator orderByComparator)
1137                    throws NoSuchTagStatsException, SystemException {
1138                    AssetTagStats assetTagStats = fetchByClassNameId_Last(classNameId,
1139                                    orderByComparator);
1140    
1141                    if (assetTagStats != null) {
1142                            return assetTagStats;
1143                    }
1144    
1145                    StringBundler msg = new StringBundler(4);
1146    
1147                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1148    
1149                    msg.append("classNameId=");
1150                    msg.append(classNameId);
1151    
1152                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1153    
1154                    throw new NoSuchTagStatsException(msg.toString());
1155            }
1156    
1157            /**
1158             * Returns the last asset tag stats in the ordered set where classNameId = &#63;.
1159             *
1160             * @param classNameId the class name ID
1161             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1162             * @return the last matching asset tag stats, or <code>null</code> if a matching asset tag stats could not be found
1163             * @throws SystemException if a system exception occurred
1164             */
1165            public AssetTagStats fetchByClassNameId_Last(long classNameId,
1166                    OrderByComparator orderByComparator) throws SystemException {
1167                    int count = countByClassNameId(classNameId);
1168    
1169                    List<AssetTagStats> list = findByClassNameId(classNameId, count - 1,
1170                                    count, orderByComparator);
1171    
1172                    if (!list.isEmpty()) {
1173                            return list.get(0);
1174                    }
1175    
1176                    return null;
1177            }
1178    
1179            /**
1180             * Returns the asset tag statses before and after the current asset tag stats in the ordered set where classNameId = &#63;.
1181             *
1182             * @param tagStatsId the primary key of the current asset tag stats
1183             * @param classNameId the class name ID
1184             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1185             * @return the previous, current, and next asset tag stats
1186             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a asset tag stats with the primary key could not be found
1187             * @throws SystemException if a system exception occurred
1188             */
1189            public AssetTagStats[] findByClassNameId_PrevAndNext(long tagStatsId,
1190                    long classNameId, OrderByComparator orderByComparator)
1191                    throws NoSuchTagStatsException, SystemException {
1192                    AssetTagStats assetTagStats = findByPrimaryKey(tagStatsId);
1193    
1194                    Session session = null;
1195    
1196                    try {
1197                            session = openSession();
1198    
1199                            AssetTagStats[] array = new AssetTagStatsImpl[3];
1200    
1201                            array[0] = getByClassNameId_PrevAndNext(session, assetTagStats,
1202                                            classNameId, orderByComparator, true);
1203    
1204                            array[1] = assetTagStats;
1205    
1206                            array[2] = getByClassNameId_PrevAndNext(session, assetTagStats,
1207                                            classNameId, orderByComparator, false);
1208    
1209                            return array;
1210                    }
1211                    catch (Exception e) {
1212                            throw processException(e);
1213                    }
1214                    finally {
1215                            closeSession(session);
1216                    }
1217            }
1218    
1219            protected AssetTagStats getByClassNameId_PrevAndNext(Session session,
1220                    AssetTagStats assetTagStats, long classNameId,
1221                    OrderByComparator orderByComparator, boolean previous) {
1222                    StringBundler query = null;
1223    
1224                    if (orderByComparator != null) {
1225                            query = new StringBundler(6 +
1226                                            (orderByComparator.getOrderByFields().length * 6));
1227                    }
1228                    else {
1229                            query = new StringBundler(3);
1230                    }
1231    
1232                    query.append(_SQL_SELECT_ASSETTAGSTATS_WHERE);
1233    
1234                    query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
1235    
1236                    if (orderByComparator != null) {
1237                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1238    
1239                            if (orderByConditionFields.length > 0) {
1240                                    query.append(WHERE_AND);
1241                            }
1242    
1243                            for (int i = 0; i < orderByConditionFields.length; i++) {
1244                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1245                                    query.append(orderByConditionFields[i]);
1246    
1247                                    if ((i + 1) < orderByConditionFields.length) {
1248                                            if (orderByComparator.isAscending() ^ previous) {
1249                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1250                                            }
1251                                            else {
1252                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1253                                            }
1254                                    }
1255                                    else {
1256                                            if (orderByComparator.isAscending() ^ previous) {
1257                                                    query.append(WHERE_GREATER_THAN);
1258                                            }
1259                                            else {
1260                                                    query.append(WHERE_LESSER_THAN);
1261                                            }
1262                                    }
1263                            }
1264    
1265                            query.append(ORDER_BY_CLAUSE);
1266    
1267                            String[] orderByFields = orderByComparator.getOrderByFields();
1268    
1269                            for (int i = 0; i < orderByFields.length; i++) {
1270                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1271                                    query.append(orderByFields[i]);
1272    
1273                                    if ((i + 1) < orderByFields.length) {
1274                                            if (orderByComparator.isAscending() ^ previous) {
1275                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1276                                            }
1277                                            else {
1278                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1279                                            }
1280                                    }
1281                                    else {
1282                                            if (orderByComparator.isAscending() ^ previous) {
1283                                                    query.append(ORDER_BY_ASC);
1284                                            }
1285                                            else {
1286                                                    query.append(ORDER_BY_DESC);
1287                                            }
1288                                    }
1289                            }
1290                    }
1291    
1292                    else {
1293                            query.append(AssetTagStatsModelImpl.ORDER_BY_JPQL);
1294                    }
1295    
1296                    String sql = query.toString();
1297    
1298                    Query q = session.createQuery(sql);
1299    
1300                    q.setFirstResult(0);
1301                    q.setMaxResults(2);
1302    
1303                    QueryPos qPos = QueryPos.getInstance(q);
1304    
1305                    qPos.add(classNameId);
1306    
1307                    if (orderByComparator != null) {
1308                            Object[] values = orderByComparator.getOrderByConditionValues(assetTagStats);
1309    
1310                            for (Object value : values) {
1311                                    qPos.add(value);
1312                            }
1313                    }
1314    
1315                    List<AssetTagStats> list = q.list();
1316    
1317                    if (list.size() == 2) {
1318                            return list.get(1);
1319                    }
1320                    else {
1321                            return null;
1322                    }
1323            }
1324    
1325            /**
1326             * Returns the asset tag stats where tagId = &#63; and classNameId = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchTagStatsException} if it could not be found.
1327             *
1328             * @param tagId the tag ID
1329             * @param classNameId the class name ID
1330             * @return the matching asset tag stats
1331             * @throws com.liferay.portlet.asset.NoSuchTagStatsException if a matching asset tag stats could not be found
1332             * @throws SystemException if a system exception occurred
1333             */
1334            public AssetTagStats findByT_C(long tagId, long classNameId)
1335                    throws NoSuchTagStatsException, SystemException {
1336                    AssetTagStats assetTagStats = fetchByT_C(tagId, classNameId);
1337    
1338                    if (assetTagStats == null) {
1339                            StringBundler msg = new StringBundler(6);
1340    
1341                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1342    
1343                            msg.append("tagId=");
1344                            msg.append(tagId);
1345    
1346                            msg.append(", classNameId=");
1347                            msg.append(classNameId);
1348    
1349                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1350    
1351                            if (_log.isWarnEnabled()) {
1352                                    _log.warn(msg.toString());
1353                            }
1354    
1355                            throw new NoSuchTagStatsException(msg.toString());
1356                    }
1357    
1358                    return assetTagStats;
1359            }
1360    
1361            /**
1362             * Returns the asset tag stats where tagId = &#63; and classNameId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1363             *
1364             * @param tagId the tag ID
1365             * @param classNameId the class name ID
1366             * @return the matching asset tag stats, or <code>null</code> if a matching asset tag stats could not be found
1367             * @throws SystemException if a system exception occurred
1368             */
1369            public AssetTagStats fetchByT_C(long tagId, long classNameId)
1370                    throws SystemException {
1371                    return fetchByT_C(tagId, classNameId, true);
1372            }
1373    
1374            /**
1375             * Returns the asset tag stats where tagId = &#63; and classNameId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1376             *
1377             * @param tagId the tag ID
1378             * @param classNameId the class name ID
1379             * @param retrieveFromCache whether to use the finder cache
1380             * @return the matching asset tag stats, or <code>null</code> if a matching asset tag stats could not be found
1381             * @throws SystemException if a system exception occurred
1382             */
1383            public AssetTagStats fetchByT_C(long tagId, long classNameId,
1384                    boolean retrieveFromCache) throws SystemException {
1385                    Object[] finderArgs = new Object[] { tagId, classNameId };
1386    
1387                    Object result = null;
1388    
1389                    if (retrieveFromCache) {
1390                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_T_C,
1391                                            finderArgs, this);
1392                    }
1393    
1394                    if (result instanceof AssetTagStats) {
1395                            AssetTagStats assetTagStats = (AssetTagStats)result;
1396    
1397                            if ((tagId != assetTagStats.getTagId()) ||
1398                                            (classNameId != assetTagStats.getClassNameId())) {
1399                                    result = null;
1400                            }
1401                    }
1402    
1403                    if (result == null) {
1404                            StringBundler query = new StringBundler(4);
1405    
1406                            query.append(_SQL_SELECT_ASSETTAGSTATS_WHERE);
1407    
1408                            query.append(_FINDER_COLUMN_T_C_TAGID_2);
1409    
1410                            query.append(_FINDER_COLUMN_T_C_CLASSNAMEID_2);
1411    
1412                            query.append(AssetTagStatsModelImpl.ORDER_BY_JPQL);
1413    
1414                            String sql = query.toString();
1415    
1416                            Session session = null;
1417    
1418                            try {
1419                                    session = openSession();
1420    
1421                                    Query q = session.createQuery(sql);
1422    
1423                                    QueryPos qPos = QueryPos.getInstance(q);
1424    
1425                                    qPos.add(tagId);
1426    
1427                                    qPos.add(classNameId);
1428    
1429                                    List<AssetTagStats> list = q.list();
1430    
1431                                    result = list;
1432    
1433                                    AssetTagStats assetTagStats = null;
1434    
1435                                    if (list.isEmpty()) {
1436                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C,
1437                                                    finderArgs, list);
1438                                    }
1439                                    else {
1440                                            assetTagStats = list.get(0);
1441    
1442                                            cacheResult(assetTagStats);
1443    
1444                                            if ((assetTagStats.getTagId() != tagId) ||
1445                                                            (assetTagStats.getClassNameId() != classNameId)) {
1446                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_T_C,
1447                                                            finderArgs, assetTagStats);
1448                                            }
1449                                    }
1450    
1451                                    return assetTagStats;
1452                            }
1453                            catch (Exception e) {
1454                                    throw processException(e);
1455                            }
1456                            finally {
1457                                    if (result == null) {
1458                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_T_C,
1459                                                    finderArgs);
1460                                    }
1461    
1462                                    closeSession(session);
1463                            }
1464                    }
1465                    else {
1466                            if (result instanceof List<?>) {
1467                                    return null;
1468                            }
1469                            else {
1470                                    return (AssetTagStats)result;
1471                            }
1472                    }
1473            }
1474    
1475            /**
1476             * Returns all the asset tag statses.
1477             *
1478             * @return the asset tag statses
1479             * @throws SystemException if a system exception occurred
1480             */
1481            public List<AssetTagStats> findAll() throws SystemException {
1482                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1483            }
1484    
1485            /**
1486             * Returns a range of all the asset tag statses.
1487             *
1488             * <p>
1489             * 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.
1490             * </p>
1491             *
1492             * @param start the lower bound of the range of asset tag statses
1493             * @param end the upper bound of the range of asset tag statses (not inclusive)
1494             * @return the range of asset tag statses
1495             * @throws SystemException if a system exception occurred
1496             */
1497            public List<AssetTagStats> findAll(int start, int end)
1498                    throws SystemException {
1499                    return findAll(start, end, null);
1500            }
1501    
1502            /**
1503             * Returns an ordered range of all the asset tag statses.
1504             *
1505             * <p>
1506             * 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.
1507             * </p>
1508             *
1509             * @param start the lower bound of the range of asset tag statses
1510             * @param end the upper bound of the range of asset tag statses (not inclusive)
1511             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1512             * @return the ordered range of asset tag statses
1513             * @throws SystemException if a system exception occurred
1514             */
1515            public List<AssetTagStats> findAll(int start, int end,
1516                    OrderByComparator orderByComparator) throws SystemException {
1517                    FinderPath finderPath = null;
1518                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1519    
1520                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1521                                    (orderByComparator == null)) {
1522                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1523                            finderArgs = FINDER_ARGS_EMPTY;
1524                    }
1525                    else {
1526                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1527                            finderArgs = new Object[] { start, end, orderByComparator };
1528                    }
1529    
1530                    List<AssetTagStats> list = (List<AssetTagStats>)FinderCacheUtil.getResult(finderPath,
1531                                    finderArgs, this);
1532    
1533                    if (list == null) {
1534                            StringBundler query = null;
1535                            String sql = null;
1536    
1537                            if (orderByComparator != null) {
1538                                    query = new StringBundler(2 +
1539                                                    (orderByComparator.getOrderByFields().length * 3));
1540    
1541                                    query.append(_SQL_SELECT_ASSETTAGSTATS);
1542    
1543                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1544                                            orderByComparator);
1545    
1546                                    sql = query.toString();
1547                            }
1548                            else {
1549                                    sql = _SQL_SELECT_ASSETTAGSTATS.concat(AssetTagStatsModelImpl.ORDER_BY_JPQL);
1550                            }
1551    
1552                            Session session = null;
1553    
1554                            try {
1555                                    session = openSession();
1556    
1557                                    Query q = session.createQuery(sql);
1558    
1559                                    if (orderByComparator == null) {
1560                                            list = (List<AssetTagStats>)QueryUtil.list(q, getDialect(),
1561                                                            start, end, false);
1562    
1563                                            Collections.sort(list);
1564                                    }
1565                                    else {
1566                                            list = (List<AssetTagStats>)QueryUtil.list(q, getDialect(),
1567                                                            start, end);
1568                                    }
1569                            }
1570                            catch (Exception e) {
1571                                    throw processException(e);
1572                            }
1573                            finally {
1574                                    if (list == null) {
1575                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1576                                    }
1577                                    else {
1578                                            cacheResult(list);
1579    
1580                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1581                                    }
1582    
1583                                    closeSession(session);
1584                            }
1585                    }
1586    
1587                    return list;
1588            }
1589    
1590            /**
1591             * Removes all the asset tag statses where tagId = &#63; from the database.
1592             *
1593             * @param tagId the tag ID
1594             * @throws SystemException if a system exception occurred
1595             */
1596            public void removeByTagId(long tagId) throws SystemException {
1597                    for (AssetTagStats assetTagStats : findByTagId(tagId)) {
1598                            remove(assetTagStats);
1599                    }
1600            }
1601    
1602            /**
1603             * Removes all the asset tag statses where classNameId = &#63; from the database.
1604             *
1605             * @param classNameId the class name ID
1606             * @throws SystemException if a system exception occurred
1607             */
1608            public void removeByClassNameId(long classNameId) throws SystemException {
1609                    for (AssetTagStats assetTagStats : findByClassNameId(classNameId)) {
1610                            remove(assetTagStats);
1611                    }
1612            }
1613    
1614            /**
1615             * Removes the asset tag stats where tagId = &#63; and classNameId = &#63; from the database.
1616             *
1617             * @param tagId the tag ID
1618             * @param classNameId the class name ID
1619             * @return the asset tag stats that was removed
1620             * @throws SystemException if a system exception occurred
1621             */
1622            public AssetTagStats removeByT_C(long tagId, long classNameId)
1623                    throws NoSuchTagStatsException, SystemException {
1624                    AssetTagStats assetTagStats = findByT_C(tagId, classNameId);
1625    
1626                    return remove(assetTagStats);
1627            }
1628    
1629            /**
1630             * Removes all the asset tag statses from the database.
1631             *
1632             * @throws SystemException if a system exception occurred
1633             */
1634            public void removeAll() throws SystemException {
1635                    for (AssetTagStats assetTagStats : findAll()) {
1636                            remove(assetTagStats);
1637                    }
1638            }
1639    
1640            /**
1641             * Returns the number of asset tag statses where tagId = &#63;.
1642             *
1643             * @param tagId the tag ID
1644             * @return the number of matching asset tag statses
1645             * @throws SystemException if a system exception occurred
1646             */
1647            public int countByTagId(long tagId) throws SystemException {
1648                    Object[] finderArgs = new Object[] { tagId };
1649    
1650                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TAGID,
1651                                    finderArgs, this);
1652    
1653                    if (count == null) {
1654                            StringBundler query = new StringBundler(2);
1655    
1656                            query.append(_SQL_COUNT_ASSETTAGSTATS_WHERE);
1657    
1658                            query.append(_FINDER_COLUMN_TAGID_TAGID_2);
1659    
1660                            String sql = query.toString();
1661    
1662                            Session session = null;
1663    
1664                            try {
1665                                    session = openSession();
1666    
1667                                    Query q = session.createQuery(sql);
1668    
1669                                    QueryPos qPos = QueryPos.getInstance(q);
1670    
1671                                    qPos.add(tagId);
1672    
1673                                    count = (Long)q.uniqueResult();
1674                            }
1675                            catch (Exception e) {
1676                                    throw processException(e);
1677                            }
1678                            finally {
1679                                    if (count == null) {
1680                                            count = Long.valueOf(0);
1681                                    }
1682    
1683                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TAGID,
1684                                            finderArgs, count);
1685    
1686                                    closeSession(session);
1687                            }
1688                    }
1689    
1690                    return count.intValue();
1691            }
1692    
1693            /**
1694             * Returns the number of asset tag statses where classNameId = &#63;.
1695             *
1696             * @param classNameId the class name ID
1697             * @return the number of matching asset tag statses
1698             * @throws SystemException if a system exception occurred
1699             */
1700            public int countByClassNameId(long classNameId) throws SystemException {
1701                    Object[] finderArgs = new Object[] { classNameId };
1702    
1703                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
1704                                    finderArgs, this);
1705    
1706                    if (count == null) {
1707                            StringBundler query = new StringBundler(2);
1708    
1709                            query.append(_SQL_COUNT_ASSETTAGSTATS_WHERE);
1710    
1711                            query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
1712    
1713                            String sql = query.toString();
1714    
1715                            Session session = null;
1716    
1717                            try {
1718                                    session = openSession();
1719    
1720                                    Query q = session.createQuery(sql);
1721    
1722                                    QueryPos qPos = QueryPos.getInstance(q);
1723    
1724                                    qPos.add(classNameId);
1725    
1726                                    count = (Long)q.uniqueResult();
1727                            }
1728                            catch (Exception e) {
1729                                    throw processException(e);
1730                            }
1731                            finally {
1732                                    if (count == null) {
1733                                            count = Long.valueOf(0);
1734                                    }
1735    
1736                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
1737                                            finderArgs, count);
1738    
1739                                    closeSession(session);
1740                            }
1741                    }
1742    
1743                    return count.intValue();
1744            }
1745    
1746            /**
1747             * Returns the number of asset tag statses where tagId = &#63; and classNameId = &#63;.
1748             *
1749             * @param tagId the tag ID
1750             * @param classNameId the class name ID
1751             * @return the number of matching asset tag statses
1752             * @throws SystemException if a system exception occurred
1753             */
1754            public int countByT_C(long tagId, long classNameId)
1755                    throws SystemException {
1756                    Object[] finderArgs = new Object[] { tagId, classNameId };
1757    
1758                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_C,
1759                                    finderArgs, this);
1760    
1761                    if (count == null) {
1762                            StringBundler query = new StringBundler(3);
1763    
1764                            query.append(_SQL_COUNT_ASSETTAGSTATS_WHERE);
1765    
1766                            query.append(_FINDER_COLUMN_T_C_TAGID_2);
1767    
1768                            query.append(_FINDER_COLUMN_T_C_CLASSNAMEID_2);
1769    
1770                            String sql = query.toString();
1771    
1772                            Session session = null;
1773    
1774                            try {
1775                                    session = openSession();
1776    
1777                                    Query q = session.createQuery(sql);
1778    
1779                                    QueryPos qPos = QueryPos.getInstance(q);
1780    
1781                                    qPos.add(tagId);
1782    
1783                                    qPos.add(classNameId);
1784    
1785                                    count = (Long)q.uniqueResult();
1786                            }
1787                            catch (Exception e) {
1788                                    throw processException(e);
1789                            }
1790                            finally {
1791                                    if (count == null) {
1792                                            count = Long.valueOf(0);
1793                                    }
1794    
1795                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_C, finderArgs,
1796                                            count);
1797    
1798                                    closeSession(session);
1799                            }
1800                    }
1801    
1802                    return count.intValue();
1803            }
1804    
1805            /**
1806             * Returns the number of asset tag statses.
1807             *
1808             * @return the number of asset tag statses
1809             * @throws SystemException if a system exception occurred
1810             */
1811            public int countAll() throws SystemException {
1812                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1813                                    FINDER_ARGS_EMPTY, this);
1814    
1815                    if (count == null) {
1816                            Session session = null;
1817    
1818                            try {
1819                                    session = openSession();
1820    
1821                                    Query q = session.createQuery(_SQL_COUNT_ASSETTAGSTATS);
1822    
1823                                    count = (Long)q.uniqueResult();
1824                            }
1825                            catch (Exception e) {
1826                                    throw processException(e);
1827                            }
1828                            finally {
1829                                    if (count == null) {
1830                                            count = Long.valueOf(0);
1831                                    }
1832    
1833                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1834                                            FINDER_ARGS_EMPTY, count);
1835    
1836                                    closeSession(session);
1837                            }
1838                    }
1839    
1840                    return count.intValue();
1841            }
1842    
1843            /**
1844             * Initializes the asset tag stats persistence.
1845             */
1846            public void afterPropertiesSet() {
1847                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1848                                            com.liferay.portal.util.PropsUtil.get(
1849                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetTagStats")));
1850    
1851                    if (listenerClassNames.length > 0) {
1852                            try {
1853                                    List<ModelListener<AssetTagStats>> listenersList = new ArrayList<ModelListener<AssetTagStats>>();
1854    
1855                                    for (String listenerClassName : listenerClassNames) {
1856                                            listenersList.add((ModelListener<AssetTagStats>)InstanceFactory.newInstance(
1857                                                            listenerClassName));
1858                                    }
1859    
1860                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1861                            }
1862                            catch (Exception e) {
1863                                    _log.error(e);
1864                            }
1865                    }
1866            }
1867    
1868            public void destroy() {
1869                    EntityCacheUtil.removeCache(AssetTagStatsImpl.class.getName());
1870                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1871                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1872            }
1873    
1874            @BeanReference(type = AssetCategoryPersistence.class)
1875            protected AssetCategoryPersistence assetCategoryPersistence;
1876            @BeanReference(type = AssetCategoryPropertyPersistence.class)
1877            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
1878            @BeanReference(type = AssetEntryPersistence.class)
1879            protected AssetEntryPersistence assetEntryPersistence;
1880            @BeanReference(type = AssetLinkPersistence.class)
1881            protected AssetLinkPersistence assetLinkPersistence;
1882            @BeanReference(type = AssetTagPersistence.class)
1883            protected AssetTagPersistence assetTagPersistence;
1884            @BeanReference(type = AssetTagPropertyPersistence.class)
1885            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
1886            @BeanReference(type = AssetTagStatsPersistence.class)
1887            protected AssetTagStatsPersistence assetTagStatsPersistence;
1888            @BeanReference(type = AssetVocabularyPersistence.class)
1889            protected AssetVocabularyPersistence assetVocabularyPersistence;
1890            @BeanReference(type = UserPersistence.class)
1891            protected UserPersistence userPersistence;
1892            private static final String _SQL_SELECT_ASSETTAGSTATS = "SELECT assetTagStats FROM AssetTagStats assetTagStats";
1893            private static final String _SQL_SELECT_ASSETTAGSTATS_WHERE = "SELECT assetTagStats FROM AssetTagStats assetTagStats WHERE ";
1894            private static final String _SQL_COUNT_ASSETTAGSTATS = "SELECT COUNT(assetTagStats) FROM AssetTagStats assetTagStats";
1895            private static final String _SQL_COUNT_ASSETTAGSTATS_WHERE = "SELECT COUNT(assetTagStats) FROM AssetTagStats assetTagStats WHERE ";
1896            private static final String _FINDER_COLUMN_TAGID_TAGID_2 = "assetTagStats.tagId = ?";
1897            private static final String _FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2 = "assetTagStats.classNameId = ?";
1898            private static final String _FINDER_COLUMN_T_C_TAGID_2 = "assetTagStats.tagId = ? AND ";
1899            private static final String _FINDER_COLUMN_T_C_CLASSNAMEID_2 = "assetTagStats.classNameId = ?";
1900            private static final String _ORDER_BY_ENTITY_ALIAS = "assetTagStats.";
1901            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetTagStats exists with the primary key ";
1902            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetTagStats exists with the key {";
1903            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1904            private static Log _log = LogFactoryUtil.getLog(AssetTagStatsPersistenceImpl.class);
1905            private static AssetTagStats _nullAssetTagStats = new AssetTagStatsImpl() {
1906                            @Override
1907                            public Object clone() {
1908                                    return this;
1909                            }
1910    
1911                            @Override
1912                            public CacheModel<AssetTagStats> toCacheModel() {
1913                                    return _nullAssetTagStatsCacheModel;
1914                            }
1915                    };
1916    
1917            private static CacheModel<AssetTagStats> _nullAssetTagStatsCacheModel = new CacheModel<AssetTagStats>() {
1918                            public AssetTagStats toEntityModel() {
1919                                    return _nullAssetTagStats;
1920                            }
1921                    };
1922    }