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