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