001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.asset.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderPath;
028    import com.liferay.portal.kernel.dao.orm.Query;
029    import com.liferay.portal.kernel.dao.orm.QueryPos;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.SQLQuery;
032    import com.liferay.portal.kernel.dao.orm.Session;
033    import com.liferay.portal.kernel.exception.SystemException;
034    import com.liferay.portal.kernel.log.Log;
035    import com.liferay.portal.kernel.log.LogFactoryUtil;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.StringUtil;
043    import com.liferay.portal.model.CacheModel;
044    import com.liferay.portal.model.ModelListener;
045    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046    import com.liferay.portal.service.persistence.BatchSessionUtil;
047    import com.liferay.portal.service.persistence.ResourcePersistence;
048    import com.liferay.portal.service.persistence.UserPersistence;
049    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050    
051    import com.liferay.portlet.asset.NoSuchTagException;
052    import com.liferay.portlet.asset.model.AssetTag;
053    import com.liferay.portlet.asset.model.impl.AssetTagImpl;
054    import com.liferay.portlet.asset.model.impl.AssetTagModelImpl;
055    
056    import java.io.Serializable;
057    
058    import java.util.ArrayList;
059    import java.util.Collections;
060    import java.util.List;
061    import java.util.Set;
062    
063    /**
064     * The persistence implementation for the asset tag service.
065     *
066     * <p>
067     * Caching information and settings can be found in <code>portal.properties</code>
068     * </p>
069     *
070     * @author Brian Wing Shun Chan
071     * @see AssetTagPersistence
072     * @see AssetTagUtil
073     * @generated
074     */
075    public class AssetTagPersistenceImpl extends BasePersistenceImpl<AssetTag>
076            implements AssetTagPersistence {
077            /*
078             * NOTE FOR DEVELOPERS:
079             *
080             * Never modify or reference this class directly. Always use {@link AssetTagUtil} to access the asset tag persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
081             */
082            public static final String FINDER_CLASS_NAME_ENTITY = AssetTagImpl.class.getName();
083            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List1";
085            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086                    ".List2";
087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
088                            AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
090                            new String[] {
091                                    Long.class.getName(),
092                                    
093                            "java.lang.Integer", "java.lang.Integer",
094                                    "com.liferay.portal.kernel.util.OrderByComparator"
095                            });
096            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
097                    new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
098                            AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
100                            new String[] { Long.class.getName() },
101                            AssetTagModelImpl.GROUPID_COLUMN_BITMASK);
102            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
103                            AssetTagModelImpl.FINDER_CACHE_ENABLED, Long.class,
104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
105                            new String[] { Long.class.getName() });
106            public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
107                            AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
108                            FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
109                            new String[] { Long.class.getName(), String.class.getName() },
110                            AssetTagModelImpl.GROUPID_COLUMN_BITMASK |
111                            AssetTagModelImpl.NAME_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
113                            AssetTagModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
115                            new String[] { Long.class.getName(), String.class.getName() });
116            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
117                            AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
119            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
120                            AssetTagModelImpl.FINDER_CACHE_ENABLED, AssetTagImpl.class,
121                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
122            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
123                            AssetTagModelImpl.FINDER_CACHE_ENABLED, Long.class,
124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
125    
126            /**
127             * Caches the asset tag in the entity cache if it is enabled.
128             *
129             * @param assetTag the asset tag
130             */
131            public void cacheResult(AssetTag assetTag) {
132                    EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
133                            AssetTagImpl.class, assetTag.getPrimaryKey(), assetTag);
134    
135                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
136                            new Object[] { Long.valueOf(assetTag.getGroupId()), assetTag.getName() },
137                            assetTag);
138    
139                    assetTag.resetOriginalValues();
140            }
141    
142            /**
143             * Caches the asset tags in the entity cache if it is enabled.
144             *
145             * @param assetTags the asset tags
146             */
147            public void cacheResult(List<AssetTag> assetTags) {
148                    for (AssetTag assetTag : assetTags) {
149                            if (EntityCacheUtil.getResult(
150                                                    AssetTagModelImpl.ENTITY_CACHE_ENABLED,
151                                                    AssetTagImpl.class, assetTag.getPrimaryKey()) == null) {
152                                    cacheResult(assetTag);
153                            }
154                            else {
155                                    assetTag.resetOriginalValues();
156                            }
157                    }
158            }
159    
160            /**
161             * Clears the cache for all asset tags.
162             *
163             * <p>
164             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
165             * </p>
166             */
167            @Override
168            public void clearCache() {
169                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
170                            CacheRegistryUtil.clear(AssetTagImpl.class.getName());
171                    }
172    
173                    EntityCacheUtil.clearCache(AssetTagImpl.class.getName());
174    
175                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
176                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
177                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
178            }
179    
180            /**
181             * Clears the cache for the asset tag.
182             *
183             * <p>
184             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
185             * </p>
186             */
187            @Override
188            public void clearCache(AssetTag assetTag) {
189                    EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
190                            AssetTagImpl.class, assetTag.getPrimaryKey());
191    
192                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
193                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
194    
195                    clearUniqueFindersCache(assetTag);
196            }
197    
198            @Override
199            public void clearCache(List<AssetTag> assetTags) {
200                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
201                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
202    
203                    for (AssetTag assetTag : assetTags) {
204                            EntityCacheUtil.removeResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
205                                    AssetTagImpl.class, assetTag.getPrimaryKey());
206    
207                            clearUniqueFindersCache(assetTag);
208                    }
209            }
210    
211            protected void clearUniqueFindersCache(AssetTag assetTag) {
212                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
213                            new Object[] { Long.valueOf(assetTag.getGroupId()), assetTag.getName() });
214            }
215    
216            /**
217             * Creates a new asset tag with the primary key. Does not add the asset tag to the database.
218             *
219             * @param tagId the primary key for the new asset tag
220             * @return the new asset tag
221             */
222            public AssetTag create(long tagId) {
223                    AssetTag assetTag = new AssetTagImpl();
224    
225                    assetTag.setNew(true);
226                    assetTag.setPrimaryKey(tagId);
227    
228                    return assetTag;
229            }
230    
231            /**
232             * Removes the asset tag with the primary key from the database. Also notifies the appropriate model listeners.
233             *
234             * @param tagId the primary key of the asset tag
235             * @return the asset tag that was removed
236             * @throws com.liferay.portlet.asset.NoSuchTagException if a asset tag with the primary key could not be found
237             * @throws SystemException if a system exception occurred
238             */
239            public AssetTag remove(long tagId)
240                    throws NoSuchTagException, SystemException {
241                    return remove(Long.valueOf(tagId));
242            }
243    
244            /**
245             * Removes the asset tag with the primary key from the database. Also notifies the appropriate model listeners.
246             *
247             * @param primaryKey the primary key of the asset tag
248             * @return the asset tag that was removed
249             * @throws com.liferay.portlet.asset.NoSuchTagException if a asset tag with the primary key could not be found
250             * @throws SystemException if a system exception occurred
251             */
252            @Override
253            public AssetTag remove(Serializable primaryKey)
254                    throws NoSuchTagException, SystemException {
255                    Session session = null;
256    
257                    try {
258                            session = openSession();
259    
260                            AssetTag assetTag = (AssetTag)session.get(AssetTagImpl.class,
261                                            primaryKey);
262    
263                            if (assetTag == null) {
264                                    if (_log.isWarnEnabled()) {
265                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
266                                    }
267    
268                                    throw new NoSuchTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
269                                            primaryKey);
270                            }
271    
272                            return remove(assetTag);
273                    }
274                    catch (NoSuchTagException nsee) {
275                            throw nsee;
276                    }
277                    catch (Exception e) {
278                            throw processException(e);
279                    }
280                    finally {
281                            closeSession(session);
282                    }
283            }
284    
285            @Override
286            protected AssetTag removeImpl(AssetTag assetTag) throws SystemException {
287                    assetTag = toUnwrappedModel(assetTag);
288    
289                    try {
290                            clearAssetEntries.clear(assetTag.getPrimaryKey());
291                    }
292                    catch (Exception e) {
293                            throw processException(e);
294                    }
295                    finally {
296                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
297                    }
298    
299                    Session session = null;
300    
301                    try {
302                            session = openSession();
303    
304                            BatchSessionUtil.delete(session, assetTag);
305                    }
306                    catch (Exception e) {
307                            throw processException(e);
308                    }
309                    finally {
310                            closeSession(session);
311                    }
312    
313                    clearCache(assetTag);
314    
315                    return assetTag;
316            }
317    
318            @Override
319            public AssetTag updateImpl(
320                    com.liferay.portlet.asset.model.AssetTag assetTag, boolean merge)
321                    throws SystemException {
322                    assetTag = toUnwrappedModel(assetTag);
323    
324                    boolean isNew = assetTag.isNew();
325    
326                    AssetTagModelImpl assetTagModelImpl = (AssetTagModelImpl)assetTag;
327    
328                    Session session = null;
329    
330                    try {
331                            session = openSession();
332    
333                            BatchSessionUtil.update(session, assetTag, merge);
334    
335                            assetTag.setNew(false);
336                    }
337                    catch (Exception e) {
338                            throw processException(e);
339                    }
340                    finally {
341                            closeSession(session);
342                    }
343    
344                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
345    
346                    if (isNew || !AssetTagModelImpl.COLUMN_BITMASK_ENABLED) {
347                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
348                    }
349    
350                    else {
351                            if ((assetTagModelImpl.getColumnBitmask() &
352                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
353                                    Object[] args = new Object[] {
354                                                    Long.valueOf(assetTagModelImpl.getOriginalGroupId())
355                                            };
356    
357                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
358                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
359                                            args);
360    
361                                    args = new Object[] { Long.valueOf(assetTagModelImpl.getGroupId()) };
362    
363                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
364                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
365                                            args);
366                            }
367                    }
368    
369                    EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
370                            AssetTagImpl.class, assetTag.getPrimaryKey(), assetTag);
371    
372                    if (isNew) {
373                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
374                                    new Object[] {
375                                            Long.valueOf(assetTag.getGroupId()),
376                                            
377                                    assetTag.getName()
378                                    }, assetTag);
379                    }
380                    else {
381                            if ((assetTagModelImpl.getColumnBitmask() &
382                                            FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
383                                    Object[] args = new Object[] {
384                                                    Long.valueOf(assetTagModelImpl.getOriginalGroupId()),
385                                                    
386                                                    assetTagModelImpl.getOriginalName()
387                                            };
388    
389                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
390                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
391    
392                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
393                                            new Object[] {
394                                                    Long.valueOf(assetTag.getGroupId()),
395                                                    
396                                            assetTag.getName()
397                                            }, assetTag);
398                            }
399                    }
400    
401                    return assetTag;
402            }
403    
404            protected AssetTag toUnwrappedModel(AssetTag assetTag) {
405                    if (assetTag instanceof AssetTagImpl) {
406                            return assetTag;
407                    }
408    
409                    AssetTagImpl assetTagImpl = new AssetTagImpl();
410    
411                    assetTagImpl.setNew(assetTag.isNew());
412                    assetTagImpl.setPrimaryKey(assetTag.getPrimaryKey());
413    
414                    assetTagImpl.setTagId(assetTag.getTagId());
415                    assetTagImpl.setGroupId(assetTag.getGroupId());
416                    assetTagImpl.setCompanyId(assetTag.getCompanyId());
417                    assetTagImpl.setUserId(assetTag.getUserId());
418                    assetTagImpl.setUserName(assetTag.getUserName());
419                    assetTagImpl.setCreateDate(assetTag.getCreateDate());
420                    assetTagImpl.setModifiedDate(assetTag.getModifiedDate());
421                    assetTagImpl.setName(assetTag.getName());
422                    assetTagImpl.setAssetCount(assetTag.getAssetCount());
423    
424                    return assetTagImpl;
425            }
426    
427            /**
428             * Returns the asset tag with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
429             *
430             * @param primaryKey the primary key of the asset tag
431             * @return the asset tag
432             * @throws com.liferay.portal.NoSuchModelException if a asset tag with the primary key could not be found
433             * @throws SystemException if a system exception occurred
434             */
435            @Override
436            public AssetTag findByPrimaryKey(Serializable primaryKey)
437                    throws NoSuchModelException, SystemException {
438                    return findByPrimaryKey(((Long)primaryKey).longValue());
439            }
440    
441            /**
442             * Returns the asset tag with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchTagException} if it could not be found.
443             *
444             * @param tagId the primary key of the asset tag
445             * @return the asset tag
446             * @throws com.liferay.portlet.asset.NoSuchTagException if a asset tag with the primary key could not be found
447             * @throws SystemException if a system exception occurred
448             */
449            public AssetTag findByPrimaryKey(long tagId)
450                    throws NoSuchTagException, SystemException {
451                    AssetTag assetTag = fetchByPrimaryKey(tagId);
452    
453                    if (assetTag == null) {
454                            if (_log.isWarnEnabled()) {
455                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + tagId);
456                            }
457    
458                            throw new NoSuchTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
459                                    tagId);
460                    }
461    
462                    return assetTag;
463            }
464    
465            /**
466             * Returns the asset tag with the primary key or returns <code>null</code> if it could not be found.
467             *
468             * @param primaryKey the primary key of the asset tag
469             * @return the asset tag, or <code>null</code> if a asset tag with the primary key could not be found
470             * @throws SystemException if a system exception occurred
471             */
472            @Override
473            public AssetTag fetchByPrimaryKey(Serializable primaryKey)
474                    throws SystemException {
475                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
476            }
477    
478            /**
479             * Returns the asset tag with the primary key or returns <code>null</code> if it could not be found.
480             *
481             * @param tagId the primary key of the asset tag
482             * @return the asset tag, or <code>null</code> if a asset tag with the primary key could not be found
483             * @throws SystemException if a system exception occurred
484             */
485            public AssetTag fetchByPrimaryKey(long tagId) throws SystemException {
486                    AssetTag assetTag = (AssetTag)EntityCacheUtil.getResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
487                                    AssetTagImpl.class, tagId);
488    
489                    if (assetTag == _nullAssetTag) {
490                            return null;
491                    }
492    
493                    if (assetTag == null) {
494                            Session session = null;
495    
496                            boolean hasException = false;
497    
498                            try {
499                                    session = openSession();
500    
501                                    assetTag = (AssetTag)session.get(AssetTagImpl.class,
502                                                    Long.valueOf(tagId));
503                            }
504                            catch (Exception e) {
505                                    hasException = true;
506    
507                                    throw processException(e);
508                            }
509                            finally {
510                                    if (assetTag != null) {
511                                            cacheResult(assetTag);
512                                    }
513                                    else if (!hasException) {
514                                            EntityCacheUtil.putResult(AssetTagModelImpl.ENTITY_CACHE_ENABLED,
515                                                    AssetTagImpl.class, tagId, _nullAssetTag);
516                                    }
517    
518                                    closeSession(session);
519                            }
520                    }
521    
522                    return assetTag;
523            }
524    
525            /**
526             * Returns all the asset tags where groupId = &#63;.
527             *
528             * @param groupId the group ID
529             * @return the matching asset tags
530             * @throws SystemException if a system exception occurred
531             */
532            public List<AssetTag> findByGroupId(long groupId) throws SystemException {
533                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
534            }
535    
536            /**
537             * Returns a range of all the asset tags where groupId = &#63;.
538             *
539             * <p>
540             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
541             * </p>
542             *
543             * @param groupId the group ID
544             * @param start the lower bound of the range of asset tags
545             * @param end the upper bound of the range of asset tags (not inclusive)
546             * @return the range of matching asset tags
547             * @throws SystemException if a system exception occurred
548             */
549            public List<AssetTag> findByGroupId(long groupId, int start, int end)
550                    throws SystemException {
551                    return findByGroupId(groupId, start, end, null);
552            }
553    
554            /**
555             * Returns an ordered range of all the asset tags where groupId = &#63;.
556             *
557             * <p>
558             * 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.
559             * </p>
560             *
561             * @param groupId the group ID
562             * @param start the lower bound of the range of asset tags
563             * @param end the upper bound of the range of asset tags (not inclusive)
564             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
565             * @return the ordered range of matching asset tags
566             * @throws SystemException if a system exception occurred
567             */
568            public List<AssetTag> findByGroupId(long groupId, int start, int end,
569                    OrderByComparator orderByComparator) throws SystemException {
570                    FinderPath finderPath = null;
571                    Object[] finderArgs = null;
572    
573                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
574                                    (orderByComparator == null)) {
575                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
576                            finderArgs = new Object[] { groupId };
577                    }
578                    else {
579                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
580                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
581                    }
582    
583                    List<AssetTag> list = (List<AssetTag>)FinderCacheUtil.getResult(finderPath,
584                                    finderArgs, this);
585    
586                    if (list == null) {
587                            StringBundler query = null;
588    
589                            if (orderByComparator != null) {
590                                    query = new StringBundler(3 +
591                                                    (orderByComparator.getOrderByFields().length * 3));
592                            }
593                            else {
594                                    query = new StringBundler(3);
595                            }
596    
597                            query.append(_SQL_SELECT_ASSETTAG_WHERE);
598    
599                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
600    
601                            if (orderByComparator != null) {
602                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
603                                            orderByComparator);
604                            }
605    
606                            else {
607                                    query.append(AssetTagModelImpl.ORDER_BY_JPQL);
608                            }
609    
610                            String sql = query.toString();
611    
612                            Session session = null;
613    
614                            try {
615                                    session = openSession();
616    
617                                    Query q = session.createQuery(sql);
618    
619                                    QueryPos qPos = QueryPos.getInstance(q);
620    
621                                    qPos.add(groupId);
622    
623                                    list = (List<AssetTag>)QueryUtil.list(q, getDialect(), start,
624                                                    end);
625                            }
626                            catch (Exception e) {
627                                    throw processException(e);
628                            }
629                            finally {
630                                    if (list == null) {
631                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
632                                    }
633                                    else {
634                                            cacheResult(list);
635    
636                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
637                                    }
638    
639                                    closeSession(session);
640                            }
641                    }
642    
643                    return list;
644            }
645    
646            /**
647             * Returns the first asset tag in the ordered set where groupId = &#63;.
648             *
649             * <p>
650             * 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.
651             * </p>
652             *
653             * @param groupId the group ID
654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
655             * @return the first matching asset tag
656             * @throws com.liferay.portlet.asset.NoSuchTagException if a matching asset tag could not be found
657             * @throws SystemException if a system exception occurred
658             */
659            public AssetTag findByGroupId_First(long groupId,
660                    OrderByComparator orderByComparator)
661                    throws NoSuchTagException, SystemException {
662                    List<AssetTag> list = findByGroupId(groupId, 0, 1, orderByComparator);
663    
664                    if (list.isEmpty()) {
665                            StringBundler msg = new StringBundler(4);
666    
667                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
668    
669                            msg.append("groupId=");
670                            msg.append(groupId);
671    
672                            msg.append(StringPool.CLOSE_CURLY_BRACE);
673    
674                            throw new NoSuchTagException(msg.toString());
675                    }
676                    else {
677                            return list.get(0);
678                    }
679            }
680    
681            /**
682             * Returns the last asset tag in the ordered set where groupId = &#63;.
683             *
684             * <p>
685             * 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.
686             * </p>
687             *
688             * @param groupId the group ID
689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
690             * @return the last matching asset tag
691             * @throws com.liferay.portlet.asset.NoSuchTagException if a matching asset tag could not be found
692             * @throws SystemException if a system exception occurred
693             */
694            public AssetTag findByGroupId_Last(long groupId,
695                    OrderByComparator orderByComparator)
696                    throws NoSuchTagException, SystemException {
697                    int count = countByGroupId(groupId);
698    
699                    List<AssetTag> list = findByGroupId(groupId, count - 1, count,
700                                    orderByComparator);
701    
702                    if (list.isEmpty()) {
703                            StringBundler msg = new StringBundler(4);
704    
705                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
706    
707                            msg.append("groupId=");
708                            msg.append(groupId);
709    
710                            msg.append(StringPool.CLOSE_CURLY_BRACE);
711    
712                            throw new NoSuchTagException(msg.toString());
713                    }
714                    else {
715                            return list.get(0);
716                    }
717            }
718    
719            /**
720             * Returns the asset tags before and after the current asset tag in the ordered set where groupId = &#63;.
721             *
722             * <p>
723             * 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.
724             * </p>
725             *
726             * @param tagId the primary key of the current asset tag
727             * @param groupId the group ID
728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
729             * @return the previous, current, and next asset tag
730             * @throws com.liferay.portlet.asset.NoSuchTagException if a asset tag with the primary key could not be found
731             * @throws SystemException if a system exception occurred
732             */
733            public AssetTag[] findByGroupId_PrevAndNext(long tagId, long groupId,
734                    OrderByComparator orderByComparator)
735                    throws NoSuchTagException, SystemException {
736                    AssetTag assetTag = findByPrimaryKey(tagId);
737    
738                    Session session = null;
739    
740                    try {
741                            session = openSession();
742    
743                            AssetTag[] array = new AssetTagImpl[3];
744    
745                            array[0] = getByGroupId_PrevAndNext(session, assetTag, groupId,
746                                            orderByComparator, true);
747    
748                            array[1] = assetTag;
749    
750                            array[2] = getByGroupId_PrevAndNext(session, assetTag, groupId,
751                                            orderByComparator, false);
752    
753                            return array;
754                    }
755                    catch (Exception e) {
756                            throw processException(e);
757                    }
758                    finally {
759                            closeSession(session);
760                    }
761            }
762    
763            protected AssetTag getByGroupId_PrevAndNext(Session session,
764                    AssetTag assetTag, long groupId, OrderByComparator orderByComparator,
765                    boolean previous) {
766                    StringBundler query = null;
767    
768                    if (orderByComparator != null) {
769                            query = new StringBundler(6 +
770                                            (orderByComparator.getOrderByFields().length * 6));
771                    }
772                    else {
773                            query = new StringBundler(3);
774                    }
775    
776                    query.append(_SQL_SELECT_ASSETTAG_WHERE);
777    
778                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
779    
780                    if (orderByComparator != null) {
781                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
782    
783                            if (orderByConditionFields.length > 0) {
784                                    query.append(WHERE_AND);
785                            }
786    
787                            for (int i = 0; i < orderByConditionFields.length; i++) {
788                                    query.append(_ORDER_BY_ENTITY_ALIAS);
789                                    query.append(orderByConditionFields[i]);
790    
791                                    if ((i + 1) < orderByConditionFields.length) {
792                                            if (orderByComparator.isAscending() ^ previous) {
793                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
794                                            }
795                                            else {
796                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
797                                            }
798                                    }
799                                    else {
800                                            if (orderByComparator.isAscending() ^ previous) {
801                                                    query.append(WHERE_GREATER_THAN);
802                                            }
803                                            else {
804                                                    query.append(WHERE_LESSER_THAN);
805                                            }
806                                    }
807                            }
808    
809                            query.append(ORDER_BY_CLAUSE);
810    
811                            String[] orderByFields = orderByComparator.getOrderByFields();
812    
813                            for (int i = 0; i < orderByFields.length; i++) {
814                                    query.append(_ORDER_BY_ENTITY_ALIAS);
815                                    query.append(orderByFields[i]);
816    
817                                    if ((i + 1) < orderByFields.length) {
818                                            if (orderByComparator.isAscending() ^ previous) {
819                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
820                                            }
821                                            else {
822                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
823                                            }
824                                    }
825                                    else {
826                                            if (orderByComparator.isAscending() ^ previous) {
827                                                    query.append(ORDER_BY_ASC);
828                                            }
829                                            else {
830                                                    query.append(ORDER_BY_DESC);
831                                            }
832                                    }
833                            }
834                    }
835    
836                    else {
837                            query.append(AssetTagModelImpl.ORDER_BY_JPQL);
838                    }
839    
840                    String sql = query.toString();
841    
842                    Query q = session.createQuery(sql);
843    
844                    q.setFirstResult(0);
845                    q.setMaxResults(2);
846    
847                    QueryPos qPos = QueryPos.getInstance(q);
848    
849                    qPos.add(groupId);
850    
851                    if (orderByComparator != null) {
852                            Object[] values = orderByComparator.getOrderByConditionValues(assetTag);
853    
854                            for (Object value : values) {
855                                    qPos.add(value);
856                            }
857                    }
858    
859                    List<AssetTag> list = q.list();
860    
861                    if (list.size() == 2) {
862                            return list.get(1);
863                    }
864                    else {
865                            return null;
866                    }
867            }
868    
869            /**
870             * Returns all the asset tags that the user has permission to view where groupId = &#63;.
871             *
872             * @param groupId the group ID
873             * @return the matching asset tags that the user has permission to view
874             * @throws SystemException if a system exception occurred
875             */
876            public List<AssetTag> filterFindByGroupId(long groupId)
877                    throws SystemException {
878                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
879                            QueryUtil.ALL_POS, null);
880            }
881    
882            /**
883             * Returns a range of all the asset tags that the user has permission to view where groupId = &#63;.
884             *
885             * <p>
886             * 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.
887             * </p>
888             *
889             * @param groupId the group ID
890             * @param start the lower bound of the range of asset tags
891             * @param end the upper bound of the range of asset tags (not inclusive)
892             * @return the range of matching asset tags that the user has permission to view
893             * @throws SystemException if a system exception occurred
894             */
895            public List<AssetTag> filterFindByGroupId(long groupId, int start, int end)
896                    throws SystemException {
897                    return filterFindByGroupId(groupId, start, end, null);
898            }
899    
900            /**
901             * Returns an ordered range of all the asset tags that the user has permissions to view where groupId = &#63;.
902             *
903             * <p>
904             * 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.
905             * </p>
906             *
907             * @param groupId the group ID
908             * @param start the lower bound of the range of asset tags
909             * @param end the upper bound of the range of asset tags (not inclusive)
910             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
911             * @return the ordered range of matching asset tags that the user has permission to view
912             * @throws SystemException if a system exception occurred
913             */
914            public List<AssetTag> filterFindByGroupId(long groupId, int start, int end,
915                    OrderByComparator orderByComparator) throws SystemException {
916                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
917                            return findByGroupId(groupId, start, end, orderByComparator);
918                    }
919    
920                    StringBundler query = null;
921    
922                    if (orderByComparator != null) {
923                            query = new StringBundler(3 +
924                                            (orderByComparator.getOrderByFields().length * 3));
925                    }
926                    else {
927                            query = new StringBundler(3);
928                    }
929    
930                    if (getDB().isSupportsInlineDistinct()) {
931                            query.append(_FILTER_SQL_SELECT_ASSETTAG_WHERE);
932                    }
933                    else {
934                            query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_1);
935                    }
936    
937                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
938    
939                    if (!getDB().isSupportsInlineDistinct()) {
940                            query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_2);
941                    }
942    
943                    if (orderByComparator != null) {
944                            if (getDB().isSupportsInlineDistinct()) {
945                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
946                                            orderByComparator);
947                            }
948                            else {
949                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
950                                            orderByComparator);
951                            }
952                    }
953    
954                    else {
955                            if (getDB().isSupportsInlineDistinct()) {
956                                    query.append(AssetTagModelImpl.ORDER_BY_JPQL);
957                            }
958                            else {
959                                    query.append(AssetTagModelImpl.ORDER_BY_SQL);
960                            }
961                    }
962    
963                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
964                                    AssetTag.class.getName(),
965                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
966    
967                    Session session = null;
968    
969                    try {
970                            session = openSession();
971    
972                            SQLQuery q = session.createSQLQuery(sql);
973    
974                            if (getDB().isSupportsInlineDistinct()) {
975                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetTagImpl.class);
976                            }
977                            else {
978                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetTagImpl.class);
979                            }
980    
981                            QueryPos qPos = QueryPos.getInstance(q);
982    
983                            qPos.add(groupId);
984    
985                            return (List<AssetTag>)QueryUtil.list(q, getDialect(), start, end);
986                    }
987                    catch (Exception e) {
988                            throw processException(e);
989                    }
990                    finally {
991                            closeSession(session);
992                    }
993            }
994    
995            /**
996             * Returns the asset tags before and after the current asset tag in the ordered set of asset tags that the user has permission to view where groupId = &#63;.
997             *
998             * @param tagId the primary key of the current asset tag
999             * @param groupId the group ID
1000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1001             * @return the previous, current, and next asset tag
1002             * @throws com.liferay.portlet.asset.NoSuchTagException if a asset tag with the primary key could not be found
1003             * @throws SystemException if a system exception occurred
1004             */
1005            public AssetTag[] filterFindByGroupId_PrevAndNext(long tagId, long groupId,
1006                    OrderByComparator orderByComparator)
1007                    throws NoSuchTagException, SystemException {
1008                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1009                            return findByGroupId_PrevAndNext(tagId, groupId, orderByComparator);
1010                    }
1011    
1012                    AssetTag assetTag = findByPrimaryKey(tagId);
1013    
1014                    Session session = null;
1015    
1016                    try {
1017                            session = openSession();
1018    
1019                            AssetTag[] array = new AssetTagImpl[3];
1020    
1021                            array[0] = filterGetByGroupId_PrevAndNext(session, assetTag,
1022                                            groupId, orderByComparator, true);
1023    
1024                            array[1] = assetTag;
1025    
1026                            array[2] = filterGetByGroupId_PrevAndNext(session, assetTag,
1027                                            groupId, orderByComparator, false);
1028    
1029                            return array;
1030                    }
1031                    catch (Exception e) {
1032                            throw processException(e);
1033                    }
1034                    finally {
1035                            closeSession(session);
1036                    }
1037            }
1038    
1039            protected AssetTag filterGetByGroupId_PrevAndNext(Session session,
1040                    AssetTag assetTag, long groupId, OrderByComparator orderByComparator,
1041                    boolean previous) {
1042                    StringBundler query = null;
1043    
1044                    if (orderByComparator != null) {
1045                            query = new StringBundler(6 +
1046                                            (orderByComparator.getOrderByFields().length * 6));
1047                    }
1048                    else {
1049                            query = new StringBundler(3);
1050                    }
1051    
1052                    if (getDB().isSupportsInlineDistinct()) {
1053                            query.append(_FILTER_SQL_SELECT_ASSETTAG_WHERE);
1054                    }
1055                    else {
1056                            query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_1);
1057                    }
1058    
1059                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1060    
1061                    if (!getDB().isSupportsInlineDistinct()) {
1062                            query.append(_FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_2);
1063                    }
1064    
1065                    if (orderByComparator != null) {
1066                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1067    
1068                            if (orderByConditionFields.length > 0) {
1069                                    query.append(WHERE_AND);
1070                            }
1071    
1072                            for (int i = 0; i < orderByConditionFields.length; i++) {
1073                                    if (getDB().isSupportsInlineDistinct()) {
1074                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1075                                    }
1076                                    else {
1077                                            query.append(_ORDER_BY_ENTITY_TABLE);
1078                                    }
1079    
1080                                    query.append(orderByConditionFields[i]);
1081    
1082                                    if ((i + 1) < orderByConditionFields.length) {
1083                                            if (orderByComparator.isAscending() ^ previous) {
1084                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1085                                            }
1086                                            else {
1087                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1088                                            }
1089                                    }
1090                                    else {
1091                                            if (orderByComparator.isAscending() ^ previous) {
1092                                                    query.append(WHERE_GREATER_THAN);
1093                                            }
1094                                            else {
1095                                                    query.append(WHERE_LESSER_THAN);
1096                                            }
1097                                    }
1098                            }
1099    
1100                            query.append(ORDER_BY_CLAUSE);
1101    
1102                            String[] orderByFields = orderByComparator.getOrderByFields();
1103    
1104                            for (int i = 0; i < orderByFields.length; i++) {
1105                                    if (getDB().isSupportsInlineDistinct()) {
1106                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1107                                    }
1108                                    else {
1109                                            query.append(_ORDER_BY_ENTITY_TABLE);
1110                                    }
1111    
1112                                    query.append(orderByFields[i]);
1113    
1114                                    if ((i + 1) < orderByFields.length) {
1115                                            if (orderByComparator.isAscending() ^ previous) {
1116                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1117                                            }
1118                                            else {
1119                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1120                                            }
1121                                    }
1122                                    else {
1123                                            if (orderByComparator.isAscending() ^ previous) {
1124                                                    query.append(ORDER_BY_ASC);
1125                                            }
1126                                            else {
1127                                                    query.append(ORDER_BY_DESC);
1128                                            }
1129                                    }
1130                            }
1131                    }
1132    
1133                    else {
1134                            if (getDB().isSupportsInlineDistinct()) {
1135                                    query.append(AssetTagModelImpl.ORDER_BY_JPQL);
1136                            }
1137                            else {
1138                                    query.append(AssetTagModelImpl.ORDER_BY_SQL);
1139                            }
1140                    }
1141    
1142                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1143                                    AssetTag.class.getName(),
1144                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1145    
1146                    SQLQuery q = session.createSQLQuery(sql);
1147    
1148                    q.setFirstResult(0);
1149                    q.setMaxResults(2);
1150    
1151                    if (getDB().isSupportsInlineDistinct()) {
1152                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetTagImpl.class);
1153                    }
1154                    else {
1155                            q.addEntity(_FILTER_ENTITY_TABLE, AssetTagImpl.class);
1156                    }
1157    
1158                    QueryPos qPos = QueryPos.getInstance(q);
1159    
1160                    qPos.add(groupId);
1161    
1162                    if (orderByComparator != null) {
1163                            Object[] values = orderByComparator.getOrderByConditionValues(assetTag);
1164    
1165                            for (Object value : values) {
1166                                    qPos.add(value);
1167                            }
1168                    }
1169    
1170                    List<AssetTag> list = q.list();
1171    
1172                    if (list.size() == 2) {
1173                            return list.get(1);
1174                    }
1175                    else {
1176                            return null;
1177                    }
1178            }
1179    
1180            /**
1181             * Returns the asset tag where groupId = &#63; and name = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchTagException} if it could not be found.
1182             *
1183             * @param groupId the group ID
1184             * @param name the name
1185             * @return the matching asset tag
1186             * @throws com.liferay.portlet.asset.NoSuchTagException if a matching asset tag could not be found
1187             * @throws SystemException if a system exception occurred
1188             */
1189            public AssetTag findByG_N(long groupId, String name)
1190                    throws NoSuchTagException, SystemException {
1191                    AssetTag assetTag = fetchByG_N(groupId, name);
1192    
1193                    if (assetTag == null) {
1194                            StringBundler msg = new StringBundler(6);
1195    
1196                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1197    
1198                            msg.append("groupId=");
1199                            msg.append(groupId);
1200    
1201                            msg.append(", name=");
1202                            msg.append(name);
1203    
1204                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1205    
1206                            if (_log.isWarnEnabled()) {
1207                                    _log.warn(msg.toString());
1208                            }
1209    
1210                            throw new NoSuchTagException(msg.toString());
1211                    }
1212    
1213                    return assetTag;
1214            }
1215    
1216            /**
1217             * Returns the asset tag where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1218             *
1219             * @param groupId the group ID
1220             * @param name the name
1221             * @return the matching asset tag, or <code>null</code> if a matching asset tag could not be found
1222             * @throws SystemException if a system exception occurred
1223             */
1224            public AssetTag fetchByG_N(long groupId, String name)
1225                    throws SystemException {
1226                    return fetchByG_N(groupId, name, true);
1227            }
1228    
1229            /**
1230             * Returns the asset tag where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1231             *
1232             * @param groupId the group ID
1233             * @param name the name
1234             * @param retrieveFromCache whether to use the finder cache
1235             * @return the matching asset tag, or <code>null</code> if a matching asset tag could not be found
1236             * @throws SystemException if a system exception occurred
1237             */
1238            public AssetTag fetchByG_N(long groupId, String name,
1239                    boolean retrieveFromCache) throws SystemException {
1240                    Object[] finderArgs = new Object[] { groupId, name };
1241    
1242                    Object result = null;
1243    
1244                    if (retrieveFromCache) {
1245                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1246                                            finderArgs, this);
1247                    }
1248    
1249                    if (result == null) {
1250                            StringBundler query = new StringBundler(4);
1251    
1252                            query.append(_SQL_SELECT_ASSETTAG_WHERE);
1253    
1254                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1255    
1256                            if (name == null) {
1257                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
1258                            }
1259                            else {
1260                                    if (name.equals(StringPool.BLANK)) {
1261                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
1262                                    }
1263                                    else {
1264                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
1265                                    }
1266                            }
1267    
1268                            query.append(AssetTagModelImpl.ORDER_BY_JPQL);
1269    
1270                            String sql = query.toString();
1271    
1272                            Session session = null;
1273    
1274                            try {
1275                                    session = openSession();
1276    
1277                                    Query q = session.createQuery(sql);
1278    
1279                                    QueryPos qPos = QueryPos.getInstance(q);
1280    
1281                                    qPos.add(groupId);
1282    
1283                                    if (name != null) {
1284                                            qPos.add(name);
1285                                    }
1286    
1287                                    List<AssetTag> list = q.list();
1288    
1289                                    result = list;
1290    
1291                                    AssetTag assetTag = null;
1292    
1293                                    if (list.isEmpty()) {
1294                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1295                                                    finderArgs, list);
1296                                    }
1297                                    else {
1298                                            assetTag = list.get(0);
1299    
1300                                            cacheResult(assetTag);
1301    
1302                                            if ((assetTag.getGroupId() != groupId) ||
1303                                                            (assetTag.getName() == null) ||
1304                                                            !assetTag.getName().equals(name)) {
1305                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1306                                                            finderArgs, assetTag);
1307                                            }
1308                                    }
1309    
1310                                    return assetTag;
1311                            }
1312                            catch (Exception e) {
1313                                    throw processException(e);
1314                            }
1315                            finally {
1316                                    if (result == null) {
1317                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
1318                                                    finderArgs);
1319                                    }
1320    
1321                                    closeSession(session);
1322                            }
1323                    }
1324                    else {
1325                            if (result instanceof List<?>) {
1326                                    return null;
1327                            }
1328                            else {
1329                                    return (AssetTag)result;
1330                            }
1331                    }
1332            }
1333    
1334            /**
1335             * Returns all the asset tags.
1336             *
1337             * @return the asset tags
1338             * @throws SystemException if a system exception occurred
1339             */
1340            public List<AssetTag> findAll() throws SystemException {
1341                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1342            }
1343    
1344            /**
1345             * Returns a range of all the asset tags.
1346             *
1347             * <p>
1348             * 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.
1349             * </p>
1350             *
1351             * @param start the lower bound of the range of asset tags
1352             * @param end the upper bound of the range of asset tags (not inclusive)
1353             * @return the range of asset tags
1354             * @throws SystemException if a system exception occurred
1355             */
1356            public List<AssetTag> findAll(int start, int end) throws SystemException {
1357                    return findAll(start, end, null);
1358            }
1359    
1360            /**
1361             * Returns an ordered range of all the asset tags.
1362             *
1363             * <p>
1364             * 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.
1365             * </p>
1366             *
1367             * @param start the lower bound of the range of asset tags
1368             * @param end the upper bound of the range of asset tags (not inclusive)
1369             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1370             * @return the ordered range of asset tags
1371             * @throws SystemException if a system exception occurred
1372             */
1373            public List<AssetTag> findAll(int start, int end,
1374                    OrderByComparator orderByComparator) throws SystemException {
1375                    FinderPath finderPath = null;
1376                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1377    
1378                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1379                                    (orderByComparator == null)) {
1380                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1381                            finderArgs = FINDER_ARGS_EMPTY;
1382                    }
1383                    else {
1384                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1385                            finderArgs = new Object[] { start, end, orderByComparator };
1386                    }
1387    
1388                    List<AssetTag> list = (List<AssetTag>)FinderCacheUtil.getResult(finderPath,
1389                                    finderArgs, this);
1390    
1391                    if (list == null) {
1392                            StringBundler query = null;
1393                            String sql = null;
1394    
1395                            if (orderByComparator != null) {
1396                                    query = new StringBundler(2 +
1397                                                    (orderByComparator.getOrderByFields().length * 3));
1398    
1399                                    query.append(_SQL_SELECT_ASSETTAG);
1400    
1401                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1402                                            orderByComparator);
1403    
1404                                    sql = query.toString();
1405                            }
1406                            else {
1407                                    sql = _SQL_SELECT_ASSETTAG.concat(AssetTagModelImpl.ORDER_BY_JPQL);
1408                            }
1409    
1410                            Session session = null;
1411    
1412                            try {
1413                                    session = openSession();
1414    
1415                                    Query q = session.createQuery(sql);
1416    
1417                                    if (orderByComparator == null) {
1418                                            list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
1419                                                            start, end, false);
1420    
1421                                            Collections.sort(list);
1422                                    }
1423                                    else {
1424                                            list = (List<AssetTag>)QueryUtil.list(q, getDialect(),
1425                                                            start, end);
1426                                    }
1427                            }
1428                            catch (Exception e) {
1429                                    throw processException(e);
1430                            }
1431                            finally {
1432                                    if (list == null) {
1433                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1434                                    }
1435                                    else {
1436                                            cacheResult(list);
1437    
1438                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1439                                    }
1440    
1441                                    closeSession(session);
1442                            }
1443                    }
1444    
1445                    return list;
1446            }
1447    
1448            /**
1449             * Removes all the asset tags where groupId = &#63; from the database.
1450             *
1451             * @param groupId the group ID
1452             * @throws SystemException if a system exception occurred
1453             */
1454            public void removeByGroupId(long groupId) throws SystemException {
1455                    for (AssetTag assetTag : findByGroupId(groupId)) {
1456                            remove(assetTag);
1457                    }
1458            }
1459    
1460            /**
1461             * Removes the asset tag where groupId = &#63; and name = &#63; from the database.
1462             *
1463             * @param groupId the group ID
1464             * @param name the name
1465             * @throws SystemException if a system exception occurred
1466             */
1467            public void removeByG_N(long groupId, String name)
1468                    throws NoSuchTagException, SystemException {
1469                    AssetTag assetTag = findByG_N(groupId, name);
1470    
1471                    remove(assetTag);
1472            }
1473    
1474            /**
1475             * Removes all the asset tags from the database.
1476             *
1477             * @throws SystemException if a system exception occurred
1478             */
1479            public void removeAll() throws SystemException {
1480                    for (AssetTag assetTag : findAll()) {
1481                            remove(assetTag);
1482                    }
1483            }
1484    
1485            /**
1486             * Returns the number of asset tags where groupId = &#63;.
1487             *
1488             * @param groupId the group ID
1489             * @return the number of matching asset tags
1490             * @throws SystemException if a system exception occurred
1491             */
1492            public int countByGroupId(long groupId) throws SystemException {
1493                    Object[] finderArgs = new Object[] { groupId };
1494    
1495                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1496                                    finderArgs, this);
1497    
1498                    if (count == null) {
1499                            StringBundler query = new StringBundler(2);
1500    
1501                            query.append(_SQL_COUNT_ASSETTAG_WHERE);
1502    
1503                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1504    
1505                            String sql = query.toString();
1506    
1507                            Session session = null;
1508    
1509                            try {
1510                                    session = openSession();
1511    
1512                                    Query q = session.createQuery(sql);
1513    
1514                                    QueryPos qPos = QueryPos.getInstance(q);
1515    
1516                                    qPos.add(groupId);
1517    
1518                                    count = (Long)q.uniqueResult();
1519                            }
1520                            catch (Exception e) {
1521                                    throw processException(e);
1522                            }
1523                            finally {
1524                                    if (count == null) {
1525                                            count = Long.valueOf(0);
1526                                    }
1527    
1528                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1529                                            finderArgs, count);
1530    
1531                                    closeSession(session);
1532                            }
1533                    }
1534    
1535                    return count.intValue();
1536            }
1537    
1538            /**
1539             * Returns the number of asset tags that the user has permission to view where groupId = &#63;.
1540             *
1541             * @param groupId the group ID
1542             * @return the number of matching asset tags that the user has permission to view
1543             * @throws SystemException if a system exception occurred
1544             */
1545            public int filterCountByGroupId(long groupId) throws SystemException {
1546                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1547                            return countByGroupId(groupId);
1548                    }
1549    
1550                    StringBundler query = new StringBundler(2);
1551    
1552                    query.append(_FILTER_SQL_COUNT_ASSETTAG_WHERE);
1553    
1554                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1555    
1556                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1557                                    AssetTag.class.getName(),
1558                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1559    
1560                    Session session = null;
1561    
1562                    try {
1563                            session = openSession();
1564    
1565                            SQLQuery q = session.createSQLQuery(sql);
1566    
1567                            q.addScalar(COUNT_COLUMN_NAME,
1568                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1569    
1570                            QueryPos qPos = QueryPos.getInstance(q);
1571    
1572                            qPos.add(groupId);
1573    
1574                            Long count = (Long)q.uniqueResult();
1575    
1576                            return count.intValue();
1577                    }
1578                    catch (Exception e) {
1579                            throw processException(e);
1580                    }
1581                    finally {
1582                            closeSession(session);
1583                    }
1584            }
1585    
1586            /**
1587             * Returns the number of asset tags where groupId = &#63; and name = &#63;.
1588             *
1589             * @param groupId the group ID
1590             * @param name the name
1591             * @return the number of matching asset tags
1592             * @throws SystemException if a system exception occurred
1593             */
1594            public int countByG_N(long groupId, String name) throws SystemException {
1595                    Object[] finderArgs = new Object[] { groupId, name };
1596    
1597                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1598                                    finderArgs, this);
1599    
1600                    if (count == null) {
1601                            StringBundler query = new StringBundler(3);
1602    
1603                            query.append(_SQL_COUNT_ASSETTAG_WHERE);
1604    
1605                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1606    
1607                            if (name == null) {
1608                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
1609                            }
1610                            else {
1611                                    if (name.equals(StringPool.BLANK)) {
1612                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
1613                                    }
1614                                    else {
1615                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
1616                                    }
1617                            }
1618    
1619                            String sql = query.toString();
1620    
1621                            Session session = null;
1622    
1623                            try {
1624                                    session = openSession();
1625    
1626                                    Query q = session.createQuery(sql);
1627    
1628                                    QueryPos qPos = QueryPos.getInstance(q);
1629    
1630                                    qPos.add(groupId);
1631    
1632                                    if (name != null) {
1633                                            qPos.add(name);
1634                                    }
1635    
1636                                    count = (Long)q.uniqueResult();
1637                            }
1638                            catch (Exception e) {
1639                                    throw processException(e);
1640                            }
1641                            finally {
1642                                    if (count == null) {
1643                                            count = Long.valueOf(0);
1644                                    }
1645    
1646                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1647                                            count);
1648    
1649                                    closeSession(session);
1650                            }
1651                    }
1652    
1653                    return count.intValue();
1654            }
1655    
1656            /**
1657             * Returns the number of asset tags.
1658             *
1659             * @return the number of asset tags
1660             * @throws SystemException if a system exception occurred
1661             */
1662            public int countAll() throws SystemException {
1663                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1664                                    FINDER_ARGS_EMPTY, this);
1665    
1666                    if (count == null) {
1667                            Session session = null;
1668    
1669                            try {
1670                                    session = openSession();
1671    
1672                                    Query q = session.createQuery(_SQL_COUNT_ASSETTAG);
1673    
1674                                    count = (Long)q.uniqueResult();
1675                            }
1676                            catch (Exception e) {
1677                                    throw processException(e);
1678                            }
1679                            finally {
1680                                    if (count == null) {
1681                                            count = Long.valueOf(0);
1682                                    }
1683    
1684                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1685                                            FINDER_ARGS_EMPTY, count);
1686    
1687                                    closeSession(session);
1688                            }
1689                    }
1690    
1691                    return count.intValue();
1692            }
1693    
1694            /**
1695             * Returns all the asset entries associated with the asset tag.
1696             *
1697             * @param pk the primary key of the asset tag
1698             * @return the asset entries associated with the asset tag
1699             * @throws SystemException if a system exception occurred
1700             */
1701            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1702                    long pk) throws SystemException {
1703                    return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1704            }
1705    
1706            /**
1707             * Returns a range of all the asset entries associated with the asset tag.
1708             *
1709             * <p>
1710             * 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.
1711             * </p>
1712             *
1713             * @param pk the primary key of the asset tag
1714             * @param start the lower bound of the range of asset tags
1715             * @param end the upper bound of the range of asset tags (not inclusive)
1716             * @return the range of asset entries associated with the asset tag
1717             * @throws SystemException if a system exception occurred
1718             */
1719            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1720                    long pk, int start, int end) throws SystemException {
1721                    return getAssetEntries(pk, start, end, null);
1722            }
1723    
1724            public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1725                            AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1726                            com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
1727                            AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1728                            "getAssetEntries",
1729                            new String[] {
1730                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1731                                    "com.liferay.portal.kernel.util.OrderByComparator"
1732                            });
1733    
1734            /**
1735             * Returns an ordered range of all the asset entries associated with the asset tag.
1736             *
1737             * <p>
1738             * 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.
1739             * </p>
1740             *
1741             * @param pk the primary key of the asset tag
1742             * @param start the lower bound of the range of asset tags
1743             * @param end the upper bound of the range of asset tags (not inclusive)
1744             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1745             * @return the ordered range of asset entries associated with the asset tag
1746             * @throws SystemException if a system exception occurred
1747             */
1748            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
1749                    long pk, int start, int end, OrderByComparator orderByComparator)
1750                    throws SystemException {
1751                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
1752    
1753                    List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
1754                                    finderArgs, this);
1755    
1756                    if (list == null) {
1757                            Session session = null;
1758    
1759                            try {
1760                                    session = openSession();
1761    
1762                                    String sql = null;
1763    
1764                                    if (orderByComparator != null) {
1765                                            sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
1766                                                                                              .concat(orderByComparator.getOrderBy());
1767                                    }
1768                                    else {
1769                                            sql = _SQL_GETASSETENTRIES;
1770                                    }
1771    
1772                                    SQLQuery q = session.createSQLQuery(sql);
1773    
1774                                    q.addEntity("AssetEntry",
1775                                            com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
1776    
1777                                    QueryPos qPos = QueryPos.getInstance(q);
1778    
1779                                    qPos.add(pk);
1780    
1781                                    list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
1782                                                    getDialect(), start, end);
1783                            }
1784                            catch (Exception e) {
1785                                    throw processException(e);
1786                            }
1787                            finally {
1788                                    if (list == null) {
1789                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
1790                                                    finderArgs);
1791                                    }
1792                                    else {
1793                                            assetEntryPersistence.cacheResult(list);
1794    
1795                                            FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
1796                                                    finderArgs, list);
1797                                    }
1798    
1799                                    closeSession(session);
1800                            }
1801                    }
1802    
1803                    return list;
1804            }
1805    
1806            public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1807                            AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1808                            Long.class,
1809                            AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1810                            "getAssetEntriesSize", new String[] { Long.class.getName() });
1811    
1812            /**
1813             * Returns the number of asset entries associated with the asset tag.
1814             *
1815             * @param pk the primary key of the asset tag
1816             * @return the number of asset entries associated with the asset tag
1817             * @throws SystemException if a system exception occurred
1818             */
1819            public int getAssetEntriesSize(long pk) throws SystemException {
1820                    Object[] finderArgs = new Object[] { pk };
1821    
1822                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
1823                                    finderArgs, this);
1824    
1825                    if (count == null) {
1826                            Session session = null;
1827    
1828                            try {
1829                                    session = openSession();
1830    
1831                                    SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
1832    
1833                                    q.addScalar(COUNT_COLUMN_NAME,
1834                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
1835    
1836                                    QueryPos qPos = QueryPos.getInstance(q);
1837    
1838                                    qPos.add(pk);
1839    
1840                                    count = (Long)q.uniqueResult();
1841                            }
1842                            catch (Exception e) {
1843                                    throw processException(e);
1844                            }
1845                            finally {
1846                                    if (count == null) {
1847                                            count = Long.valueOf(0);
1848                                    }
1849    
1850                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
1851                                            finderArgs, count);
1852    
1853                                    closeSession(session);
1854                            }
1855                    }
1856    
1857                    return count.intValue();
1858            }
1859    
1860            public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1861                            AssetTagModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
1862                            Boolean.class,
1863                            AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
1864                            "containsAssetEntry",
1865                            new String[] { Long.class.getName(), Long.class.getName() });
1866    
1867            /**
1868             * Returns <code>true</code> if the asset entry is associated with the asset tag.
1869             *
1870             * @param pk the primary key of the asset tag
1871             * @param assetEntryPK the primary key of the asset entry
1872             * @return <code>true</code> if the asset entry is associated with the asset tag; <code>false</code> otherwise
1873             * @throws SystemException if a system exception occurred
1874             */
1875            public boolean containsAssetEntry(long pk, long assetEntryPK)
1876                    throws SystemException {
1877                    Object[] finderArgs = new Object[] { pk, assetEntryPK };
1878    
1879                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
1880                                    finderArgs, this);
1881    
1882                    if (value == null) {
1883                            try {
1884                                    value = Boolean.valueOf(containsAssetEntry.contains(pk,
1885                                                            assetEntryPK));
1886                            }
1887                            catch (Exception e) {
1888                                    throw processException(e);
1889                            }
1890                            finally {
1891                                    if (value == null) {
1892                                            value = Boolean.FALSE;
1893                                    }
1894    
1895                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
1896                                            finderArgs, value);
1897                            }
1898                    }
1899    
1900                    return value.booleanValue();
1901            }
1902    
1903            /**
1904             * Returns <code>true</code> if the asset tag has any asset entries associated with it.
1905             *
1906             * @param pk the primary key of the asset tag to check for associations with asset entries
1907             * @return <code>true</code> if the asset tag has any asset entries associated with it; <code>false</code> otherwise
1908             * @throws SystemException if a system exception occurred
1909             */
1910            public boolean containsAssetEntries(long pk) throws SystemException {
1911                    if (getAssetEntriesSize(pk) > 0) {
1912                            return true;
1913                    }
1914                    else {
1915                            return false;
1916                    }
1917            }
1918    
1919            /**
1920             * Adds an association between the asset tag and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1921             *
1922             * @param pk the primary key of the asset tag
1923             * @param assetEntryPK the primary key of the asset entry
1924             * @throws SystemException if a system exception occurred
1925             */
1926            public void addAssetEntry(long pk, long assetEntryPK)
1927                    throws SystemException {
1928                    try {
1929                            addAssetEntry.add(pk, assetEntryPK);
1930                    }
1931                    catch (Exception e) {
1932                            throw processException(e);
1933                    }
1934                    finally {
1935                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1936                    }
1937            }
1938    
1939            /**
1940             * Adds an association between the asset tag and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1941             *
1942             * @param pk the primary key of the asset tag
1943             * @param assetEntry the asset entry
1944             * @throws SystemException if a system exception occurred
1945             */
1946            public void addAssetEntry(long pk,
1947                    com.liferay.portlet.asset.model.AssetEntry assetEntry)
1948                    throws SystemException {
1949                    try {
1950                            addAssetEntry.add(pk, assetEntry.getPrimaryKey());
1951                    }
1952                    catch (Exception e) {
1953                            throw processException(e);
1954                    }
1955                    finally {
1956                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1957                    }
1958            }
1959    
1960            /**
1961             * Adds an association between the asset tag and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1962             *
1963             * @param pk the primary key of the asset tag
1964             * @param assetEntryPKs the primary keys of the asset entries
1965             * @throws SystemException if a system exception occurred
1966             */
1967            public void addAssetEntries(long pk, long[] assetEntryPKs)
1968                    throws SystemException {
1969                    try {
1970                            for (long assetEntryPK : assetEntryPKs) {
1971                                    addAssetEntry.add(pk, assetEntryPK);
1972                            }
1973                    }
1974                    catch (Exception e) {
1975                            throw processException(e);
1976                    }
1977                    finally {
1978                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
1979                    }
1980            }
1981    
1982            /**
1983             * Adds an association between the asset tag and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
1984             *
1985             * @param pk the primary key of the asset tag
1986             * @param assetEntries the asset entries
1987             * @throws SystemException if a system exception occurred
1988             */
1989            public void addAssetEntries(long pk,
1990                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
1991                    throws SystemException {
1992                    try {
1993                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
1994                                    addAssetEntry.add(pk, assetEntry.getPrimaryKey());
1995                            }
1996                    }
1997                    catch (Exception e) {
1998                            throw processException(e);
1999                    }
2000                    finally {
2001                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2002                    }
2003            }
2004    
2005            /**
2006             * Clears all associations between the asset tag and its asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2007             *
2008             * @param pk the primary key of the asset tag to clear the associated asset entries from
2009             * @throws SystemException if a system exception occurred
2010             */
2011            public void clearAssetEntries(long pk) throws SystemException {
2012                    try {
2013                            clearAssetEntries.clear(pk);
2014                    }
2015                    catch (Exception e) {
2016                            throw processException(e);
2017                    }
2018                    finally {
2019                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2020                    }
2021            }
2022    
2023            /**
2024             * Removes the association between the asset tag and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2025             *
2026             * @param pk the primary key of the asset tag
2027             * @param assetEntryPK the primary key of the asset entry
2028             * @throws SystemException if a system exception occurred
2029             */
2030            public void removeAssetEntry(long pk, long assetEntryPK)
2031                    throws SystemException {
2032                    try {
2033                            removeAssetEntry.remove(pk, assetEntryPK);
2034                    }
2035                    catch (Exception e) {
2036                            throw processException(e);
2037                    }
2038                    finally {
2039                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2040                    }
2041            }
2042    
2043            /**
2044             * Removes the association between the asset tag and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2045             *
2046             * @param pk the primary key of the asset tag
2047             * @param assetEntry the asset entry
2048             * @throws SystemException if a system exception occurred
2049             */
2050            public void removeAssetEntry(long pk,
2051                    com.liferay.portlet.asset.model.AssetEntry assetEntry)
2052                    throws SystemException {
2053                    try {
2054                            removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
2055                    }
2056                    catch (Exception e) {
2057                            throw processException(e);
2058                    }
2059                    finally {
2060                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2061                    }
2062            }
2063    
2064            /**
2065             * Removes the association between the asset tag and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2066             *
2067             * @param pk the primary key of the asset tag
2068             * @param assetEntryPKs the primary keys of the asset entries
2069             * @throws SystemException if a system exception occurred
2070             */
2071            public void removeAssetEntries(long pk, long[] assetEntryPKs)
2072                    throws SystemException {
2073                    try {
2074                            for (long assetEntryPK : assetEntryPKs) {
2075                                    removeAssetEntry.remove(pk, assetEntryPK);
2076                            }
2077                    }
2078                    catch (Exception e) {
2079                            throw processException(e);
2080                    }
2081                    finally {
2082                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2083                    }
2084            }
2085    
2086            /**
2087             * Removes the association between the asset tag and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2088             *
2089             * @param pk the primary key of the asset tag
2090             * @param assetEntries the asset entries
2091             * @throws SystemException if a system exception occurred
2092             */
2093            public void removeAssetEntries(long pk,
2094                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
2095                    throws SystemException {
2096                    try {
2097                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2098                                    removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
2099                            }
2100                    }
2101                    catch (Exception e) {
2102                            throw processException(e);
2103                    }
2104                    finally {
2105                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2106                    }
2107            }
2108    
2109            /**
2110             * Sets the asset entries associated with the asset tag, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2111             *
2112             * @param pk the primary key of the asset tag
2113             * @param assetEntryPKs the primary keys of the asset entries to be associated with the asset tag
2114             * @throws SystemException if a system exception occurred
2115             */
2116            public void setAssetEntries(long pk, long[] assetEntryPKs)
2117                    throws SystemException {
2118                    try {
2119                            Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
2120    
2121                            List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
2122    
2123                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2124                                    if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
2125                                            removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
2126                                    }
2127                            }
2128    
2129                            for (Long assetEntryPK : assetEntryPKSet) {
2130                                    addAssetEntry.add(pk, assetEntryPK);
2131                            }
2132                    }
2133                    catch (Exception e) {
2134                            throw processException(e);
2135                    }
2136                    finally {
2137                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2138                    }
2139            }
2140    
2141            /**
2142             * Sets the asset entries associated with the asset tag, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2143             *
2144             * @param pk the primary key of the asset tag
2145             * @param assetEntries the asset entries to be associated with the asset tag
2146             * @throws SystemException if a system exception occurred
2147             */
2148            public void setAssetEntries(long pk,
2149                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
2150                    throws SystemException {
2151                    try {
2152                            long[] assetEntryPKs = new long[assetEntries.size()];
2153    
2154                            for (int i = 0; i < assetEntries.size(); i++) {
2155                                    com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
2156    
2157                                    assetEntryPKs[i] = assetEntry.getPrimaryKey();
2158                            }
2159    
2160                            setAssetEntries(pk, assetEntryPKs);
2161                    }
2162                    catch (Exception e) {
2163                            throw processException(e);
2164                    }
2165                    finally {
2166                            FinderCacheUtil.clearCache(AssetTagModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
2167                    }
2168            }
2169    
2170            /**
2171             * Initializes the asset tag persistence.
2172             */
2173            public void afterPropertiesSet() {
2174                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2175                                            com.liferay.portal.util.PropsUtil.get(
2176                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetTag")));
2177    
2178                    if (listenerClassNames.length > 0) {
2179                            try {
2180                                    List<ModelListener<AssetTag>> listenersList = new ArrayList<ModelListener<AssetTag>>();
2181    
2182                                    for (String listenerClassName : listenerClassNames) {
2183                                            listenersList.add((ModelListener<AssetTag>)InstanceFactory.newInstance(
2184                                                            listenerClassName));
2185                                    }
2186    
2187                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2188                            }
2189                            catch (Exception e) {
2190                                    _log.error(e);
2191                            }
2192                    }
2193    
2194                    containsAssetEntry = new ContainsAssetEntry();
2195    
2196                    addAssetEntry = new AddAssetEntry();
2197                    clearAssetEntries = new ClearAssetEntries();
2198                    removeAssetEntry = new RemoveAssetEntry();
2199            }
2200    
2201            public void destroy() {
2202                    EntityCacheUtil.removeCache(AssetTagImpl.class.getName());
2203                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2204                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2205            }
2206    
2207            @BeanReference(type = AssetCategoryPersistence.class)
2208            protected AssetCategoryPersistence assetCategoryPersistence;
2209            @BeanReference(type = AssetCategoryPropertyPersistence.class)
2210            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
2211            @BeanReference(type = AssetEntryPersistence.class)
2212            protected AssetEntryPersistence assetEntryPersistence;
2213            @BeanReference(type = AssetLinkPersistence.class)
2214            protected AssetLinkPersistence assetLinkPersistence;
2215            @BeanReference(type = AssetTagPersistence.class)
2216            protected AssetTagPersistence assetTagPersistence;
2217            @BeanReference(type = AssetTagPropertyPersistence.class)
2218            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
2219            @BeanReference(type = AssetTagStatsPersistence.class)
2220            protected AssetTagStatsPersistence assetTagStatsPersistence;
2221            @BeanReference(type = AssetVocabularyPersistence.class)
2222            protected AssetVocabularyPersistence assetVocabularyPersistence;
2223            @BeanReference(type = ResourcePersistence.class)
2224            protected ResourcePersistence resourcePersistence;
2225            @BeanReference(type = UserPersistence.class)
2226            protected UserPersistence userPersistence;
2227            protected ContainsAssetEntry containsAssetEntry;
2228            protected AddAssetEntry addAssetEntry;
2229            protected ClearAssetEntries clearAssetEntries;
2230            protected RemoveAssetEntry removeAssetEntry;
2231    
2232            protected class ContainsAssetEntry {
2233                    protected ContainsAssetEntry() {
2234                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2235                                            _SQL_CONTAINSASSETENTRY,
2236                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2237                                            RowMapper.COUNT);
2238                    }
2239    
2240                    protected boolean contains(long tagId, long entryId) {
2241                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2242                                                    new Long(tagId), new Long(entryId)
2243                                            });
2244    
2245                            if (results.size() > 0) {
2246                                    Integer count = results.get(0);
2247    
2248                                    if (count.intValue() > 0) {
2249                                            return true;
2250                                    }
2251                            }
2252    
2253                            return false;
2254                    }
2255    
2256                    private MappingSqlQuery<Integer> _mappingSqlQuery;
2257            }
2258    
2259            protected class AddAssetEntry {
2260                    protected AddAssetEntry() {
2261                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2262                                            "INSERT INTO AssetEntries_AssetTags (tagId, entryId) VALUES (?, ?)",
2263                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2264                    }
2265    
2266                    protected void add(long tagId, long entryId) throws SystemException {
2267                            if (!containsAssetEntry.contains(tagId, entryId)) {
2268                                    ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
2269                                            assetEntryPersistence.getListeners();
2270    
2271                                    for (ModelListener<AssetTag> listener : listeners) {
2272                                            listener.onBeforeAddAssociation(tagId,
2273                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2274                                                    entryId);
2275                                    }
2276    
2277                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2278                                            listener.onBeforeAddAssociation(entryId,
2279                                                    AssetTag.class.getName(), tagId);
2280                                    }
2281    
2282                                    _sqlUpdate.update(new Object[] {
2283                                                    new Long(tagId), new Long(entryId)
2284                                            });
2285    
2286                                    for (ModelListener<AssetTag> listener : listeners) {
2287                                            listener.onAfterAddAssociation(tagId,
2288                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2289                                                    entryId);
2290                                    }
2291    
2292                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2293                                            listener.onAfterAddAssociation(entryId,
2294                                                    AssetTag.class.getName(), tagId);
2295                                    }
2296                            }
2297                    }
2298    
2299                    private SqlUpdate _sqlUpdate;
2300            }
2301    
2302            protected class ClearAssetEntries {
2303                    protected ClearAssetEntries() {
2304                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2305                                            "DELETE FROM AssetEntries_AssetTags WHERE tagId = ?",
2306                                            new int[] { java.sql.Types.BIGINT });
2307                    }
2308    
2309                    protected void clear(long tagId) throws SystemException {
2310                            ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
2311                                    assetEntryPersistence.getListeners();
2312    
2313                            List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
2314    
2315                            if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
2316                                    assetEntries = getAssetEntries(tagId);
2317    
2318                                    for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2319                                            for (ModelListener<AssetTag> listener : listeners) {
2320                                                    listener.onBeforeRemoveAssociation(tagId,
2321                                                            com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2322                                                            assetEntry.getPrimaryKey());
2323                                            }
2324    
2325                                            for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2326                                                    listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
2327                                                            AssetTag.class.getName(), tagId);
2328                                            }
2329                                    }
2330                            }
2331    
2332                            _sqlUpdate.update(new Object[] { new Long(tagId) });
2333    
2334                            if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
2335                                    for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
2336                                            for (ModelListener<AssetTag> listener : listeners) {
2337                                                    listener.onAfterRemoveAssociation(tagId,
2338                                                            com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2339                                                            assetEntry.getPrimaryKey());
2340                                            }
2341    
2342                                            for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2343                                                    listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
2344                                                            AssetTag.class.getName(), tagId);
2345                                            }
2346                                    }
2347                            }
2348                    }
2349    
2350                    private SqlUpdate _sqlUpdate;
2351            }
2352    
2353            protected class RemoveAssetEntry {
2354                    protected RemoveAssetEntry() {
2355                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2356                                            "DELETE FROM AssetEntries_AssetTags WHERE tagId = ? AND entryId = ?",
2357                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2358                    }
2359    
2360                    protected void remove(long tagId, long entryId)
2361                            throws SystemException {
2362                            if (containsAssetEntry.contains(tagId, entryId)) {
2363                                    ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
2364                                            assetEntryPersistence.getListeners();
2365    
2366                                    for (ModelListener<AssetTag> listener : listeners) {
2367                                            listener.onBeforeRemoveAssociation(tagId,
2368                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2369                                                    entryId);
2370                                    }
2371    
2372                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2373                                            listener.onBeforeRemoveAssociation(entryId,
2374                                                    AssetTag.class.getName(), tagId);
2375                                    }
2376    
2377                                    _sqlUpdate.update(new Object[] {
2378                                                    new Long(tagId), new Long(entryId)
2379                                            });
2380    
2381                                    for (ModelListener<AssetTag> listener : listeners) {
2382                                            listener.onAfterRemoveAssociation(tagId,
2383                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
2384                                                    entryId);
2385                                    }
2386    
2387                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
2388                                            listener.onAfterRemoveAssociation(entryId,
2389                                                    AssetTag.class.getName(), tagId);
2390                                    }
2391                            }
2392                    }
2393    
2394                    private SqlUpdate _sqlUpdate;
2395            }
2396    
2397            private static final String _SQL_SELECT_ASSETTAG = "SELECT assetTag FROM AssetTag assetTag";
2398            private static final String _SQL_SELECT_ASSETTAG_WHERE = "SELECT assetTag FROM AssetTag assetTag WHERE ";
2399            private static final String _SQL_COUNT_ASSETTAG = "SELECT COUNT(assetTag) FROM AssetTag assetTag";
2400            private static final String _SQL_COUNT_ASSETTAG_WHERE = "SELECT COUNT(assetTag) FROM AssetTag assetTag WHERE ";
2401            private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetTags.tagId = ?)";
2402            private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE tagId = ?";
2403            private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE tagId = ? AND entryId = ?";
2404            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetTag.groupId = ?";
2405            private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetTag.groupId = ? AND ";
2406            private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetTag.name IS NULL";
2407            private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetTag.name = ?";
2408            private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetTag.name IS NULL OR assetTag.name = ?)";
2409            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetTag.tagId";
2410            private static final String _FILTER_SQL_SELECT_ASSETTAG_WHERE = "SELECT DISTINCT {assetTag.*} FROM AssetTag assetTag WHERE ";
2411            private static final String _FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_1 =
2412                    "SELECT {AssetTag.*} FROM (SELECT DISTINCT assetTag.tagId FROM AssetTag assetTag WHERE ";
2413            private static final String _FILTER_SQL_SELECT_ASSETTAG_NO_INLINE_DISTINCT_WHERE_2 =
2414                    ") TEMP_TABLE INNER JOIN AssetTag ON TEMP_TABLE.tagId = AssetTag.tagId";
2415            private static final String _FILTER_SQL_COUNT_ASSETTAG_WHERE = "SELECT COUNT(DISTINCT assetTag.tagId) AS COUNT_VALUE FROM AssetTag assetTag WHERE ";
2416            private static final String _FILTER_ENTITY_ALIAS = "assetTag";
2417            private static final String _FILTER_ENTITY_TABLE = "AssetTag";
2418            private static final String _ORDER_BY_ENTITY_ALIAS = "assetTag.";
2419            private static final String _ORDER_BY_ENTITY_TABLE = "AssetTag.";
2420            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetTag exists with the primary key ";
2421            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetTag exists with the key {";
2422            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2423            private static Log _log = LogFactoryUtil.getLog(AssetTagPersistenceImpl.class);
2424            private static AssetTag _nullAssetTag = new AssetTagImpl() {
2425                            @Override
2426                            public Object clone() {
2427                                    return this;
2428                            }
2429    
2430                            @Override
2431                            public CacheModel<AssetTag> toCacheModel() {
2432                                    return _nullAssetTagCacheModel;
2433                            }
2434                    };
2435    
2436            private static CacheModel<AssetTag> _nullAssetTagCacheModel = new CacheModel<AssetTag>() {
2437                            public AssetTag toEntityModel() {
2438                                    return _nullAssetTag;
2439                            }
2440                    };
2441    }