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