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