001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.asset.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderPath;
028    import com.liferay.portal.kernel.dao.orm.Query;
029    import com.liferay.portal.kernel.dao.orm.QueryPos;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.SQLQuery;
032    import com.liferay.portal.kernel.dao.orm.Session;
033    import com.liferay.portal.kernel.exception.SystemException;
034    import com.liferay.portal.kernel.log.Log;
035    import com.liferay.portal.kernel.log.LogFactoryUtil;
036    import com.liferay.portal.kernel.util.CalendarUtil;
037    import com.liferay.portal.kernel.util.GetterUtil;
038    import com.liferay.portal.kernel.util.InstanceFactory;
039    import com.liferay.portal.kernel.util.OrderByComparator;
040    import com.liferay.portal.kernel.util.SetUtil;
041    import com.liferay.portal.kernel.util.StringBundler;
042    import com.liferay.portal.kernel.util.StringPool;
043    import com.liferay.portal.kernel.util.StringUtil;
044    import com.liferay.portal.kernel.util.Validator;
045    import com.liferay.portal.model.CacheModel;
046    import com.liferay.portal.model.ModelListener;
047    import com.liferay.portal.service.persistence.BatchSessionUtil;
048    import com.liferay.portal.service.persistence.CompanyPersistence;
049    import com.liferay.portal.service.persistence.GroupPersistence;
050    import com.liferay.portal.service.persistence.ResourcePersistence;
051    import com.liferay.portal.service.persistence.UserPersistence;
052    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
053    
054    import com.liferay.portlet.asset.NoSuchEntryException;
055    import com.liferay.portlet.asset.model.AssetEntry;
056    import com.liferay.portlet.asset.model.impl.AssetEntryImpl;
057    import com.liferay.portlet.asset.model.impl.AssetEntryModelImpl;
058    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
059    import com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence;
060    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
061    import com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence;
062    import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
063    import com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence;
064    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
065    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
066    import com.liferay.portlet.wiki.service.persistence.WikiPagePersistence;
067    import com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence;
068    
069    import java.io.Serializable;
070    
071    import java.util.ArrayList;
072    import java.util.Collections;
073    import java.util.Date;
074    import java.util.List;
075    import java.util.Set;
076    
077    /**
078     * The persistence implementation for the asset entry service.
079     *
080     * <p>
081     * Caching information and settings can be found in <code>portal.properties</code>
082     * </p>
083     *
084     * @author Brian Wing Shun Chan
085     * @see AssetEntryPersistence
086     * @see AssetEntryUtil
087     * @generated
088     */
089    public class AssetEntryPersistenceImpl extends BasePersistenceImpl<AssetEntry>
090            implements AssetEntryPersistence {
091            /*
092             * NOTE FOR DEVELOPERS:
093             *
094             * Never modify or reference this class directly. Always use {@link AssetEntryUtil} to access the asset entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
095             */
096            public static final String FINDER_CLASS_NAME_ENTITY = AssetEntryImpl.class.getName();
097            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
098                    ".List1";
099            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
100                    ".List2";
101            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
102                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
103                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
104                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
105                            new String[] {
106                                    Long.class.getName(),
107                                    
108                            "java.lang.Integer", "java.lang.Integer",
109                                    "com.liferay.portal.kernel.util.OrderByComparator"
110                            });
111            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
112                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
113                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
115                            new String[] { Long.class.getName() },
116                            AssetEntryModelImpl.COMPANYID_COLUMN_BITMASK);
117            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
118                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
119                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
120                            new String[] { Long.class.getName() });
121            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
122                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
123                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVisible",
124                            new String[] {
125                                    Boolean.class.getName(),
126                                    
127                            "java.lang.Integer", "java.lang.Integer",
128                                    "com.liferay.portal.kernel.util.OrderByComparator"
129                            });
130            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE =
131                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
132                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
133                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVisible",
134                            new String[] { Boolean.class.getName() },
135                            AssetEntryModelImpl.VISIBLE_COLUMN_BITMASK);
136            public static final FinderPath FINDER_PATH_COUNT_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
137                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
138                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVisible",
139                            new String[] { Boolean.class.getName() });
140            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE =
141                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
142                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
143                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPublishDate",
144                            new String[] {
145                                    Date.class.getName(),
146                                    
147                            "java.lang.Integer", "java.lang.Integer",
148                                    "com.liferay.portal.kernel.util.OrderByComparator"
149                            });
150            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE =
151                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
152                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPublishDate",
154                            new String[] { Date.class.getName() },
155                            AssetEntryModelImpl.PUBLISHDATE_COLUMN_BITMASK);
156            public static final FinderPath FINDER_PATH_COUNT_BY_PUBLISHDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
157                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
158                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPublishDate",
159                            new String[] { Date.class.getName() });
160            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE =
161                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
162                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
163                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByExpirationDate",
164                            new String[] {
165                                    Date.class.getName(),
166                                    
167                            "java.lang.Integer", "java.lang.Integer",
168                                    "com.liferay.portal.kernel.util.OrderByComparator"
169                            });
170            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE =
171                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
172                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
173                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByExpirationDate",
174                            new String[] { Date.class.getName() },
175                            AssetEntryModelImpl.EXPIRATIONDATE_COLUMN_BITMASK);
176            public static final FinderPath FINDER_PATH_COUNT_BY_EXPIRATIONDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
177                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
178                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByExpirationDate",
179                            new String[] { Date.class.getName() });
180            public static final FinderPath FINDER_PATH_FETCH_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
181                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
182                            FINDER_CLASS_NAME_ENTITY, "fetchByG_CU",
183                            new String[] { Long.class.getName(), String.class.getName() },
184                            AssetEntryModelImpl.GROUPID_COLUMN_BITMASK |
185                            AssetEntryModelImpl.CLASSUUID_COLUMN_BITMASK);
186            public static final FinderPath FINDER_PATH_COUNT_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
187                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
188                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_CU",
189                            new String[] { Long.class.getName(), String.class.getName() });
190            public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
191                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
192                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
193                            new String[] { Long.class.getName(), Long.class.getName() },
194                            AssetEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
195                            AssetEntryModelImpl.CLASSPK_COLUMN_BITMASK);
196            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
197                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
198                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
199                            new String[] { Long.class.getName(), Long.class.getName() });
200            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
201                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
202                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
203            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
204                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
205                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
206            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
207                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
208                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
209    
210            /**
211             * Caches the asset entry in the entity cache if it is enabled.
212             *
213             * @param assetEntry the asset entry
214             */
215            public void cacheResult(AssetEntry assetEntry) {
216                    EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
217                            AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
218    
219                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
220                            new Object[] {
221                                    Long.valueOf(assetEntry.getGroupId()),
222                                    
223                            assetEntry.getClassUuid()
224                            }, assetEntry);
225    
226                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
227                            new Object[] {
228                                    Long.valueOf(assetEntry.getClassNameId()),
229                                    Long.valueOf(assetEntry.getClassPK())
230                            }, assetEntry);
231    
232                    assetEntry.resetOriginalValues();
233            }
234    
235            /**
236             * Caches the asset entries in the entity cache if it is enabled.
237             *
238             * @param assetEntries the asset entries
239             */
240            public void cacheResult(List<AssetEntry> assetEntries) {
241                    for (AssetEntry assetEntry : assetEntries) {
242                            if (EntityCacheUtil.getResult(
243                                                    AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
244                                                    AssetEntryImpl.class, assetEntry.getPrimaryKey()) == null) {
245                                    cacheResult(assetEntry);
246                            }
247                            else {
248                                    assetEntry.resetOriginalValues();
249                            }
250                    }
251            }
252    
253            /**
254             * Clears the cache for all asset entries.
255             *
256             * <p>
257             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
258             * </p>
259             */
260            @Override
261            public void clearCache() {
262                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
263                            CacheRegistryUtil.clear(AssetEntryImpl.class.getName());
264                    }
265    
266                    EntityCacheUtil.clearCache(AssetEntryImpl.class.getName());
267    
268                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
269                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
270                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
271            }
272    
273            /**
274             * Clears the cache for the asset entry.
275             *
276             * <p>
277             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
278             * </p>
279             */
280            @Override
281            public void clearCache(AssetEntry assetEntry) {
282                    EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
283                            AssetEntryImpl.class, assetEntry.getPrimaryKey());
284    
285                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
286                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
287    
288                    clearUniqueFindersCache(assetEntry);
289            }
290    
291            @Override
292            public void clearCache(List<AssetEntry> assetEntries) {
293                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
294                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
295    
296                    for (AssetEntry assetEntry : assetEntries) {
297                            EntityCacheUtil.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
298                                    AssetEntryImpl.class, assetEntry.getPrimaryKey());
299    
300                            clearUniqueFindersCache(assetEntry);
301                    }
302            }
303    
304            protected void clearUniqueFindersCache(AssetEntry assetEntry) {
305                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
306                            new Object[] {
307                                    Long.valueOf(assetEntry.getGroupId()),
308                                    
309                            assetEntry.getClassUuid()
310                            });
311    
312                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
313                            new Object[] {
314                                    Long.valueOf(assetEntry.getClassNameId()),
315                                    Long.valueOf(assetEntry.getClassPK())
316                            });
317            }
318    
319            /**
320             * Creates a new asset entry with the primary key. Does not add the asset entry to the database.
321             *
322             * @param entryId the primary key for the new asset entry
323             * @return the new asset entry
324             */
325            public AssetEntry create(long entryId) {
326                    AssetEntry assetEntry = new AssetEntryImpl();
327    
328                    assetEntry.setNew(true);
329                    assetEntry.setPrimaryKey(entryId);
330    
331                    return assetEntry;
332            }
333    
334            /**
335             * Removes the asset entry with the primary key from the database. Also notifies the appropriate model listeners.
336             *
337             * @param entryId the primary key of the asset entry
338             * @return the asset entry that was removed
339             * @throws com.liferay.portlet.asset.NoSuchEntryException if a asset entry with the primary key could not be found
340             * @throws SystemException if a system exception occurred
341             */
342            public AssetEntry remove(long entryId)
343                    throws NoSuchEntryException, SystemException {
344                    return remove(Long.valueOf(entryId));
345            }
346    
347            /**
348             * Removes the asset entry with the primary key from the database. Also notifies the appropriate model listeners.
349             *
350             * @param primaryKey the primary key of the asset entry
351             * @return the asset entry that was removed
352             * @throws com.liferay.portlet.asset.NoSuchEntryException if a asset entry with the primary key could not be found
353             * @throws SystemException if a system exception occurred
354             */
355            @Override
356            public AssetEntry remove(Serializable primaryKey)
357                    throws NoSuchEntryException, SystemException {
358                    Session session = null;
359    
360                    try {
361                            session = openSession();
362    
363                            AssetEntry assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
364                                            primaryKey);
365    
366                            if (assetEntry == null) {
367                                    if (_log.isWarnEnabled()) {
368                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
369                                    }
370    
371                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
372                                            primaryKey);
373                            }
374    
375                            return remove(assetEntry);
376                    }
377                    catch (NoSuchEntryException nsee) {
378                            throw nsee;
379                    }
380                    catch (Exception e) {
381                            throw processException(e);
382                    }
383                    finally {
384                            closeSession(session);
385                    }
386            }
387    
388            @Override
389            protected AssetEntry removeImpl(AssetEntry assetEntry)
390                    throws SystemException {
391                    assetEntry = toUnwrappedModel(assetEntry);
392    
393                    try {
394                            clearAssetCategories.clear(assetEntry.getPrimaryKey());
395                    }
396                    catch (Exception e) {
397                            throw processException(e);
398                    }
399                    finally {
400                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
401                    }
402    
403                    try {
404                            clearAssetTags.clear(assetEntry.getPrimaryKey());
405                    }
406                    catch (Exception e) {
407                            throw processException(e);
408                    }
409                    finally {
410                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
411                    }
412    
413                    Session session = null;
414    
415                    try {
416                            session = openSession();
417    
418                            BatchSessionUtil.delete(session, assetEntry);
419                    }
420                    catch (Exception e) {
421                            throw processException(e);
422                    }
423                    finally {
424                            closeSession(session);
425                    }
426    
427                    clearCache(assetEntry);
428    
429                    return assetEntry;
430            }
431    
432            @Override
433            public AssetEntry updateImpl(
434                    com.liferay.portlet.asset.model.AssetEntry assetEntry, boolean merge)
435                    throws SystemException {
436                    assetEntry = toUnwrappedModel(assetEntry);
437    
438                    boolean isNew = assetEntry.isNew();
439    
440                    AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
441    
442                    Session session = null;
443    
444                    try {
445                            session = openSession();
446    
447                            BatchSessionUtil.update(session, assetEntry, merge);
448    
449                            assetEntry.setNew(false);
450                    }
451                    catch (Exception e) {
452                            throw processException(e);
453                    }
454                    finally {
455                            closeSession(session);
456                    }
457    
458                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
459    
460                    if (isNew || !AssetEntryModelImpl.COLUMN_BITMASK_ENABLED) {
461                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
462                    }
463                    else {
464                            if ((assetEntryModelImpl.getColumnBitmask() &
465                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
466                                    Object[] args = new Object[] {
467                                                    Long.valueOf(assetEntryModelImpl.getOriginalCompanyId())
468                                            };
469    
470                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
471                                            args);
472                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
473                                            args);
474    
475                                    args = new Object[] {
476                                                    Long.valueOf(assetEntryModelImpl.getCompanyId())
477                                            };
478    
479                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
480                                            args);
481                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
482                                            args);
483                            }
484    
485                            if ((assetEntryModelImpl.getColumnBitmask() &
486                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE.getColumnBitmask()) != 0) {
487                                    Object[] args = new Object[] {
488                                                    Boolean.valueOf(assetEntryModelImpl.getOriginalVisible())
489                                            };
490    
491                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
492                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
493                                            args);
494    
495                                    args = new Object[] {
496                                                    Boolean.valueOf(assetEntryModelImpl.getVisible())
497                                            };
498    
499                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
500                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
501                                            args);
502                            }
503    
504                            if ((assetEntryModelImpl.getColumnBitmask() &
505                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE.getColumnBitmask()) != 0) {
506                                    Object[] args = new Object[] {
507                                                    assetEntryModelImpl.getOriginalPublishDate()
508                                            };
509    
510                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
511                                            args);
512                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
513                                            args);
514    
515                                    args = new Object[] { assetEntryModelImpl.getPublishDate() };
516    
517                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
518                                            args);
519                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
520                                            args);
521                            }
522    
523                            if ((assetEntryModelImpl.getColumnBitmask() &
524                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE.getColumnBitmask()) != 0) {
525                                    Object[] args = new Object[] {
526                                                    assetEntryModelImpl.getOriginalExpirationDate()
527                                            };
528    
529                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
530                                            args);
531                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
532                                            args);
533    
534                                    args = new Object[] { assetEntryModelImpl.getExpirationDate() };
535    
536                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
537                                            args);
538                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
539                                            args);
540                            }
541                    }
542    
543                    EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
544                            AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
545    
546                    if (isNew) {
547                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
548                                    new Object[] {
549                                            Long.valueOf(assetEntry.getGroupId()),
550                                            
551                                    assetEntry.getClassUuid()
552                                    }, assetEntry);
553    
554                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
555                                    new Object[] {
556                                            Long.valueOf(assetEntry.getClassNameId()),
557                                            Long.valueOf(assetEntry.getClassPK())
558                                    }, assetEntry);
559                    }
560                    else {
561                            if ((assetEntryModelImpl.getColumnBitmask() &
562                                            FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
563                                    Object[] args = new Object[] {
564                                                    Long.valueOf(assetEntryModelImpl.getOriginalGroupId()),
565                                                    
566                                                    assetEntryModelImpl.getOriginalClassUuid()
567                                            };
568    
569                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
570                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
571    
572                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
573                                            new Object[] {
574                                                    Long.valueOf(assetEntry.getGroupId()),
575                                                    
576                                            assetEntry.getClassUuid()
577                                            }, assetEntry);
578                            }
579    
580                            if ((assetEntryModelImpl.getColumnBitmask() &
581                                            FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
582                                    Object[] args = new Object[] {
583                                                    Long.valueOf(assetEntryModelImpl.getOriginalClassNameId()),
584                                                    Long.valueOf(assetEntryModelImpl.getOriginalClassPK())
585                                            };
586    
587                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
588                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
589    
590                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
591                                            new Object[] {
592                                                    Long.valueOf(assetEntry.getClassNameId()),
593                                                    Long.valueOf(assetEntry.getClassPK())
594                                            }, assetEntry);
595                            }
596                    }
597    
598                    return assetEntry;
599            }
600    
601            protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
602                    if (assetEntry instanceof AssetEntryImpl) {
603                            return assetEntry;
604                    }
605    
606                    AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
607    
608                    assetEntryImpl.setNew(assetEntry.isNew());
609                    assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
610    
611                    assetEntryImpl.setEntryId(assetEntry.getEntryId());
612                    assetEntryImpl.setGroupId(assetEntry.getGroupId());
613                    assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
614                    assetEntryImpl.setUserId(assetEntry.getUserId());
615                    assetEntryImpl.setUserName(assetEntry.getUserName());
616                    assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
617                    assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
618                    assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
619                    assetEntryImpl.setClassPK(assetEntry.getClassPK());
620                    assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
621                    assetEntryImpl.setClassTypeId(assetEntry.getClassTypeId());
622                    assetEntryImpl.setVisible(assetEntry.isVisible());
623                    assetEntryImpl.setStartDate(assetEntry.getStartDate());
624                    assetEntryImpl.setEndDate(assetEntry.getEndDate());
625                    assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
626                    assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
627                    assetEntryImpl.setMimeType(assetEntry.getMimeType());
628                    assetEntryImpl.setTitle(assetEntry.getTitle());
629                    assetEntryImpl.setDescription(assetEntry.getDescription());
630                    assetEntryImpl.setSummary(assetEntry.getSummary());
631                    assetEntryImpl.setUrl(assetEntry.getUrl());
632                    assetEntryImpl.setLayoutUuid(assetEntry.getLayoutUuid());
633                    assetEntryImpl.setHeight(assetEntry.getHeight());
634                    assetEntryImpl.setWidth(assetEntry.getWidth());
635                    assetEntryImpl.setPriority(assetEntry.getPriority());
636                    assetEntryImpl.setViewCount(assetEntry.getViewCount());
637    
638                    return assetEntryImpl;
639            }
640    
641            /**
642             * Returns the asset entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
643             *
644             * @param primaryKey the primary key of the asset entry
645             * @return the asset entry
646             * @throws com.liferay.portal.NoSuchModelException if a asset entry with the primary key could not be found
647             * @throws SystemException if a system exception occurred
648             */
649            @Override
650            public AssetEntry findByPrimaryKey(Serializable primaryKey)
651                    throws NoSuchModelException, SystemException {
652                    return findByPrimaryKey(((Long)primaryKey).longValue());
653            }
654    
655            /**
656             * Returns the asset entry with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchEntryException} if it could not be found.
657             *
658             * @param entryId the primary key of the asset entry
659             * @return the asset entry
660             * @throws com.liferay.portlet.asset.NoSuchEntryException if a asset entry with the primary key could not be found
661             * @throws SystemException if a system exception occurred
662             */
663            public AssetEntry findByPrimaryKey(long entryId)
664                    throws NoSuchEntryException, SystemException {
665                    AssetEntry assetEntry = fetchByPrimaryKey(entryId);
666    
667                    if (assetEntry == null) {
668                            if (_log.isWarnEnabled()) {
669                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
670                            }
671    
672                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
673                                    entryId);
674                    }
675    
676                    return assetEntry;
677            }
678    
679            /**
680             * Returns the asset entry with the primary key or returns <code>null</code> if it could not be found.
681             *
682             * @param primaryKey the primary key of the asset entry
683             * @return the asset entry, or <code>null</code> if a asset entry with the primary key could not be found
684             * @throws SystemException if a system exception occurred
685             */
686            @Override
687            public AssetEntry fetchByPrimaryKey(Serializable primaryKey)
688                    throws SystemException {
689                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
690            }
691    
692            /**
693             * Returns the asset entry with the primary key or returns <code>null</code> if it could not be found.
694             *
695             * @param entryId the primary key of the asset entry
696             * @return the asset entry, or <code>null</code> if a asset entry with the primary key could not be found
697             * @throws SystemException if a system exception occurred
698             */
699            public AssetEntry fetchByPrimaryKey(long entryId) throws SystemException {
700                    AssetEntry assetEntry = (AssetEntry)EntityCacheUtil.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
701                                    AssetEntryImpl.class, entryId);
702    
703                    if (assetEntry == _nullAssetEntry) {
704                            return null;
705                    }
706    
707                    if (assetEntry == null) {
708                            Session session = null;
709    
710                            boolean hasException = false;
711    
712                            try {
713                                    session = openSession();
714    
715                                    assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
716                                                    Long.valueOf(entryId));
717                            }
718                            catch (Exception e) {
719                                    hasException = true;
720    
721                                    throw processException(e);
722                            }
723                            finally {
724                                    if (assetEntry != null) {
725                                            cacheResult(assetEntry);
726                                    }
727                                    else if (!hasException) {
728                                            EntityCacheUtil.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
729                                                    AssetEntryImpl.class, entryId, _nullAssetEntry);
730                                    }
731    
732                                    closeSession(session);
733                            }
734                    }
735    
736                    return assetEntry;
737            }
738    
739            /**
740             * Returns all the asset entries where companyId = &#63;.
741             *
742             * @param companyId the company ID
743             * @return the matching asset entries
744             * @throws SystemException if a system exception occurred
745             */
746            public List<AssetEntry> findByCompanyId(long companyId)
747                    throws SystemException {
748                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
749                            null);
750            }
751    
752            /**
753             * Returns a range of all the asset entries where companyId = &#63;.
754             *
755             * <p>
756             * 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.
757             * </p>
758             *
759             * @param companyId the company ID
760             * @param start the lower bound of the range of asset entries
761             * @param end the upper bound of the range of asset entries (not inclusive)
762             * @return the range of matching asset entries
763             * @throws SystemException if a system exception occurred
764             */
765            public List<AssetEntry> findByCompanyId(long companyId, int start, int end)
766                    throws SystemException {
767                    return findByCompanyId(companyId, start, end, null);
768            }
769    
770            /**
771             * Returns an ordered range of all the asset entries where companyId = &#63;.
772             *
773             * <p>
774             * 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.
775             * </p>
776             *
777             * @param companyId the company ID
778             * @param start the lower bound of the range of asset entries
779             * @param end the upper bound of the range of asset entries (not inclusive)
780             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
781             * @return the ordered range of matching asset entries
782             * @throws SystemException if a system exception occurred
783             */
784            public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
785                    OrderByComparator orderByComparator) throws SystemException {
786                    FinderPath finderPath = null;
787                    Object[] finderArgs = null;
788    
789                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
790                                    (orderByComparator == null)) {
791                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
792                            finderArgs = new Object[] { companyId };
793                    }
794                    else {
795                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
796                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
797                    }
798    
799                    List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
800                                    finderArgs, this);
801    
802                    if ((list != null) && !list.isEmpty()) {
803                            for (AssetEntry assetEntry : list) {
804                                    if ((companyId != assetEntry.getCompanyId())) {
805                                            list = null;
806    
807                                            break;
808                                    }
809                            }
810                    }
811    
812                    if (list == null) {
813                            StringBundler query = null;
814    
815                            if (orderByComparator != null) {
816                                    query = new StringBundler(3 +
817                                                    (orderByComparator.getOrderByFields().length * 3));
818                            }
819                            else {
820                                    query = new StringBundler(2);
821                            }
822    
823                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
824    
825                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
826    
827                            if (orderByComparator != null) {
828                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
829                                            orderByComparator);
830                            }
831    
832                            String sql = query.toString();
833    
834                            Session session = null;
835    
836                            try {
837                                    session = openSession();
838    
839                                    Query q = session.createQuery(sql);
840    
841                                    QueryPos qPos = QueryPos.getInstance(q);
842    
843                                    qPos.add(companyId);
844    
845                                    list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
846                                                    end);
847                            }
848                            catch (Exception e) {
849                                    throw processException(e);
850                            }
851                            finally {
852                                    if (list == null) {
853                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
854                                    }
855                                    else {
856                                            cacheResult(list);
857    
858                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
859                                    }
860    
861                                    closeSession(session);
862                            }
863                    }
864    
865                    return list;
866            }
867    
868            /**
869             * Returns the first asset entry in the ordered set where companyId = &#63;.
870             *
871             * <p>
872             * 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.
873             * </p>
874             *
875             * @param companyId the company ID
876             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
877             * @return the first matching asset entry
878             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
879             * @throws SystemException if a system exception occurred
880             */
881            public AssetEntry findByCompanyId_First(long companyId,
882                    OrderByComparator orderByComparator)
883                    throws NoSuchEntryException, SystemException {
884                    List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
885                                    orderByComparator);
886    
887                    if (list.isEmpty()) {
888                            StringBundler msg = new StringBundler(4);
889    
890                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
891    
892                            msg.append("companyId=");
893                            msg.append(companyId);
894    
895                            msg.append(StringPool.CLOSE_CURLY_BRACE);
896    
897                            throw new NoSuchEntryException(msg.toString());
898                    }
899                    else {
900                            return list.get(0);
901                    }
902            }
903    
904            /**
905             * Returns the last asset entry in the ordered set where companyId = &#63;.
906             *
907             * <p>
908             * 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.
909             * </p>
910             *
911             * @param companyId the company ID
912             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
913             * @return the last matching asset entry
914             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
915             * @throws SystemException if a system exception occurred
916             */
917            public AssetEntry findByCompanyId_Last(long companyId,
918                    OrderByComparator orderByComparator)
919                    throws NoSuchEntryException, SystemException {
920                    int count = countByCompanyId(companyId);
921    
922                    List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
923                                    orderByComparator);
924    
925                    if (list.isEmpty()) {
926                            StringBundler msg = new StringBundler(4);
927    
928                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
929    
930                            msg.append("companyId=");
931                            msg.append(companyId);
932    
933                            msg.append(StringPool.CLOSE_CURLY_BRACE);
934    
935                            throw new NoSuchEntryException(msg.toString());
936                    }
937                    else {
938                            return list.get(0);
939                    }
940            }
941    
942            /**
943             * Returns the asset entries before and after the current asset entry in the ordered set where companyId = &#63;.
944             *
945             * <p>
946             * 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.
947             * </p>
948             *
949             * @param entryId the primary key of the current asset entry
950             * @param companyId the company ID
951             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
952             * @return the previous, current, and next asset entry
953             * @throws com.liferay.portlet.asset.NoSuchEntryException if a asset entry with the primary key could not be found
954             * @throws SystemException if a system exception occurred
955             */
956            public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
957                    long companyId, OrderByComparator orderByComparator)
958                    throws NoSuchEntryException, SystemException {
959                    AssetEntry assetEntry = findByPrimaryKey(entryId);
960    
961                    Session session = null;
962    
963                    try {
964                            session = openSession();
965    
966                            AssetEntry[] array = new AssetEntryImpl[3];
967    
968                            array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
969                                            companyId, orderByComparator, true);
970    
971                            array[1] = assetEntry;
972    
973                            array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
974                                            companyId, orderByComparator, false);
975    
976                            return array;
977                    }
978                    catch (Exception e) {
979                            throw processException(e);
980                    }
981                    finally {
982                            closeSession(session);
983                    }
984            }
985    
986            protected AssetEntry getByCompanyId_PrevAndNext(Session session,
987                    AssetEntry assetEntry, long companyId,
988                    OrderByComparator orderByComparator, boolean previous) {
989                    StringBundler query = null;
990    
991                    if (orderByComparator != null) {
992                            query = new StringBundler(6 +
993                                            (orderByComparator.getOrderByFields().length * 6));
994                    }
995                    else {
996                            query = new StringBundler(3);
997                    }
998    
999                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1000    
1001                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1002    
1003                    if (orderByComparator != null) {
1004                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1005    
1006                            if (orderByConditionFields.length > 0) {
1007                                    query.append(WHERE_AND);
1008                            }
1009    
1010                            for (int i = 0; i < orderByConditionFields.length; i++) {
1011                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1012                                    query.append(orderByConditionFields[i]);
1013    
1014                                    if ((i + 1) < orderByConditionFields.length) {
1015                                            if (orderByComparator.isAscending() ^ previous) {
1016                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1017                                            }
1018                                            else {
1019                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1020                                            }
1021                                    }
1022                                    else {
1023                                            if (orderByComparator.isAscending() ^ previous) {
1024                                                    query.append(WHERE_GREATER_THAN);
1025                                            }
1026                                            else {
1027                                                    query.append(WHERE_LESSER_THAN);
1028                                            }
1029                                    }
1030                            }
1031    
1032                            query.append(ORDER_BY_CLAUSE);
1033    
1034                            String[] orderByFields = orderByComparator.getOrderByFields();
1035    
1036                            for (int i = 0; i < orderByFields.length; i++) {
1037                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1038                                    query.append(orderByFields[i]);
1039    
1040                                    if ((i + 1) < orderByFields.length) {
1041                                            if (orderByComparator.isAscending() ^ previous) {
1042                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1043                                            }
1044                                            else {
1045                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1046                                            }
1047                                    }
1048                                    else {
1049                                            if (orderByComparator.isAscending() ^ previous) {
1050                                                    query.append(ORDER_BY_ASC);
1051                                            }
1052                                            else {
1053                                                    query.append(ORDER_BY_DESC);
1054                                            }
1055                                    }
1056                            }
1057                    }
1058    
1059                    String sql = query.toString();
1060    
1061                    Query q = session.createQuery(sql);
1062    
1063                    q.setFirstResult(0);
1064                    q.setMaxResults(2);
1065    
1066                    QueryPos qPos = QueryPos.getInstance(q);
1067    
1068                    qPos.add(companyId);
1069    
1070                    if (orderByComparator != null) {
1071                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1072    
1073                            for (Object value : values) {
1074                                    qPos.add(value);
1075                            }
1076                    }
1077    
1078                    List<AssetEntry> list = q.list();
1079    
1080                    if (list.size() == 2) {
1081                            return list.get(1);
1082                    }
1083                    else {
1084                            return null;
1085                    }
1086            }
1087    
1088            /**
1089             * Returns all the asset entries where visible = &#63;.
1090             *
1091             * @param visible the visible
1092             * @return the matching asset entries
1093             * @throws SystemException if a system exception occurred
1094             */
1095            public List<AssetEntry> findByVisible(boolean visible)
1096                    throws SystemException {
1097                    return findByVisible(visible, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1098            }
1099    
1100            /**
1101             * Returns a range of all the asset entries where visible = &#63;.
1102             *
1103             * <p>
1104             * 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.
1105             * </p>
1106             *
1107             * @param visible the visible
1108             * @param start the lower bound of the range of asset entries
1109             * @param end the upper bound of the range of asset entries (not inclusive)
1110             * @return the range of matching asset entries
1111             * @throws SystemException if a system exception occurred
1112             */
1113            public List<AssetEntry> findByVisible(boolean visible, int start, int end)
1114                    throws SystemException {
1115                    return findByVisible(visible, start, end, null);
1116            }
1117    
1118            /**
1119             * Returns an ordered range of all the asset entries where visible = &#63;.
1120             *
1121             * <p>
1122             * 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.
1123             * </p>
1124             *
1125             * @param visible the visible
1126             * @param start the lower bound of the range of asset entries
1127             * @param end the upper bound of the range of asset entries (not inclusive)
1128             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1129             * @return the ordered range of matching asset entries
1130             * @throws SystemException if a system exception occurred
1131             */
1132            public List<AssetEntry> findByVisible(boolean visible, int start, int end,
1133                    OrderByComparator orderByComparator) throws SystemException {
1134                    FinderPath finderPath = null;
1135                    Object[] finderArgs = null;
1136    
1137                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1138                                    (orderByComparator == null)) {
1139                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE;
1140                            finderArgs = new Object[] { visible };
1141                    }
1142                    else {
1143                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE;
1144                            finderArgs = new Object[] { visible, start, end, orderByComparator };
1145                    }
1146    
1147                    List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1148                                    finderArgs, this);
1149    
1150                    if ((list != null) && !list.isEmpty()) {
1151                            for (AssetEntry assetEntry : list) {
1152                                    if ((visible != assetEntry.getVisible())) {
1153                                            list = null;
1154    
1155                                            break;
1156                                    }
1157                            }
1158                    }
1159    
1160                    if (list == null) {
1161                            StringBundler query = null;
1162    
1163                            if (orderByComparator != null) {
1164                                    query = new StringBundler(3 +
1165                                                    (orderByComparator.getOrderByFields().length * 3));
1166                            }
1167                            else {
1168                                    query = new StringBundler(2);
1169                            }
1170    
1171                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1172    
1173                            query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1174    
1175                            if (orderByComparator != null) {
1176                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1177                                            orderByComparator);
1178                            }
1179    
1180                            String sql = query.toString();
1181    
1182                            Session session = null;
1183    
1184                            try {
1185                                    session = openSession();
1186    
1187                                    Query q = session.createQuery(sql);
1188    
1189                                    QueryPos qPos = QueryPos.getInstance(q);
1190    
1191                                    qPos.add(visible);
1192    
1193                                    list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1194                                                    end);
1195                            }
1196                            catch (Exception e) {
1197                                    throw processException(e);
1198                            }
1199                            finally {
1200                                    if (list == null) {
1201                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1202                                    }
1203                                    else {
1204                                            cacheResult(list);
1205    
1206                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1207                                    }
1208    
1209                                    closeSession(session);
1210                            }
1211                    }
1212    
1213                    return list;
1214            }
1215    
1216            /**
1217             * Returns the first asset entry in the ordered set where visible = &#63;.
1218             *
1219             * <p>
1220             * 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.
1221             * </p>
1222             *
1223             * @param visible the visible
1224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1225             * @return the first matching asset entry
1226             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
1227             * @throws SystemException if a system exception occurred
1228             */
1229            public AssetEntry findByVisible_First(boolean visible,
1230                    OrderByComparator orderByComparator)
1231                    throws NoSuchEntryException, SystemException {
1232                    List<AssetEntry> list = findByVisible(visible, 0, 1, orderByComparator);
1233    
1234                    if (list.isEmpty()) {
1235                            StringBundler msg = new StringBundler(4);
1236    
1237                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1238    
1239                            msg.append("visible=");
1240                            msg.append(visible);
1241    
1242                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1243    
1244                            throw new NoSuchEntryException(msg.toString());
1245                    }
1246                    else {
1247                            return list.get(0);
1248                    }
1249            }
1250    
1251            /**
1252             * Returns the last asset entry in the ordered set where visible = &#63;.
1253             *
1254             * <p>
1255             * 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.
1256             * </p>
1257             *
1258             * @param visible the visible
1259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1260             * @return the last matching asset entry
1261             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
1262             * @throws SystemException if a system exception occurred
1263             */
1264            public AssetEntry findByVisible_Last(boolean visible,
1265                    OrderByComparator orderByComparator)
1266                    throws NoSuchEntryException, SystemException {
1267                    int count = countByVisible(visible);
1268    
1269                    List<AssetEntry> list = findByVisible(visible, count - 1, count,
1270                                    orderByComparator);
1271    
1272                    if (list.isEmpty()) {
1273                            StringBundler msg = new StringBundler(4);
1274    
1275                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1276    
1277                            msg.append("visible=");
1278                            msg.append(visible);
1279    
1280                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1281    
1282                            throw new NoSuchEntryException(msg.toString());
1283                    }
1284                    else {
1285                            return list.get(0);
1286                    }
1287            }
1288    
1289            /**
1290             * Returns the asset entries before and after the current asset entry in the ordered set where visible = &#63;.
1291             *
1292             * <p>
1293             * 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.
1294             * </p>
1295             *
1296             * @param entryId the primary key of the current asset entry
1297             * @param visible the visible
1298             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1299             * @return the previous, current, and next asset entry
1300             * @throws com.liferay.portlet.asset.NoSuchEntryException if a asset entry with the primary key could not be found
1301             * @throws SystemException if a system exception occurred
1302             */
1303            public AssetEntry[] findByVisible_PrevAndNext(long entryId,
1304                    boolean visible, OrderByComparator orderByComparator)
1305                    throws NoSuchEntryException, SystemException {
1306                    AssetEntry assetEntry = findByPrimaryKey(entryId);
1307    
1308                    Session session = null;
1309    
1310                    try {
1311                            session = openSession();
1312    
1313                            AssetEntry[] array = new AssetEntryImpl[3];
1314    
1315                            array[0] = getByVisible_PrevAndNext(session, assetEntry, visible,
1316                                            orderByComparator, true);
1317    
1318                            array[1] = assetEntry;
1319    
1320                            array[2] = getByVisible_PrevAndNext(session, assetEntry, visible,
1321                                            orderByComparator, false);
1322    
1323                            return array;
1324                    }
1325                    catch (Exception e) {
1326                            throw processException(e);
1327                    }
1328                    finally {
1329                            closeSession(session);
1330                    }
1331            }
1332    
1333            protected AssetEntry getByVisible_PrevAndNext(Session session,
1334                    AssetEntry assetEntry, boolean visible,
1335                    OrderByComparator orderByComparator, boolean previous) {
1336                    StringBundler query = null;
1337    
1338                    if (orderByComparator != null) {
1339                            query = new StringBundler(6 +
1340                                            (orderByComparator.getOrderByFields().length * 6));
1341                    }
1342                    else {
1343                            query = new StringBundler(3);
1344                    }
1345    
1346                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1347    
1348                    query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1349    
1350                    if (orderByComparator != null) {
1351                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1352    
1353                            if (orderByConditionFields.length > 0) {
1354                                    query.append(WHERE_AND);
1355                            }
1356    
1357                            for (int i = 0; i < orderByConditionFields.length; i++) {
1358                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1359                                    query.append(orderByConditionFields[i]);
1360    
1361                                    if ((i + 1) < orderByConditionFields.length) {
1362                                            if (orderByComparator.isAscending() ^ previous) {
1363                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1364                                            }
1365                                            else {
1366                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1367                                            }
1368                                    }
1369                                    else {
1370                                            if (orderByComparator.isAscending() ^ previous) {
1371                                                    query.append(WHERE_GREATER_THAN);
1372                                            }
1373                                            else {
1374                                                    query.append(WHERE_LESSER_THAN);
1375                                            }
1376                                    }
1377                            }
1378    
1379                            query.append(ORDER_BY_CLAUSE);
1380    
1381                            String[] orderByFields = orderByComparator.getOrderByFields();
1382    
1383                            for (int i = 0; i < orderByFields.length; i++) {
1384                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1385                                    query.append(orderByFields[i]);
1386    
1387                                    if ((i + 1) < orderByFields.length) {
1388                                            if (orderByComparator.isAscending() ^ previous) {
1389                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1390                                            }
1391                                            else {
1392                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1393                                            }
1394                                    }
1395                                    else {
1396                                            if (orderByComparator.isAscending() ^ previous) {
1397                                                    query.append(ORDER_BY_ASC);
1398                                            }
1399                                            else {
1400                                                    query.append(ORDER_BY_DESC);
1401                                            }
1402                                    }
1403                            }
1404                    }
1405    
1406                    String sql = query.toString();
1407    
1408                    Query q = session.createQuery(sql);
1409    
1410                    q.setFirstResult(0);
1411                    q.setMaxResults(2);
1412    
1413                    QueryPos qPos = QueryPos.getInstance(q);
1414    
1415                    qPos.add(visible);
1416    
1417                    if (orderByComparator != null) {
1418                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1419    
1420                            for (Object value : values) {
1421                                    qPos.add(value);
1422                            }
1423                    }
1424    
1425                    List<AssetEntry> list = q.list();
1426    
1427                    if (list.size() == 2) {
1428                            return list.get(1);
1429                    }
1430                    else {
1431                            return null;
1432                    }
1433            }
1434    
1435            /**
1436             * Returns all the asset entries where publishDate = &#63;.
1437             *
1438             * @param publishDate the publish date
1439             * @return the matching asset entries
1440             * @throws SystemException if a system exception occurred
1441             */
1442            public List<AssetEntry> findByPublishDate(Date publishDate)
1443                    throws SystemException {
1444                    return findByPublishDate(publishDate, QueryUtil.ALL_POS,
1445                            QueryUtil.ALL_POS, null);
1446            }
1447    
1448            /**
1449             * Returns a range of all the asset entries where publishDate = &#63;.
1450             *
1451             * <p>
1452             * 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.
1453             * </p>
1454             *
1455             * @param publishDate the publish date
1456             * @param start the lower bound of the range of asset entries
1457             * @param end the upper bound of the range of asset entries (not inclusive)
1458             * @return the range of matching asset entries
1459             * @throws SystemException if a system exception occurred
1460             */
1461            public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1462                    int end) throws SystemException {
1463                    return findByPublishDate(publishDate, start, end, null);
1464            }
1465    
1466            /**
1467             * Returns an ordered range of all the asset entries where publishDate = &#63;.
1468             *
1469             * <p>
1470             * 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.
1471             * </p>
1472             *
1473             * @param publishDate the publish date
1474             * @param start the lower bound of the range of asset entries
1475             * @param end the upper bound of the range of asset entries (not inclusive)
1476             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1477             * @return the ordered range of matching asset entries
1478             * @throws SystemException if a system exception occurred
1479             */
1480            public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1481                    int end, OrderByComparator orderByComparator) throws SystemException {
1482                    FinderPath finderPath = null;
1483                    Object[] finderArgs = null;
1484    
1485                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1486                                    (orderByComparator == null)) {
1487                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE;
1488                            finderArgs = new Object[] { publishDate };
1489                    }
1490                    else {
1491                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE;
1492                            finderArgs = new Object[] { publishDate, start, end, orderByComparator };
1493                    }
1494    
1495                    List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1496                                    finderArgs, this);
1497    
1498                    if ((list != null) && !list.isEmpty()) {
1499                            for (AssetEntry assetEntry : list) {
1500                                    if (!Validator.equals(publishDate, assetEntry.getPublishDate())) {
1501                                            list = null;
1502    
1503                                            break;
1504                                    }
1505                            }
1506                    }
1507    
1508                    if (list == null) {
1509                            StringBundler query = null;
1510    
1511                            if (orderByComparator != null) {
1512                                    query = new StringBundler(3 +
1513                                                    (orderByComparator.getOrderByFields().length * 3));
1514                            }
1515                            else {
1516                                    query = new StringBundler(2);
1517                            }
1518    
1519                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1520    
1521                            if (publishDate == null) {
1522                                    query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1523                            }
1524                            else {
1525                                    query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1526                            }
1527    
1528                            if (orderByComparator != null) {
1529                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1530                                            orderByComparator);
1531                            }
1532    
1533                            String sql = query.toString();
1534    
1535                            Session session = null;
1536    
1537                            try {
1538                                    session = openSession();
1539    
1540                                    Query q = session.createQuery(sql);
1541    
1542                                    QueryPos qPos = QueryPos.getInstance(q);
1543    
1544                                    if (publishDate != null) {
1545                                            qPos.add(CalendarUtil.getTimestamp(publishDate));
1546                                    }
1547    
1548                                    list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1549                                                    end);
1550                            }
1551                            catch (Exception e) {
1552                                    throw processException(e);
1553                            }
1554                            finally {
1555                                    if (list == null) {
1556                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1557                                    }
1558                                    else {
1559                                            cacheResult(list);
1560    
1561                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1562                                    }
1563    
1564                                    closeSession(session);
1565                            }
1566                    }
1567    
1568                    return list;
1569            }
1570    
1571            /**
1572             * Returns the first asset entry in the ordered set where publishDate = &#63;.
1573             *
1574             * <p>
1575             * 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.
1576             * </p>
1577             *
1578             * @param publishDate the publish date
1579             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1580             * @return the first matching asset entry
1581             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
1582             * @throws SystemException if a system exception occurred
1583             */
1584            public AssetEntry findByPublishDate_First(Date publishDate,
1585                    OrderByComparator orderByComparator)
1586                    throws NoSuchEntryException, SystemException {
1587                    List<AssetEntry> list = findByPublishDate(publishDate, 0, 1,
1588                                    orderByComparator);
1589    
1590                    if (list.isEmpty()) {
1591                            StringBundler msg = new StringBundler(4);
1592    
1593                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1594    
1595                            msg.append("publishDate=");
1596                            msg.append(publishDate);
1597    
1598                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1599    
1600                            throw new NoSuchEntryException(msg.toString());
1601                    }
1602                    else {
1603                            return list.get(0);
1604                    }
1605            }
1606    
1607            /**
1608             * Returns the last asset entry in the ordered set where publishDate = &#63;.
1609             *
1610             * <p>
1611             * 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.
1612             * </p>
1613             *
1614             * @param publishDate the publish date
1615             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1616             * @return the last matching asset entry
1617             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
1618             * @throws SystemException if a system exception occurred
1619             */
1620            public AssetEntry findByPublishDate_Last(Date publishDate,
1621                    OrderByComparator orderByComparator)
1622                    throws NoSuchEntryException, SystemException {
1623                    int count = countByPublishDate(publishDate);
1624    
1625                    List<AssetEntry> list = findByPublishDate(publishDate, count - 1,
1626                                    count, orderByComparator);
1627    
1628                    if (list.isEmpty()) {
1629                            StringBundler msg = new StringBundler(4);
1630    
1631                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1632    
1633                            msg.append("publishDate=");
1634                            msg.append(publishDate);
1635    
1636                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1637    
1638                            throw new NoSuchEntryException(msg.toString());
1639                    }
1640                    else {
1641                            return list.get(0);
1642                    }
1643            }
1644    
1645            /**
1646             * Returns the asset entries before and after the current asset entry in the ordered set where publishDate = &#63;.
1647             *
1648             * <p>
1649             * 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.
1650             * </p>
1651             *
1652             * @param entryId the primary key of the current asset entry
1653             * @param publishDate the publish date
1654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1655             * @return the previous, current, and next asset entry
1656             * @throws com.liferay.portlet.asset.NoSuchEntryException if a asset entry with the primary key could not be found
1657             * @throws SystemException if a system exception occurred
1658             */
1659            public AssetEntry[] findByPublishDate_PrevAndNext(long entryId,
1660                    Date publishDate, OrderByComparator orderByComparator)
1661                    throws NoSuchEntryException, SystemException {
1662                    AssetEntry assetEntry = findByPrimaryKey(entryId);
1663    
1664                    Session session = null;
1665    
1666                    try {
1667                            session = openSession();
1668    
1669                            AssetEntry[] array = new AssetEntryImpl[3];
1670    
1671                            array[0] = getByPublishDate_PrevAndNext(session, assetEntry,
1672                                            publishDate, orderByComparator, true);
1673    
1674                            array[1] = assetEntry;
1675    
1676                            array[2] = getByPublishDate_PrevAndNext(session, assetEntry,
1677                                            publishDate, orderByComparator, false);
1678    
1679                            return array;
1680                    }
1681                    catch (Exception e) {
1682                            throw processException(e);
1683                    }
1684                    finally {
1685                            closeSession(session);
1686                    }
1687            }
1688    
1689            protected AssetEntry getByPublishDate_PrevAndNext(Session session,
1690                    AssetEntry assetEntry, Date publishDate,
1691                    OrderByComparator orderByComparator, boolean previous) {
1692                    StringBundler query = null;
1693    
1694                    if (orderByComparator != null) {
1695                            query = new StringBundler(6 +
1696                                            (orderByComparator.getOrderByFields().length * 6));
1697                    }
1698                    else {
1699                            query = new StringBundler(3);
1700                    }
1701    
1702                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1703    
1704                    if (publishDate == null) {
1705                            query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1706                    }
1707                    else {
1708                            query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1709                    }
1710    
1711                    if (orderByComparator != null) {
1712                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1713    
1714                            if (orderByConditionFields.length > 0) {
1715                                    query.append(WHERE_AND);
1716                            }
1717    
1718                            for (int i = 0; i < orderByConditionFields.length; i++) {
1719                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1720                                    query.append(orderByConditionFields[i]);
1721    
1722                                    if ((i + 1) < orderByConditionFields.length) {
1723                                            if (orderByComparator.isAscending() ^ previous) {
1724                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1725                                            }
1726                                            else {
1727                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1728                                            }
1729                                    }
1730                                    else {
1731                                            if (orderByComparator.isAscending() ^ previous) {
1732                                                    query.append(WHERE_GREATER_THAN);
1733                                            }
1734                                            else {
1735                                                    query.append(WHERE_LESSER_THAN);
1736                                            }
1737                                    }
1738                            }
1739    
1740                            query.append(ORDER_BY_CLAUSE);
1741    
1742                            String[] orderByFields = orderByComparator.getOrderByFields();
1743    
1744                            for (int i = 0; i < orderByFields.length; i++) {
1745                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1746                                    query.append(orderByFields[i]);
1747    
1748                                    if ((i + 1) < orderByFields.length) {
1749                                            if (orderByComparator.isAscending() ^ previous) {
1750                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1751                                            }
1752                                            else {
1753                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1754                                            }
1755                                    }
1756                                    else {
1757                                            if (orderByComparator.isAscending() ^ previous) {
1758                                                    query.append(ORDER_BY_ASC);
1759                                            }
1760                                            else {
1761                                                    query.append(ORDER_BY_DESC);
1762                                            }
1763                                    }
1764                            }
1765                    }
1766    
1767                    String sql = query.toString();
1768    
1769                    Query q = session.createQuery(sql);
1770    
1771                    q.setFirstResult(0);
1772                    q.setMaxResults(2);
1773    
1774                    QueryPos qPos = QueryPos.getInstance(q);
1775    
1776                    if (publishDate != null) {
1777                            qPos.add(CalendarUtil.getTimestamp(publishDate));
1778                    }
1779    
1780                    if (orderByComparator != null) {
1781                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1782    
1783                            for (Object value : values) {
1784                                    qPos.add(value);
1785                            }
1786                    }
1787    
1788                    List<AssetEntry> list = q.list();
1789    
1790                    if (list.size() == 2) {
1791                            return list.get(1);
1792                    }
1793                    else {
1794                            return null;
1795                    }
1796            }
1797    
1798            /**
1799             * Returns all the asset entries where expirationDate = &#63;.
1800             *
1801             * @param expirationDate the expiration date
1802             * @return the matching asset entries
1803             * @throws SystemException if a system exception occurred
1804             */
1805            public List<AssetEntry> findByExpirationDate(Date expirationDate)
1806                    throws SystemException {
1807                    return findByExpirationDate(expirationDate, QueryUtil.ALL_POS,
1808                            QueryUtil.ALL_POS, null);
1809            }
1810    
1811            /**
1812             * Returns a range of all the asset entries where expirationDate = &#63;.
1813             *
1814             * <p>
1815             * 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.
1816             * </p>
1817             *
1818             * @param expirationDate the expiration date
1819             * @param start the lower bound of the range of asset entries
1820             * @param end the upper bound of the range of asset entries (not inclusive)
1821             * @return the range of matching asset entries
1822             * @throws SystemException if a system exception occurred
1823             */
1824            public List<AssetEntry> findByExpirationDate(Date expirationDate,
1825                    int start, int end) throws SystemException {
1826                    return findByExpirationDate(expirationDate, start, end, null);
1827            }
1828    
1829            /**
1830             * Returns an ordered range of all the asset entries where expirationDate = &#63;.
1831             *
1832             * <p>
1833             * 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.
1834             * </p>
1835             *
1836             * @param expirationDate the expiration date
1837             * @param start the lower bound of the range of asset entries
1838             * @param end the upper bound of the range of asset entries (not inclusive)
1839             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1840             * @return the ordered range of matching asset entries
1841             * @throws SystemException if a system exception occurred
1842             */
1843            public List<AssetEntry> findByExpirationDate(Date expirationDate,
1844                    int start, int end, OrderByComparator orderByComparator)
1845                    throws SystemException {
1846                    FinderPath finderPath = null;
1847                    Object[] finderArgs = null;
1848    
1849                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1850                                    (orderByComparator == null)) {
1851                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE;
1852                            finderArgs = new Object[] { expirationDate };
1853                    }
1854                    else {
1855                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE;
1856                            finderArgs = new Object[] {
1857                                            expirationDate,
1858                                            
1859                                            start, end, orderByComparator
1860                                    };
1861                    }
1862    
1863                    List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
1864                                    finderArgs, this);
1865    
1866                    if ((list != null) && !list.isEmpty()) {
1867                            for (AssetEntry assetEntry : list) {
1868                                    if (!Validator.equals(expirationDate,
1869                                                            assetEntry.getExpirationDate())) {
1870                                            list = null;
1871    
1872                                            break;
1873                                    }
1874                            }
1875                    }
1876    
1877                    if (list == null) {
1878                            StringBundler query = null;
1879    
1880                            if (orderByComparator != null) {
1881                                    query = new StringBundler(3 +
1882                                                    (orderByComparator.getOrderByFields().length * 3));
1883                            }
1884                            else {
1885                                    query = new StringBundler(2);
1886                            }
1887    
1888                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1889    
1890                            if (expirationDate == null) {
1891                                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
1892                            }
1893                            else {
1894                                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
1895                            }
1896    
1897                            if (orderByComparator != null) {
1898                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1899                                            orderByComparator);
1900                            }
1901    
1902                            String sql = query.toString();
1903    
1904                            Session session = null;
1905    
1906                            try {
1907                                    session = openSession();
1908    
1909                                    Query q = session.createQuery(sql);
1910    
1911                                    QueryPos qPos = QueryPos.getInstance(q);
1912    
1913                                    if (expirationDate != null) {
1914                                            qPos.add(CalendarUtil.getTimestamp(expirationDate));
1915                                    }
1916    
1917                                    list = (List<AssetEntry>)QueryUtil.list(q, getDialect(), start,
1918                                                    end);
1919                            }
1920                            catch (Exception e) {
1921                                    throw processException(e);
1922                            }
1923                            finally {
1924                                    if (list == null) {
1925                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1926                                    }
1927                                    else {
1928                                            cacheResult(list);
1929    
1930                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1931                                    }
1932    
1933                                    closeSession(session);
1934                            }
1935                    }
1936    
1937                    return list;
1938            }
1939    
1940            /**
1941             * Returns the first asset entry in the ordered set where expirationDate = &#63;.
1942             *
1943             * <p>
1944             * 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.
1945             * </p>
1946             *
1947             * @param expirationDate the expiration date
1948             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1949             * @return the first matching asset entry
1950             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
1951             * @throws SystemException if a system exception occurred
1952             */
1953            public AssetEntry findByExpirationDate_First(Date expirationDate,
1954                    OrderByComparator orderByComparator)
1955                    throws NoSuchEntryException, SystemException {
1956                    List<AssetEntry> list = findByExpirationDate(expirationDate, 0, 1,
1957                                    orderByComparator);
1958    
1959                    if (list.isEmpty()) {
1960                            StringBundler msg = new StringBundler(4);
1961    
1962                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1963    
1964                            msg.append("expirationDate=");
1965                            msg.append(expirationDate);
1966    
1967                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1968    
1969                            throw new NoSuchEntryException(msg.toString());
1970                    }
1971                    else {
1972                            return list.get(0);
1973                    }
1974            }
1975    
1976            /**
1977             * Returns the last asset entry in the ordered set where expirationDate = &#63;.
1978             *
1979             * <p>
1980             * 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.
1981             * </p>
1982             *
1983             * @param expirationDate the expiration date
1984             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1985             * @return the last matching asset entry
1986             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
1987             * @throws SystemException if a system exception occurred
1988             */
1989            public AssetEntry findByExpirationDate_Last(Date expirationDate,
1990                    OrderByComparator orderByComparator)
1991                    throws NoSuchEntryException, SystemException {
1992                    int count = countByExpirationDate(expirationDate);
1993    
1994                    List<AssetEntry> list = findByExpirationDate(expirationDate, count - 1,
1995                                    count, orderByComparator);
1996    
1997                    if (list.isEmpty()) {
1998                            StringBundler msg = new StringBundler(4);
1999    
2000                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2001    
2002                            msg.append("expirationDate=");
2003                            msg.append(expirationDate);
2004    
2005                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2006    
2007                            throw new NoSuchEntryException(msg.toString());
2008                    }
2009                    else {
2010                            return list.get(0);
2011                    }
2012            }
2013    
2014            /**
2015             * Returns the asset entries before and after the current asset entry in the ordered set where expirationDate = &#63;.
2016             *
2017             * <p>
2018             * 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.
2019             * </p>
2020             *
2021             * @param entryId the primary key of the current asset entry
2022             * @param expirationDate the expiration date
2023             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2024             * @return the previous, current, and next asset entry
2025             * @throws com.liferay.portlet.asset.NoSuchEntryException if a asset entry with the primary key could not be found
2026             * @throws SystemException if a system exception occurred
2027             */
2028            public AssetEntry[] findByExpirationDate_PrevAndNext(long entryId,
2029                    Date expirationDate, OrderByComparator orderByComparator)
2030                    throws NoSuchEntryException, SystemException {
2031                    AssetEntry assetEntry = findByPrimaryKey(entryId);
2032    
2033                    Session session = null;
2034    
2035                    try {
2036                            session = openSession();
2037    
2038                            AssetEntry[] array = new AssetEntryImpl[3];
2039    
2040                            array[0] = getByExpirationDate_PrevAndNext(session, assetEntry,
2041                                            expirationDate, orderByComparator, true);
2042    
2043                            array[1] = assetEntry;
2044    
2045                            array[2] = getByExpirationDate_PrevAndNext(session, assetEntry,
2046                                            expirationDate, orderByComparator, false);
2047    
2048                            return array;
2049                    }
2050                    catch (Exception e) {
2051                            throw processException(e);
2052                    }
2053                    finally {
2054                            closeSession(session);
2055                    }
2056            }
2057    
2058            protected AssetEntry getByExpirationDate_PrevAndNext(Session session,
2059                    AssetEntry assetEntry, Date expirationDate,
2060                    OrderByComparator orderByComparator, boolean previous) {
2061                    StringBundler query = null;
2062    
2063                    if (orderByComparator != null) {
2064                            query = new StringBundler(6 +
2065                                            (orderByComparator.getOrderByFields().length * 6));
2066                    }
2067                    else {
2068                            query = new StringBundler(3);
2069                    }
2070    
2071                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2072    
2073                    if (expirationDate == null) {
2074                            query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2075                    }
2076                    else {
2077                            query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2078                    }
2079    
2080                    if (orderByComparator != null) {
2081                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2082    
2083                            if (orderByConditionFields.length > 0) {
2084                                    query.append(WHERE_AND);
2085                            }
2086    
2087                            for (int i = 0; i < orderByConditionFields.length; i++) {
2088                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2089                                    query.append(orderByConditionFields[i]);
2090    
2091                                    if ((i + 1) < orderByConditionFields.length) {
2092                                            if (orderByComparator.isAscending() ^ previous) {
2093                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2094                                            }
2095                                            else {
2096                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2097                                            }
2098                                    }
2099                                    else {
2100                                            if (orderByComparator.isAscending() ^ previous) {
2101                                                    query.append(WHERE_GREATER_THAN);
2102                                            }
2103                                            else {
2104                                                    query.append(WHERE_LESSER_THAN);
2105                                            }
2106                                    }
2107                            }
2108    
2109                            query.append(ORDER_BY_CLAUSE);
2110    
2111                            String[] orderByFields = orderByComparator.getOrderByFields();
2112    
2113                            for (int i = 0; i < orderByFields.length; i++) {
2114                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2115                                    query.append(orderByFields[i]);
2116    
2117                                    if ((i + 1) < orderByFields.length) {
2118                                            if (orderByComparator.isAscending() ^ previous) {
2119                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2120                                            }
2121                                            else {
2122                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2123                                            }
2124                                    }
2125                                    else {
2126                                            if (orderByComparator.isAscending() ^ previous) {
2127                                                    query.append(ORDER_BY_ASC);
2128                                            }
2129                                            else {
2130                                                    query.append(ORDER_BY_DESC);
2131                                            }
2132                                    }
2133                            }
2134                    }
2135    
2136                    String sql = query.toString();
2137    
2138                    Query q = session.createQuery(sql);
2139    
2140                    q.setFirstResult(0);
2141                    q.setMaxResults(2);
2142    
2143                    QueryPos qPos = QueryPos.getInstance(q);
2144    
2145                    if (expirationDate != null) {
2146                            qPos.add(CalendarUtil.getTimestamp(expirationDate));
2147                    }
2148    
2149                    if (orderByComparator != null) {
2150                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
2151    
2152                            for (Object value : values) {
2153                                    qPos.add(value);
2154                            }
2155                    }
2156    
2157                    List<AssetEntry> list = q.list();
2158    
2159                    if (list.size() == 2) {
2160                            return list.get(1);
2161                    }
2162                    else {
2163                            return null;
2164                    }
2165            }
2166    
2167            /**
2168             * Returns the asset entry where groupId = &#63; and classUuid = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchEntryException} if it could not be found.
2169             *
2170             * @param groupId the group ID
2171             * @param classUuid the class uuid
2172             * @return the matching asset entry
2173             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
2174             * @throws SystemException if a system exception occurred
2175             */
2176            public AssetEntry findByG_CU(long groupId, String classUuid)
2177                    throws NoSuchEntryException, SystemException {
2178                    AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
2179    
2180                    if (assetEntry == null) {
2181                            StringBundler msg = new StringBundler(6);
2182    
2183                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2184    
2185                            msg.append("groupId=");
2186                            msg.append(groupId);
2187    
2188                            msg.append(", classUuid=");
2189                            msg.append(classUuid);
2190    
2191                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2192    
2193                            if (_log.isWarnEnabled()) {
2194                                    _log.warn(msg.toString());
2195                            }
2196    
2197                            throw new NoSuchEntryException(msg.toString());
2198                    }
2199    
2200                    return assetEntry;
2201            }
2202    
2203            /**
2204             * Returns the asset entry where groupId = &#63; and classUuid = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2205             *
2206             * @param groupId the group ID
2207             * @param classUuid the class uuid
2208             * @return the matching asset entry, or <code>null</code> if a matching asset entry could not be found
2209             * @throws SystemException if a system exception occurred
2210             */
2211            public AssetEntry fetchByG_CU(long groupId, String classUuid)
2212                    throws SystemException {
2213                    return fetchByG_CU(groupId, classUuid, true);
2214            }
2215    
2216            /**
2217             * Returns the asset entry where groupId = &#63; and classUuid = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2218             *
2219             * @param groupId the group ID
2220             * @param classUuid the class uuid
2221             * @param retrieveFromCache whether to use the finder cache
2222             * @return the matching asset entry, or <code>null</code> if a matching asset entry could not be found
2223             * @throws SystemException if a system exception occurred
2224             */
2225            public AssetEntry fetchByG_CU(long groupId, String classUuid,
2226                    boolean retrieveFromCache) throws SystemException {
2227                    Object[] finderArgs = new Object[] { groupId, classUuid };
2228    
2229                    Object result = null;
2230    
2231                    if (retrieveFromCache) {
2232                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_CU,
2233                                            finderArgs, this);
2234                    }
2235    
2236                    if (result instanceof AssetEntry) {
2237                            AssetEntry assetEntry = (AssetEntry)result;
2238    
2239                            if ((groupId != assetEntry.getGroupId()) ||
2240                                            !Validator.equals(classUuid, assetEntry.getClassUuid())) {
2241                                    result = null;
2242                            }
2243                    }
2244    
2245                    if (result == null) {
2246                            StringBundler query = new StringBundler(3);
2247    
2248                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2249    
2250                            query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2251    
2252                            if (classUuid == null) {
2253                                    query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2254                            }
2255                            else {
2256                                    if (classUuid.equals(StringPool.BLANK)) {
2257                                            query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2258                                    }
2259                                    else {
2260                                            query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2261                                    }
2262                            }
2263    
2264                            String sql = query.toString();
2265    
2266                            Session session = null;
2267    
2268                            try {
2269                                    session = openSession();
2270    
2271                                    Query q = session.createQuery(sql);
2272    
2273                                    QueryPos qPos = QueryPos.getInstance(q);
2274    
2275                                    qPos.add(groupId);
2276    
2277                                    if (classUuid != null) {
2278                                            qPos.add(classUuid);
2279                                    }
2280    
2281                                    List<AssetEntry> list = q.list();
2282    
2283                                    result = list;
2284    
2285                                    AssetEntry assetEntry = null;
2286    
2287                                    if (list.isEmpty()) {
2288                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2289                                                    finderArgs, list);
2290                                    }
2291                                    else {
2292                                            assetEntry = list.get(0);
2293    
2294                                            cacheResult(assetEntry);
2295    
2296                                            if ((assetEntry.getGroupId() != groupId) ||
2297                                                            (assetEntry.getClassUuid() == null) ||
2298                                                            !assetEntry.getClassUuid().equals(classUuid)) {
2299                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_CU,
2300                                                            finderArgs, assetEntry);
2301                                            }
2302                                    }
2303    
2304                                    return assetEntry;
2305                            }
2306                            catch (Exception e) {
2307                                    throw processException(e);
2308                            }
2309                            finally {
2310                                    if (result == null) {
2311                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_CU,
2312                                                    finderArgs);
2313                                    }
2314    
2315                                    closeSession(session);
2316                            }
2317                    }
2318                    else {
2319                            if (result instanceof List<?>) {
2320                                    return null;
2321                            }
2322                            else {
2323                                    return (AssetEntry)result;
2324                            }
2325                    }
2326            }
2327    
2328            /**
2329             * Returns the asset entry where classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchEntryException} if it could not be found.
2330             *
2331             * @param classNameId the class name ID
2332             * @param classPK the class p k
2333             * @return the matching asset entry
2334             * @throws com.liferay.portlet.asset.NoSuchEntryException if a matching asset entry could not be found
2335             * @throws SystemException if a system exception occurred
2336             */
2337            public AssetEntry findByC_C(long classNameId, long classPK)
2338                    throws NoSuchEntryException, SystemException {
2339                    AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
2340    
2341                    if (assetEntry == null) {
2342                            StringBundler msg = new StringBundler(6);
2343    
2344                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2345    
2346                            msg.append("classNameId=");
2347                            msg.append(classNameId);
2348    
2349                            msg.append(", classPK=");
2350                            msg.append(classPK);
2351    
2352                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2353    
2354                            if (_log.isWarnEnabled()) {
2355                                    _log.warn(msg.toString());
2356                            }
2357    
2358                            throw new NoSuchEntryException(msg.toString());
2359                    }
2360    
2361                    return assetEntry;
2362            }
2363    
2364            /**
2365             * Returns the asset entry where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2366             *
2367             * @param classNameId the class name ID
2368             * @param classPK the class p k
2369             * @return the matching asset entry, or <code>null</code> if a matching asset entry could not be found
2370             * @throws SystemException if a system exception occurred
2371             */
2372            public AssetEntry fetchByC_C(long classNameId, long classPK)
2373                    throws SystemException {
2374                    return fetchByC_C(classNameId, classPK, true);
2375            }
2376    
2377            /**
2378             * Returns the asset entry where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2379             *
2380             * @param classNameId the class name ID
2381             * @param classPK the class p k
2382             * @param retrieveFromCache whether to use the finder cache
2383             * @return the matching asset entry, or <code>null</code> if a matching asset entry could not be found
2384             * @throws SystemException if a system exception occurred
2385             */
2386            public AssetEntry fetchByC_C(long classNameId, long classPK,
2387                    boolean retrieveFromCache) throws SystemException {
2388                    Object[] finderArgs = new Object[] { classNameId, classPK };
2389    
2390                    Object result = null;
2391    
2392                    if (retrieveFromCache) {
2393                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
2394                                            finderArgs, this);
2395                    }
2396    
2397                    if (result instanceof AssetEntry) {
2398                            AssetEntry assetEntry = (AssetEntry)result;
2399    
2400                            if ((classNameId != assetEntry.getClassNameId()) ||
2401                                            (classPK != assetEntry.getClassPK())) {
2402                                    result = null;
2403                            }
2404                    }
2405    
2406                    if (result == null) {
2407                            StringBundler query = new StringBundler(3);
2408    
2409                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2410    
2411                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2412    
2413                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2414    
2415                            String sql = query.toString();
2416    
2417                            Session session = null;
2418    
2419                            try {
2420                                    session = openSession();
2421    
2422                                    Query q = session.createQuery(sql);
2423    
2424                                    QueryPos qPos = QueryPos.getInstance(q);
2425    
2426                                    qPos.add(classNameId);
2427    
2428                                    qPos.add(classPK);
2429    
2430                                    List<AssetEntry> list = q.list();
2431    
2432                                    result = list;
2433    
2434                                    AssetEntry assetEntry = null;
2435    
2436                                    if (list.isEmpty()) {
2437                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2438                                                    finderArgs, list);
2439                                    }
2440                                    else {
2441                                            assetEntry = list.get(0);
2442    
2443                                            cacheResult(assetEntry);
2444    
2445                                            if ((assetEntry.getClassNameId() != classNameId) ||
2446                                                            (assetEntry.getClassPK() != classPK)) {
2447                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2448                                                            finderArgs, assetEntry);
2449                                            }
2450                                    }
2451    
2452                                    return assetEntry;
2453                            }
2454                            catch (Exception e) {
2455                                    throw processException(e);
2456                            }
2457                            finally {
2458                                    if (result == null) {
2459                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
2460                                                    finderArgs);
2461                                    }
2462    
2463                                    closeSession(session);
2464                            }
2465                    }
2466                    else {
2467                            if (result instanceof List<?>) {
2468                                    return null;
2469                            }
2470                            else {
2471                                    return (AssetEntry)result;
2472                            }
2473                    }
2474            }
2475    
2476            /**
2477             * Returns all the asset entries.
2478             *
2479             * @return the asset entries
2480             * @throws SystemException if a system exception occurred
2481             */
2482            public List<AssetEntry> findAll() throws SystemException {
2483                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2484            }
2485    
2486            /**
2487             * Returns a range of all the asset entries.
2488             *
2489             * <p>
2490             * 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.
2491             * </p>
2492             *
2493             * @param start the lower bound of the range of asset entries
2494             * @param end the upper bound of the range of asset entries (not inclusive)
2495             * @return the range of asset entries
2496             * @throws SystemException if a system exception occurred
2497             */
2498            public List<AssetEntry> findAll(int start, int end)
2499                    throws SystemException {
2500                    return findAll(start, end, null);
2501            }
2502    
2503            /**
2504             * Returns an ordered range of all the asset entries.
2505             *
2506             * <p>
2507             * 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.
2508             * </p>
2509             *
2510             * @param start the lower bound of the range of asset entries
2511             * @param end the upper bound of the range of asset entries (not inclusive)
2512             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2513             * @return the ordered range of asset entries
2514             * @throws SystemException if a system exception occurred
2515             */
2516            public List<AssetEntry> findAll(int start, int end,
2517                    OrderByComparator orderByComparator) throws SystemException {
2518                    FinderPath finderPath = null;
2519                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2520    
2521                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2522                                    (orderByComparator == null)) {
2523                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2524                            finderArgs = FINDER_ARGS_EMPTY;
2525                    }
2526                    else {
2527                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2528                            finderArgs = new Object[] { start, end, orderByComparator };
2529                    }
2530    
2531                    List<AssetEntry> list = (List<AssetEntry>)FinderCacheUtil.getResult(finderPath,
2532                                    finderArgs, this);
2533    
2534                    if (list == null) {
2535                            StringBundler query = null;
2536                            String sql = null;
2537    
2538                            if (orderByComparator != null) {
2539                                    query = new StringBundler(2 +
2540                                                    (orderByComparator.getOrderByFields().length * 3));
2541    
2542                                    query.append(_SQL_SELECT_ASSETENTRY);
2543    
2544                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2545                                            orderByComparator);
2546    
2547                                    sql = query.toString();
2548                            }
2549                            else {
2550                                    sql = _SQL_SELECT_ASSETENTRY;
2551                            }
2552    
2553                            Session session = null;
2554    
2555                            try {
2556                                    session = openSession();
2557    
2558                                    Query q = session.createQuery(sql);
2559    
2560                                    if (orderByComparator == null) {
2561                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2562                                                            start, end, false);
2563    
2564                                            Collections.sort(list);
2565                                    }
2566                                    else {
2567                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2568                                                            start, end);
2569                                    }
2570                            }
2571                            catch (Exception e) {
2572                                    throw processException(e);
2573                            }
2574                            finally {
2575                                    if (list == null) {
2576                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2577                                    }
2578                                    else {
2579                                            cacheResult(list);
2580    
2581                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2582                                    }
2583    
2584                                    closeSession(session);
2585                            }
2586                    }
2587    
2588                    return list;
2589            }
2590    
2591            /**
2592             * Removes all the asset entries where companyId = &#63; from the database.
2593             *
2594             * @param companyId the company ID
2595             * @throws SystemException if a system exception occurred
2596             */
2597            public void removeByCompanyId(long companyId) throws SystemException {
2598                    for (AssetEntry assetEntry : findByCompanyId(companyId)) {
2599                            remove(assetEntry);
2600                    }
2601            }
2602    
2603            /**
2604             * Removes all the asset entries where visible = &#63; from the database.
2605             *
2606             * @param visible the visible
2607             * @throws SystemException if a system exception occurred
2608             */
2609            public void removeByVisible(boolean visible) throws SystemException {
2610                    for (AssetEntry assetEntry : findByVisible(visible)) {
2611                            remove(assetEntry);
2612                    }
2613            }
2614    
2615            /**
2616             * Removes all the asset entries where publishDate = &#63; from the database.
2617             *
2618             * @param publishDate the publish date
2619             * @throws SystemException if a system exception occurred
2620             */
2621            public void removeByPublishDate(Date publishDate) throws SystemException {
2622                    for (AssetEntry assetEntry : findByPublishDate(publishDate)) {
2623                            remove(assetEntry);
2624                    }
2625            }
2626    
2627            /**
2628             * Removes all the asset entries where expirationDate = &#63; from the database.
2629             *
2630             * @param expirationDate the expiration date
2631             * @throws SystemException if a system exception occurred
2632             */
2633            public void removeByExpirationDate(Date expirationDate)
2634                    throws SystemException {
2635                    for (AssetEntry assetEntry : findByExpirationDate(expirationDate)) {
2636                            remove(assetEntry);
2637                    }
2638            }
2639    
2640            /**
2641             * Removes the asset entry where groupId = &#63; and classUuid = &#63; from the database.
2642             *
2643             * @param groupId the group ID
2644             * @param classUuid the class uuid
2645             * @throws SystemException if a system exception occurred
2646             */
2647            public void removeByG_CU(long groupId, String classUuid)
2648                    throws NoSuchEntryException, SystemException {
2649                    AssetEntry assetEntry = findByG_CU(groupId, classUuid);
2650    
2651                    remove(assetEntry);
2652            }
2653    
2654            /**
2655             * Removes the asset entry where classNameId = &#63; and classPK = &#63; from the database.
2656             *
2657             * @param classNameId the class name ID
2658             * @param classPK the class p k
2659             * @throws SystemException if a system exception occurred
2660             */
2661            public void removeByC_C(long classNameId, long classPK)
2662                    throws NoSuchEntryException, SystemException {
2663                    AssetEntry assetEntry = findByC_C(classNameId, classPK);
2664    
2665                    remove(assetEntry);
2666            }
2667    
2668            /**
2669             * Removes all the asset entries from the database.
2670             *
2671             * @throws SystemException if a system exception occurred
2672             */
2673            public void removeAll() throws SystemException {
2674                    for (AssetEntry assetEntry : findAll()) {
2675                            remove(assetEntry);
2676                    }
2677            }
2678    
2679            /**
2680             * Returns the number of asset entries where companyId = &#63;.
2681             *
2682             * @param companyId the company ID
2683             * @return the number of matching asset entries
2684             * @throws SystemException if a system exception occurred
2685             */
2686            public int countByCompanyId(long companyId) throws SystemException {
2687                    Object[] finderArgs = new Object[] { companyId };
2688    
2689                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2690                                    finderArgs, this);
2691    
2692                    if (count == null) {
2693                            StringBundler query = new StringBundler(2);
2694    
2695                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2696    
2697                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2698    
2699                            String sql = query.toString();
2700    
2701                            Session session = null;
2702    
2703                            try {
2704                                    session = openSession();
2705    
2706                                    Query q = session.createQuery(sql);
2707    
2708                                    QueryPos qPos = QueryPos.getInstance(q);
2709    
2710                                    qPos.add(companyId);
2711    
2712                                    count = (Long)q.uniqueResult();
2713                            }
2714                            catch (Exception e) {
2715                                    throw processException(e);
2716                            }
2717                            finally {
2718                                    if (count == null) {
2719                                            count = Long.valueOf(0);
2720                                    }
2721    
2722                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2723                                            finderArgs, count);
2724    
2725                                    closeSession(session);
2726                            }
2727                    }
2728    
2729                    return count.intValue();
2730            }
2731    
2732            /**
2733             * Returns the number of asset entries where visible = &#63;.
2734             *
2735             * @param visible the visible
2736             * @return the number of matching asset entries
2737             * @throws SystemException if a system exception occurred
2738             */
2739            public int countByVisible(boolean visible) throws SystemException {
2740                    Object[] finderArgs = new Object[] { visible };
2741    
2742                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VISIBLE,
2743                                    finderArgs, this);
2744    
2745                    if (count == null) {
2746                            StringBundler query = new StringBundler(2);
2747    
2748                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2749    
2750                            query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
2751    
2752                            String sql = query.toString();
2753    
2754                            Session session = null;
2755    
2756                            try {
2757                                    session = openSession();
2758    
2759                                    Query q = session.createQuery(sql);
2760    
2761                                    QueryPos qPos = QueryPos.getInstance(q);
2762    
2763                                    qPos.add(visible);
2764    
2765                                    count = (Long)q.uniqueResult();
2766                            }
2767                            catch (Exception e) {
2768                                    throw processException(e);
2769                            }
2770                            finally {
2771                                    if (count == null) {
2772                                            count = Long.valueOf(0);
2773                                    }
2774    
2775                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VISIBLE,
2776                                            finderArgs, count);
2777    
2778                                    closeSession(session);
2779                            }
2780                    }
2781    
2782                    return count.intValue();
2783            }
2784    
2785            /**
2786             * Returns the number of asset entries where publishDate = &#63;.
2787             *
2788             * @param publishDate the publish date
2789             * @return the number of matching asset entries
2790             * @throws SystemException if a system exception occurred
2791             */
2792            public int countByPublishDate(Date publishDate) throws SystemException {
2793                    Object[] finderArgs = new Object[] { publishDate };
2794    
2795                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
2796                                    finderArgs, this);
2797    
2798                    if (count == null) {
2799                            StringBundler query = new StringBundler(2);
2800    
2801                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2802    
2803                            if (publishDate == null) {
2804                                    query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
2805                            }
2806                            else {
2807                                    query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
2808                            }
2809    
2810                            String sql = query.toString();
2811    
2812                            Session session = null;
2813    
2814                            try {
2815                                    session = openSession();
2816    
2817                                    Query q = session.createQuery(sql);
2818    
2819                                    QueryPos qPos = QueryPos.getInstance(q);
2820    
2821                                    if (publishDate != null) {
2822                                            qPos.add(CalendarUtil.getTimestamp(publishDate));
2823                                    }
2824    
2825                                    count = (Long)q.uniqueResult();
2826                            }
2827                            catch (Exception e) {
2828                                    throw processException(e);
2829                            }
2830                            finally {
2831                                    if (count == null) {
2832                                            count = Long.valueOf(0);
2833                                    }
2834    
2835                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PUBLISHDATE,
2836                                            finderArgs, count);
2837    
2838                                    closeSession(session);
2839                            }
2840                    }
2841    
2842                    return count.intValue();
2843            }
2844    
2845            /**
2846             * Returns the number of asset entries where expirationDate = &#63;.
2847             *
2848             * @param expirationDate the expiration date
2849             * @return the number of matching asset entries
2850             * @throws SystemException if a system exception occurred
2851             */
2852            public int countByExpirationDate(Date expirationDate)
2853                    throws SystemException {
2854                    Object[] finderArgs = new Object[] { expirationDate };
2855    
2856                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
2857                                    finderArgs, this);
2858    
2859                    if (count == null) {
2860                            StringBundler query = new StringBundler(2);
2861    
2862                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2863    
2864                            if (expirationDate == null) {
2865                                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2866                            }
2867                            else {
2868                                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2869                            }
2870    
2871                            String sql = query.toString();
2872    
2873                            Session session = null;
2874    
2875                            try {
2876                                    session = openSession();
2877    
2878                                    Query q = session.createQuery(sql);
2879    
2880                                    QueryPos qPos = QueryPos.getInstance(q);
2881    
2882                                    if (expirationDate != null) {
2883                                            qPos.add(CalendarUtil.getTimestamp(expirationDate));
2884                                    }
2885    
2886                                    count = (Long)q.uniqueResult();
2887                            }
2888                            catch (Exception e) {
2889                                    throw processException(e);
2890                            }
2891                            finally {
2892                                    if (count == null) {
2893                                            count = Long.valueOf(0);
2894                                    }
2895    
2896                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
2897                                            finderArgs, count);
2898    
2899                                    closeSession(session);
2900                            }
2901                    }
2902    
2903                    return count.intValue();
2904            }
2905    
2906            /**
2907             * Returns the number of asset entries where groupId = &#63; and classUuid = &#63;.
2908             *
2909             * @param groupId the group ID
2910             * @param classUuid the class uuid
2911             * @return the number of matching asset entries
2912             * @throws SystemException if a system exception occurred
2913             */
2914            public int countByG_CU(long groupId, String classUuid)
2915                    throws SystemException {
2916                    Object[] finderArgs = new Object[] { groupId, classUuid };
2917    
2918                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_CU,
2919                                    finderArgs, this);
2920    
2921                    if (count == null) {
2922                            StringBundler query = new StringBundler(3);
2923    
2924                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2925    
2926                            query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
2927    
2928                            if (classUuid == null) {
2929                                    query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
2930                            }
2931                            else {
2932                                    if (classUuid.equals(StringPool.BLANK)) {
2933                                            query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
2934                                    }
2935                                    else {
2936                                            query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
2937                                    }
2938                            }
2939    
2940                            String sql = query.toString();
2941    
2942                            Session session = null;
2943    
2944                            try {
2945                                    session = openSession();
2946    
2947                                    Query q = session.createQuery(sql);
2948    
2949                                    QueryPos qPos = QueryPos.getInstance(q);
2950    
2951                                    qPos.add(groupId);
2952    
2953                                    if (classUuid != null) {
2954                                            qPos.add(classUuid);
2955                                    }
2956    
2957                                    count = (Long)q.uniqueResult();
2958                            }
2959                            catch (Exception e) {
2960                                    throw processException(e);
2961                            }
2962                            finally {
2963                                    if (count == null) {
2964                                            count = Long.valueOf(0);
2965                                    }
2966    
2967                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_CU,
2968                                            finderArgs, count);
2969    
2970                                    closeSession(session);
2971                            }
2972                    }
2973    
2974                    return count.intValue();
2975            }
2976    
2977            /**
2978             * Returns the number of asset entries where classNameId = &#63; and classPK = &#63;.
2979             *
2980             * @param classNameId the class name ID
2981             * @param classPK the class p k
2982             * @return the number of matching asset entries
2983             * @throws SystemException if a system exception occurred
2984             */
2985            public int countByC_C(long classNameId, long classPK)
2986                    throws SystemException {
2987                    Object[] finderArgs = new Object[] { classNameId, classPK };
2988    
2989                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
2990                                    finderArgs, this);
2991    
2992                    if (count == null) {
2993                            StringBundler query = new StringBundler(3);
2994    
2995                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2996    
2997                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2998    
2999                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3000    
3001                            String sql = query.toString();
3002    
3003                            Session session = null;
3004    
3005                            try {
3006                                    session = openSession();
3007    
3008                                    Query q = session.createQuery(sql);
3009    
3010                                    QueryPos qPos = QueryPos.getInstance(q);
3011    
3012                                    qPos.add(classNameId);
3013    
3014                                    qPos.add(classPK);
3015    
3016                                    count = (Long)q.uniqueResult();
3017                            }
3018                            catch (Exception e) {
3019                                    throw processException(e);
3020                            }
3021                            finally {
3022                                    if (count == null) {
3023                                            count = Long.valueOf(0);
3024                                    }
3025    
3026                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
3027                                            count);
3028    
3029                                    closeSession(session);
3030                            }
3031                    }
3032    
3033                    return count.intValue();
3034            }
3035    
3036            /**
3037             * Returns the number of asset entries.
3038             *
3039             * @return the number of asset entries
3040             * @throws SystemException if a system exception occurred
3041             */
3042            public int countAll() throws SystemException {
3043                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3044                                    FINDER_ARGS_EMPTY, this);
3045    
3046                    if (count == null) {
3047                            Session session = null;
3048    
3049                            try {
3050                                    session = openSession();
3051    
3052                                    Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
3053    
3054                                    count = (Long)q.uniqueResult();
3055                            }
3056                            catch (Exception e) {
3057                                    throw processException(e);
3058                            }
3059                            finally {
3060                                    if (count == null) {
3061                                            count = Long.valueOf(0);
3062                                    }
3063    
3064                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3065                                            FINDER_ARGS_EMPTY, count);
3066    
3067                                    closeSession(session);
3068                            }
3069                    }
3070    
3071                    return count.intValue();
3072            }
3073    
3074            /**
3075             * Returns all the asset categories associated with the asset entry.
3076             *
3077             * @param pk the primary key of the asset entry
3078             * @return the asset categories associated with the asset entry
3079             * @throws SystemException if a system exception occurred
3080             */
3081            public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3082                    long pk) throws SystemException {
3083                    return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3084            }
3085    
3086            /**
3087             * Returns a range of all the asset categories associated with the asset entry.
3088             *
3089             * <p>
3090             * 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.
3091             * </p>
3092             *
3093             * @param pk the primary key of the asset entry
3094             * @param start the lower bound of the range of asset entries
3095             * @param end the upper bound of the range of asset entries (not inclusive)
3096             * @return the range of asset categories associated with the asset entry
3097             * @throws SystemException if a system exception occurred
3098             */
3099            public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3100                    long pk, int start, int end) throws SystemException {
3101                    return getAssetCategories(pk, start, end, null);
3102            }
3103    
3104            public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3105                            AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3106                            com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class,
3107                            AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3108                            "getAssetCategories",
3109                            new String[] {
3110                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3111                                    "com.liferay.portal.kernel.util.OrderByComparator"
3112                            });
3113    
3114            static {
3115                    FINDER_PATH_GET_ASSETCATEGORIES.setCacheKeyGeneratorCacheName(null);
3116            }
3117    
3118            /**
3119             * Returns an ordered range of all the asset categories associated with the asset entry.
3120             *
3121             * <p>
3122             * 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.
3123             * </p>
3124             *
3125             * @param pk the primary key of the asset entry
3126             * @param start the lower bound of the range of asset entries
3127             * @param end the upper bound of the range of asset entries (not inclusive)
3128             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3129             * @return the ordered range of asset categories associated with the asset entry
3130             * @throws SystemException if a system exception occurred
3131             */
3132            public List<com.liferay.portlet.asset.model.AssetCategory> getAssetCategories(
3133                    long pk, int start, int end, OrderByComparator orderByComparator)
3134                    throws SystemException {
3135                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3136    
3137                    List<com.liferay.portlet.asset.model.AssetCategory> list = (List<com.liferay.portlet.asset.model.AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES,
3138                                    finderArgs, this);
3139    
3140                    if (list == null) {
3141                            Session session = null;
3142    
3143                            try {
3144                                    session = openSession();
3145    
3146                                    String sql = null;
3147    
3148                                    if (orderByComparator != null) {
3149                                            sql = _SQL_GETASSETCATEGORIES.concat(ORDER_BY_CLAUSE)
3150                                                                                                     .concat(orderByComparator.getOrderBy());
3151                                    }
3152                                    else {
3153                                            sql = _SQL_GETASSETCATEGORIES.concat(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ORDER_BY_SQL);
3154                                    }
3155    
3156                                    SQLQuery q = session.createSQLQuery(sql);
3157    
3158                                    q.addEntity("AssetCategory",
3159                                            com.liferay.portlet.asset.model.impl.AssetCategoryImpl.class);
3160    
3161                                    QueryPos qPos = QueryPos.getInstance(q);
3162    
3163                                    qPos.add(pk);
3164    
3165                                    list = (List<com.liferay.portlet.asset.model.AssetCategory>)QueryUtil.list(q,
3166                                                    getDialect(), start, end);
3167                            }
3168                            catch (Exception e) {
3169                                    throw processException(e);
3170                            }
3171                            finally {
3172                                    if (list == null) {
3173                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETCATEGORIES,
3174                                                    finderArgs);
3175                                    }
3176                                    else {
3177                                            assetCategoryPersistence.cacheResult(list);
3178    
3179                                            FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES,
3180                                                    finderArgs, list);
3181                                    }
3182    
3183                                    closeSession(session);
3184                            }
3185                    }
3186    
3187                    return list;
3188            }
3189    
3190            public static final FinderPath FINDER_PATH_GET_ASSETCATEGORIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3191                            AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3192                            Long.class,
3193                            AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3194                            "getAssetCategoriesSize", new String[] { Long.class.getName() });
3195    
3196            static {
3197                    FINDER_PATH_GET_ASSETCATEGORIES_SIZE.setCacheKeyGeneratorCacheName(null);
3198            }
3199    
3200            /**
3201             * Returns the number of asset categories associated with the asset entry.
3202             *
3203             * @param pk the primary key of the asset entry
3204             * @return the number of asset categories associated with the asset entry
3205             * @throws SystemException if a system exception occurred
3206             */
3207            public int getAssetCategoriesSize(long pk) throws SystemException {
3208                    Object[] finderArgs = new Object[] { pk };
3209    
3210                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
3211                                    finderArgs, this);
3212    
3213                    if (count == null) {
3214                            Session session = null;
3215    
3216                            try {
3217                                    session = openSession();
3218    
3219                                    SQLQuery q = session.createSQLQuery(_SQL_GETASSETCATEGORIESSIZE);
3220    
3221                                    q.addScalar(COUNT_COLUMN_NAME,
3222                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
3223    
3224                                    QueryPos qPos = QueryPos.getInstance(q);
3225    
3226                                    qPos.add(pk);
3227    
3228                                    count = (Long)q.uniqueResult();
3229                            }
3230                            catch (Exception e) {
3231                                    throw processException(e);
3232                            }
3233                            finally {
3234                                    if (count == null) {
3235                                            count = Long.valueOf(0);
3236                                    }
3237    
3238                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETCATEGORIES_SIZE,
3239                                            finderArgs, count);
3240    
3241                                    closeSession(session);
3242                            }
3243                    }
3244    
3245                    return count.intValue();
3246            }
3247    
3248            public static final FinderPath FINDER_PATH_CONTAINS_ASSETCATEGORY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3249                            AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
3250                            Boolean.class,
3251                            AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
3252                            "containsAssetCategory",
3253                            new String[] { Long.class.getName(), Long.class.getName() });
3254    
3255            /**
3256             * Returns <code>true</code> if the asset category is associated with the asset entry.
3257             *
3258             * @param pk the primary key of the asset entry
3259             * @param assetCategoryPK the primary key of the asset category
3260             * @return <code>true</code> if the asset category is associated with the asset entry; <code>false</code> otherwise
3261             * @throws SystemException if a system exception occurred
3262             */
3263            public boolean containsAssetCategory(long pk, long assetCategoryPK)
3264                    throws SystemException {
3265                    Object[] finderArgs = new Object[] { pk, assetCategoryPK };
3266    
3267                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
3268                                    finderArgs, this);
3269    
3270                    if (value == null) {
3271                            try {
3272                                    value = Boolean.valueOf(containsAssetCategory.contains(pk,
3273                                                            assetCategoryPK));
3274                            }
3275                            catch (Exception e) {
3276                                    throw processException(e);
3277                            }
3278                            finally {
3279                                    if (value == null) {
3280                                            value = Boolean.FALSE;
3281                                    }
3282    
3283                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETCATEGORY,
3284                                            finderArgs, value);
3285                            }
3286                    }
3287    
3288                    return value.booleanValue();
3289            }
3290    
3291            /**
3292             * Returns <code>true</code> if the asset entry has any asset categories associated with it.
3293             *
3294             * @param pk the primary key of the asset entry to check for associations with asset categories
3295             * @return <code>true</code> if the asset entry has any asset categories associated with it; <code>false</code> otherwise
3296             * @throws SystemException if a system exception occurred
3297             */
3298            public boolean containsAssetCategories(long pk) throws SystemException {
3299                    if (getAssetCategoriesSize(pk) > 0) {
3300                            return true;
3301                    }
3302                    else {
3303                            return false;
3304                    }
3305            }
3306    
3307            /**
3308             * Adds an association between the asset entry and the asset category. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3309             *
3310             * @param pk the primary key of the asset entry
3311             * @param assetCategoryPK the primary key of the asset category
3312             * @throws SystemException if a system exception occurred
3313             */
3314            public void addAssetCategory(long pk, long assetCategoryPK)
3315                    throws SystemException {
3316                    try {
3317                            addAssetCategory.add(pk, assetCategoryPK);
3318                    }
3319                    catch (Exception e) {
3320                            throw processException(e);
3321                    }
3322                    finally {
3323                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3324                    }
3325            }
3326    
3327            /**
3328             * Adds an association between the asset entry and the asset category. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3329             *
3330             * @param pk the primary key of the asset entry
3331             * @param assetCategory the asset category
3332             * @throws SystemException if a system exception occurred
3333             */
3334            public void addAssetCategory(long pk,
3335                    com.liferay.portlet.asset.model.AssetCategory assetCategory)
3336                    throws SystemException {
3337                    try {
3338                            addAssetCategory.add(pk, assetCategory.getPrimaryKey());
3339                    }
3340                    catch (Exception e) {
3341                            throw processException(e);
3342                    }
3343                    finally {
3344                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3345                    }
3346            }
3347    
3348            /**
3349             * Adds an association between the asset entry and the asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3350             *
3351             * @param pk the primary key of the asset entry
3352             * @param assetCategoryPKs the primary keys of the asset categories
3353             * @throws SystemException if a system exception occurred
3354             */
3355            public void addAssetCategories(long pk, long[] assetCategoryPKs)
3356                    throws SystemException {
3357                    try {
3358                            for (long assetCategoryPK : assetCategoryPKs) {
3359                                    addAssetCategory.add(pk, assetCategoryPK);
3360                            }
3361                    }
3362                    catch (Exception e) {
3363                            throw processException(e);
3364                    }
3365                    finally {
3366                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3367                    }
3368            }
3369    
3370            /**
3371             * Adds an association between the asset entry and the asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3372             *
3373             * @param pk the primary key of the asset entry
3374             * @param assetCategories the asset categories
3375             * @throws SystemException if a system exception occurred
3376             */
3377            public void addAssetCategories(long pk,
3378                    List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3379                    throws SystemException {
3380                    try {
3381                            for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3382                                    addAssetCategory.add(pk, assetCategory.getPrimaryKey());
3383                            }
3384                    }
3385                    catch (Exception e) {
3386                            throw processException(e);
3387                    }
3388                    finally {
3389                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3390                    }
3391            }
3392    
3393            /**
3394             * Clears all associations between the asset entry and its asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3395             *
3396             * @param pk the primary key of the asset entry to clear the associated asset categories from
3397             * @throws SystemException if a system exception occurred
3398             */
3399            public void clearAssetCategories(long pk) throws SystemException {
3400                    try {
3401                            clearAssetCategories.clear(pk);
3402                    }
3403                    catch (Exception e) {
3404                            throw processException(e);
3405                    }
3406                    finally {
3407                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3408                    }
3409            }
3410    
3411            /**
3412             * Removes the association between the asset entry and the asset category. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3413             *
3414             * @param pk the primary key of the asset entry
3415             * @param assetCategoryPK the primary key of the asset category
3416             * @throws SystemException if a system exception occurred
3417             */
3418            public void removeAssetCategory(long pk, long assetCategoryPK)
3419                    throws SystemException {
3420                    try {
3421                            removeAssetCategory.remove(pk, assetCategoryPK);
3422                    }
3423                    catch (Exception e) {
3424                            throw processException(e);
3425                    }
3426                    finally {
3427                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3428                    }
3429            }
3430    
3431            /**
3432             * Removes the association between the asset entry and the asset category. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3433             *
3434             * @param pk the primary key of the asset entry
3435             * @param assetCategory the asset category
3436             * @throws SystemException if a system exception occurred
3437             */
3438            public void removeAssetCategory(long pk,
3439                    com.liferay.portlet.asset.model.AssetCategory assetCategory)
3440                    throws SystemException {
3441                    try {
3442                            removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3443                    }
3444                    catch (Exception e) {
3445                            throw processException(e);
3446                    }
3447                    finally {
3448                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3449                    }
3450            }
3451    
3452            /**
3453             * Removes the association between the asset entry and the asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3454             *
3455             * @param pk the primary key of the asset entry
3456             * @param assetCategoryPKs the primary keys of the asset categories
3457             * @throws SystemException if a system exception occurred
3458             */
3459            public void removeAssetCategories(long pk, long[] assetCategoryPKs)
3460                    throws SystemException {
3461                    try {
3462                            for (long assetCategoryPK : assetCategoryPKs) {
3463                                    removeAssetCategory.remove(pk, assetCategoryPK);
3464                            }
3465                    }
3466                    catch (Exception e) {
3467                            throw processException(e);
3468                    }
3469                    finally {
3470                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3471                    }
3472            }
3473    
3474            /**
3475             * Removes the association between the asset entry and the asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3476             *
3477             * @param pk the primary key of the asset entry
3478             * @param assetCategories the asset categories
3479             * @throws SystemException if a system exception occurred
3480             */
3481            public void removeAssetCategories(long pk,
3482                    List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3483                    throws SystemException {
3484                    try {
3485                            for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3486                                    removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3487                            }
3488                    }
3489                    catch (Exception e) {
3490                            throw processException(e);
3491                    }
3492                    finally {
3493                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3494                    }
3495            }
3496    
3497            /**
3498             * Sets the asset categories associated with the asset entry, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3499             *
3500             * @param pk the primary key of the asset entry
3501             * @param assetCategoryPKs the primary keys of the asset categories to be associated with the asset entry
3502             * @throws SystemException if a system exception occurred
3503             */
3504            public void setAssetCategories(long pk, long[] assetCategoryPKs)
3505                    throws SystemException {
3506                    try {
3507                            Set<Long> assetCategoryPKSet = SetUtil.fromArray(assetCategoryPKs);
3508    
3509                            List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = getAssetCategories(pk);
3510    
3511                            for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
3512                                    if (!assetCategoryPKSet.remove(assetCategory.getPrimaryKey())) {
3513                                            removeAssetCategory.remove(pk, assetCategory.getPrimaryKey());
3514                                    }
3515                            }
3516    
3517                            for (Long assetCategoryPK : assetCategoryPKSet) {
3518                                    addAssetCategory.add(pk, assetCategoryPK);
3519                            }
3520                    }
3521                    catch (Exception e) {
3522                            throw processException(e);
3523                    }
3524                    finally {
3525                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3526                    }
3527            }
3528    
3529            /**
3530             * Sets the asset categories associated with the asset entry, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3531             *
3532             * @param pk the primary key of the asset entry
3533             * @param assetCategories the asset categories to be associated with the asset entry
3534             * @throws SystemException if a system exception occurred
3535             */
3536            public void setAssetCategories(long pk,
3537                    List<com.liferay.portlet.asset.model.AssetCategory> assetCategories)
3538                    throws SystemException {
3539                    try {
3540                            long[] assetCategoryPKs = new long[assetCategories.size()];
3541    
3542                            for (int i = 0; i < assetCategories.size(); i++) {
3543                                    com.liferay.portlet.asset.model.AssetCategory assetCategory = assetCategories.get(i);
3544    
3545                                    assetCategoryPKs[i] = assetCategory.getPrimaryKey();
3546                            }
3547    
3548                            setAssetCategories(pk, assetCategoryPKs);
3549                    }
3550                    catch (Exception e) {
3551                            throw processException(e);
3552                    }
3553                    finally {
3554                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
3555                    }
3556            }
3557    
3558            /**
3559             * Returns all the asset tags associated with the asset entry.
3560             *
3561             * @param pk the primary key of the asset entry
3562             * @return the asset tags associated with the asset entry
3563             * @throws SystemException if a system exception occurred
3564             */
3565            public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(long pk)
3566                    throws SystemException {
3567                    return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3568            }
3569    
3570            /**
3571             * Returns a range of all the asset tags associated with the asset entry.
3572             *
3573             * <p>
3574             * 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.
3575             * </p>
3576             *
3577             * @param pk the primary key of the asset entry
3578             * @param start the lower bound of the range of asset entries
3579             * @param end the upper bound of the range of asset entries (not inclusive)
3580             * @return the range of asset tags associated with the asset entry
3581             * @throws SystemException if a system exception occurred
3582             */
3583            public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
3584                    long pk, int start, int end) throws SystemException {
3585                    return getAssetTags(pk, start, end, null);
3586            }
3587    
3588            public static final FinderPath FINDER_PATH_GET_ASSETTAGS = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3589                            AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3590                            com.liferay.portlet.asset.model.impl.AssetTagImpl.class,
3591                            AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3592                            "getAssetTags",
3593                            new String[] {
3594                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3595                                    "com.liferay.portal.kernel.util.OrderByComparator"
3596                            });
3597    
3598            static {
3599                    FINDER_PATH_GET_ASSETTAGS.setCacheKeyGeneratorCacheName(null);
3600            }
3601    
3602            /**
3603             * Returns an ordered range of all the asset tags associated with the asset entry.
3604             *
3605             * <p>
3606             * 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.
3607             * </p>
3608             *
3609             * @param pk the primary key of the asset entry
3610             * @param start the lower bound of the range of asset entries
3611             * @param end the upper bound of the range of asset entries (not inclusive)
3612             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3613             * @return the ordered range of asset tags associated with the asset entry
3614             * @throws SystemException if a system exception occurred
3615             */
3616            public List<com.liferay.portlet.asset.model.AssetTag> getAssetTags(
3617                    long pk, int start, int end, OrderByComparator orderByComparator)
3618                    throws SystemException {
3619                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3620    
3621                    List<com.liferay.portlet.asset.model.AssetTag> list = (List<com.liferay.portlet.asset.model.AssetTag>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS,
3622                                    finderArgs, this);
3623    
3624                    if (list == null) {
3625                            Session session = null;
3626    
3627                            try {
3628                                    session = openSession();
3629    
3630                                    String sql = null;
3631    
3632                                    if (orderByComparator != null) {
3633                                            sql = _SQL_GETASSETTAGS.concat(ORDER_BY_CLAUSE)
3634                                                                                       .concat(orderByComparator.getOrderBy());
3635                                    }
3636                                    else {
3637                                            sql = _SQL_GETASSETTAGS.concat(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ORDER_BY_SQL);
3638                                    }
3639    
3640                                    SQLQuery q = session.createSQLQuery(sql);
3641    
3642                                    q.addEntity("AssetTag",
3643                                            com.liferay.portlet.asset.model.impl.AssetTagImpl.class);
3644    
3645                                    QueryPos qPos = QueryPos.getInstance(q);
3646    
3647                                    qPos.add(pk);
3648    
3649                                    list = (List<com.liferay.portlet.asset.model.AssetTag>)QueryUtil.list(q,
3650                                                    getDialect(), start, end);
3651                            }
3652                            catch (Exception e) {
3653                                    throw processException(e);
3654                            }
3655                            finally {
3656                                    if (list == null) {
3657                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETTAGS,
3658                                                    finderArgs);
3659                                    }
3660                                    else {
3661                                            assetTagPersistence.cacheResult(list);
3662    
3663                                            FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS,
3664                                                    finderArgs, list);
3665                                    }
3666    
3667                                    closeSession(session);
3668                            }
3669                    }
3670    
3671                    return list;
3672            }
3673    
3674            public static final FinderPath FINDER_PATH_GET_ASSETTAGS_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3675                            AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3676                            Long.class,
3677                            AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3678                            "getAssetTagsSize", new String[] { Long.class.getName() });
3679    
3680            static {
3681                    FINDER_PATH_GET_ASSETTAGS_SIZE.setCacheKeyGeneratorCacheName(null);
3682            }
3683    
3684            /**
3685             * Returns the number of asset tags associated with the asset entry.
3686             *
3687             * @param pk the primary key of the asset entry
3688             * @return the number of asset tags associated with the asset entry
3689             * @throws SystemException if a system exception occurred
3690             */
3691            public int getAssetTagsSize(long pk) throws SystemException {
3692                    Object[] finderArgs = new Object[] { pk };
3693    
3694                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
3695                                    finderArgs, this);
3696    
3697                    if (count == null) {
3698                            Session session = null;
3699    
3700                            try {
3701                                    session = openSession();
3702    
3703                                    SQLQuery q = session.createSQLQuery(_SQL_GETASSETTAGSSIZE);
3704    
3705                                    q.addScalar(COUNT_COLUMN_NAME,
3706                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
3707    
3708                                    QueryPos qPos = QueryPos.getInstance(q);
3709    
3710                                    qPos.add(pk);
3711    
3712                                    count = (Long)q.uniqueResult();
3713                            }
3714                            catch (Exception e) {
3715                                    throw processException(e);
3716                            }
3717                            finally {
3718                                    if (count == null) {
3719                                            count = Long.valueOf(0);
3720                                    }
3721    
3722                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETTAGS_SIZE,
3723                                            finderArgs, count);
3724    
3725                                    closeSession(session);
3726                            }
3727                    }
3728    
3729                    return count.intValue();
3730            }
3731    
3732            public static final FinderPath FINDER_PATH_CONTAINS_ASSETTAG = new FinderPath(com.liferay.portlet.asset.model.impl.AssetTagModelImpl.ENTITY_CACHE_ENABLED,
3733                            AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS,
3734                            Boolean.class,
3735                            AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME,
3736                            "containsAssetTag",
3737                            new String[] { Long.class.getName(), Long.class.getName() });
3738    
3739            /**
3740             * Returns <code>true</code> if the asset tag is associated with the asset entry.
3741             *
3742             * @param pk the primary key of the asset entry
3743             * @param assetTagPK the primary key of the asset tag
3744             * @return <code>true</code> if the asset tag is associated with the asset entry; <code>false</code> otherwise
3745             * @throws SystemException if a system exception occurred
3746             */
3747            public boolean containsAssetTag(long pk, long assetTagPK)
3748                    throws SystemException {
3749                    Object[] finderArgs = new Object[] { pk, assetTagPK };
3750    
3751                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETTAG,
3752                                    finderArgs, this);
3753    
3754                    if (value == null) {
3755                            try {
3756                                    value = Boolean.valueOf(containsAssetTag.contains(pk, assetTagPK));
3757                            }
3758                            catch (Exception e) {
3759                                    throw processException(e);
3760                            }
3761                            finally {
3762                                    if (value == null) {
3763                                            value = Boolean.FALSE;
3764                                    }
3765    
3766                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETTAG,
3767                                            finderArgs, value);
3768                            }
3769                    }
3770    
3771                    return value.booleanValue();
3772            }
3773    
3774            /**
3775             * Returns <code>true</code> if the asset entry has any asset tags associated with it.
3776             *
3777             * @param pk the primary key of the asset entry to check for associations with asset tags
3778             * @return <code>true</code> if the asset entry has any asset tags associated with it; <code>false</code> otherwise
3779             * @throws SystemException if a system exception occurred
3780             */
3781            public boolean containsAssetTags(long pk) throws SystemException {
3782                    if (getAssetTagsSize(pk) > 0) {
3783                            return true;
3784                    }
3785                    else {
3786                            return false;
3787                    }
3788            }
3789    
3790            /**
3791             * Adds an association between the asset entry and the asset tag. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3792             *
3793             * @param pk the primary key of the asset entry
3794             * @param assetTagPK the primary key of the asset tag
3795             * @throws SystemException if a system exception occurred
3796             */
3797            public void addAssetTag(long pk, long assetTagPK) throws SystemException {
3798                    try {
3799                            addAssetTag.add(pk, assetTagPK);
3800                    }
3801                    catch (Exception e) {
3802                            throw processException(e);
3803                    }
3804                    finally {
3805                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3806                    }
3807            }
3808    
3809            /**
3810             * Adds an association between the asset entry and the asset tag. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3811             *
3812             * @param pk the primary key of the asset entry
3813             * @param assetTag the asset tag
3814             * @throws SystemException if a system exception occurred
3815             */
3816            public void addAssetTag(long pk,
3817                    com.liferay.portlet.asset.model.AssetTag assetTag)
3818                    throws SystemException {
3819                    try {
3820                            addAssetTag.add(pk, assetTag.getPrimaryKey());
3821                    }
3822                    catch (Exception e) {
3823                            throw processException(e);
3824                    }
3825                    finally {
3826                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3827                    }
3828            }
3829    
3830            /**
3831             * Adds an association between the asset entry and the asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3832             *
3833             * @param pk the primary key of the asset entry
3834             * @param assetTagPKs the primary keys of the asset tags
3835             * @throws SystemException if a system exception occurred
3836             */
3837            public void addAssetTags(long pk, long[] assetTagPKs)
3838                    throws SystemException {
3839                    try {
3840                            for (long assetTagPK : assetTagPKs) {
3841                                    addAssetTag.add(pk, assetTagPK);
3842                            }
3843                    }
3844                    catch (Exception e) {
3845                            throw processException(e);
3846                    }
3847                    finally {
3848                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3849                    }
3850            }
3851    
3852            /**
3853             * Adds an association between the asset entry and the asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3854             *
3855             * @param pk the primary key of the asset entry
3856             * @param assetTags the asset tags
3857             * @throws SystemException if a system exception occurred
3858             */
3859            public void addAssetTags(long pk,
3860                    List<com.liferay.portlet.asset.model.AssetTag> assetTags)
3861                    throws SystemException {
3862                    try {
3863                            for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
3864                                    addAssetTag.add(pk, assetTag.getPrimaryKey());
3865                            }
3866                    }
3867                    catch (Exception e) {
3868                            throw processException(e);
3869                    }
3870                    finally {
3871                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3872                    }
3873            }
3874    
3875            /**
3876             * Clears all associations between the asset entry and its asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3877             *
3878             * @param pk the primary key of the asset entry to clear the associated asset tags from
3879             * @throws SystemException if a system exception occurred
3880             */
3881            public void clearAssetTags(long pk) throws SystemException {
3882                    try {
3883                            clearAssetTags.clear(pk);
3884                    }
3885                    catch (Exception e) {
3886                            throw processException(e);
3887                    }
3888                    finally {
3889                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3890                    }
3891            }
3892    
3893            /**
3894             * Removes the association between the asset entry and the asset tag. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3895             *
3896             * @param pk the primary key of the asset entry
3897             * @param assetTagPK the primary key of the asset tag
3898             * @throws SystemException if a system exception occurred
3899             */
3900            public void removeAssetTag(long pk, long assetTagPK)
3901                    throws SystemException {
3902                    try {
3903                            removeAssetTag.remove(pk, assetTagPK);
3904                    }
3905                    catch (Exception e) {
3906                            throw processException(e);
3907                    }
3908                    finally {
3909                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3910                    }
3911            }
3912    
3913            /**
3914             * Removes the association between the asset entry and the asset tag. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3915             *
3916             * @param pk the primary key of the asset entry
3917             * @param assetTag the asset tag
3918             * @throws SystemException if a system exception occurred
3919             */
3920            public void removeAssetTag(long pk,
3921                    com.liferay.portlet.asset.model.AssetTag assetTag)
3922                    throws SystemException {
3923                    try {
3924                            removeAssetTag.remove(pk, assetTag.getPrimaryKey());
3925                    }
3926                    catch (Exception e) {
3927                            throw processException(e);
3928                    }
3929                    finally {
3930                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3931                    }
3932            }
3933    
3934            /**
3935             * Removes the association between the asset entry and the asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3936             *
3937             * @param pk the primary key of the asset entry
3938             * @param assetTagPKs the primary keys of the asset tags
3939             * @throws SystemException if a system exception occurred
3940             */
3941            public void removeAssetTags(long pk, long[] assetTagPKs)
3942                    throws SystemException {
3943                    try {
3944                            for (long assetTagPK : assetTagPKs) {
3945                                    removeAssetTag.remove(pk, assetTagPK);
3946                            }
3947                    }
3948                    catch (Exception e) {
3949                            throw processException(e);
3950                    }
3951                    finally {
3952                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3953                    }
3954            }
3955    
3956            /**
3957             * Removes the association between the asset entry and the asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3958             *
3959             * @param pk the primary key of the asset entry
3960             * @param assetTags the asset tags
3961             * @throws SystemException if a system exception occurred
3962             */
3963            public void removeAssetTags(long pk,
3964                    List<com.liferay.portlet.asset.model.AssetTag> assetTags)
3965                    throws SystemException {
3966                    try {
3967                            for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
3968                                    removeAssetTag.remove(pk, assetTag.getPrimaryKey());
3969                            }
3970                    }
3971                    catch (Exception e) {
3972                            throw processException(e);
3973                    }
3974                    finally {
3975                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
3976                    }
3977            }
3978    
3979            /**
3980             * Sets the asset tags associated with the asset entry, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3981             *
3982             * @param pk the primary key of the asset entry
3983             * @param assetTagPKs the primary keys of the asset tags to be associated with the asset entry
3984             * @throws SystemException if a system exception occurred
3985             */
3986            public void setAssetTags(long pk, long[] assetTagPKs)
3987                    throws SystemException {
3988                    try {
3989                            Set<Long> assetTagPKSet = SetUtil.fromArray(assetTagPKs);
3990    
3991                            List<com.liferay.portlet.asset.model.AssetTag> assetTags = getAssetTags(pk);
3992    
3993                            for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
3994                                    if (!assetTagPKSet.remove(assetTag.getPrimaryKey())) {
3995                                            removeAssetTag.remove(pk, assetTag.getPrimaryKey());
3996                                    }
3997                            }
3998    
3999                            for (Long assetTagPK : assetTagPKSet) {
4000                                    addAssetTag.add(pk, assetTagPK);
4001                            }
4002                    }
4003                    catch (Exception e) {
4004                            throw processException(e);
4005                    }
4006                    finally {
4007                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4008                    }
4009            }
4010    
4011            /**
4012             * Sets the asset tags associated with the asset entry, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4013             *
4014             * @param pk the primary key of the asset entry
4015             * @param assetTags the asset tags to be associated with the asset entry
4016             * @throws SystemException if a system exception occurred
4017             */
4018            public void setAssetTags(long pk,
4019                    List<com.liferay.portlet.asset.model.AssetTag> assetTags)
4020                    throws SystemException {
4021                    try {
4022                            long[] assetTagPKs = new long[assetTags.size()];
4023    
4024                            for (int i = 0; i < assetTags.size(); i++) {
4025                                    com.liferay.portlet.asset.model.AssetTag assetTag = assetTags.get(i);
4026    
4027                                    assetTagPKs[i] = assetTag.getPrimaryKey();
4028                            }
4029    
4030                            setAssetTags(pk, assetTagPKs);
4031                    }
4032                    catch (Exception e) {
4033                            throw processException(e);
4034                    }
4035                    finally {
4036                            FinderCacheUtil.clearCache(AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME);
4037                    }
4038            }
4039    
4040            /**
4041             * Initializes the asset entry persistence.
4042             */
4043            public void afterPropertiesSet() {
4044                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4045                                            com.liferay.portal.util.PropsUtil.get(
4046                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetEntry")));
4047    
4048                    if (listenerClassNames.length > 0) {
4049                            try {
4050                                    List<ModelListener<AssetEntry>> listenersList = new ArrayList<ModelListener<AssetEntry>>();
4051    
4052                                    for (String listenerClassName : listenerClassNames) {
4053                                            listenersList.add((ModelListener<AssetEntry>)InstanceFactory.newInstance(
4054                                                            listenerClassName));
4055                                    }
4056    
4057                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4058                            }
4059                            catch (Exception e) {
4060                                    _log.error(e);
4061                            }
4062                    }
4063    
4064                    containsAssetCategory = new ContainsAssetCategory();
4065    
4066                    addAssetCategory = new AddAssetCategory();
4067                    clearAssetCategories = new ClearAssetCategories();
4068                    removeAssetCategory = new RemoveAssetCategory();
4069    
4070                    containsAssetTag = new ContainsAssetTag();
4071    
4072                    addAssetTag = new AddAssetTag();
4073                    clearAssetTags = new ClearAssetTags();
4074                    removeAssetTag = new RemoveAssetTag();
4075            }
4076    
4077            public void destroy() {
4078                    EntityCacheUtil.removeCache(AssetEntryImpl.class.getName());
4079                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4080                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4081            }
4082    
4083            @BeanReference(type = AssetCategoryPersistence.class)
4084            protected AssetCategoryPersistence assetCategoryPersistence;
4085            @BeanReference(type = AssetCategoryPropertyPersistence.class)
4086            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
4087            @BeanReference(type = AssetEntryPersistence.class)
4088            protected AssetEntryPersistence assetEntryPersistence;
4089            @BeanReference(type = AssetLinkPersistence.class)
4090            protected AssetLinkPersistence assetLinkPersistence;
4091            @BeanReference(type = AssetTagPersistence.class)
4092            protected AssetTagPersistence assetTagPersistence;
4093            @BeanReference(type = AssetTagPropertyPersistence.class)
4094            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
4095            @BeanReference(type = AssetTagStatsPersistence.class)
4096            protected AssetTagStatsPersistence assetTagStatsPersistence;
4097            @BeanReference(type = AssetVocabularyPersistence.class)
4098            protected AssetVocabularyPersistence assetVocabularyPersistence;
4099            @BeanReference(type = CompanyPersistence.class)
4100            protected CompanyPersistence companyPersistence;
4101            @BeanReference(type = GroupPersistence.class)
4102            protected GroupPersistence groupPersistence;
4103            @BeanReference(type = ResourcePersistence.class)
4104            protected ResourcePersistence resourcePersistence;
4105            @BeanReference(type = UserPersistence.class)
4106            protected UserPersistence userPersistence;
4107            @BeanReference(type = BlogsEntryPersistence.class)
4108            protected BlogsEntryPersistence blogsEntryPersistence;
4109            @BeanReference(type = BookmarksEntryPersistence.class)
4110            protected BookmarksEntryPersistence bookmarksEntryPersistence;
4111            @BeanReference(type = DLFileEntryPersistence.class)
4112            protected DLFileEntryPersistence dlFileEntryPersistence;
4113            @BeanReference(type = DLFolderPersistence.class)
4114            protected DLFolderPersistence dlFolderPersistence;
4115            @BeanReference(type = JournalArticlePersistence.class)
4116            protected JournalArticlePersistence journalArticlePersistence;
4117            @BeanReference(type = JournalArticleResourcePersistence.class)
4118            protected JournalArticleResourcePersistence journalArticleResourcePersistence;
4119            @BeanReference(type = MBMessagePersistence.class)
4120            protected MBMessagePersistence mbMessagePersistence;
4121            @BeanReference(type = SocialActivityPersistence.class)
4122            protected SocialActivityPersistence socialActivityPersistence;
4123            @BeanReference(type = WikiPagePersistence.class)
4124            protected WikiPagePersistence wikiPagePersistence;
4125            @BeanReference(type = WikiPageResourcePersistence.class)
4126            protected WikiPageResourcePersistence wikiPageResourcePersistence;
4127            protected ContainsAssetCategory containsAssetCategory;
4128            protected AddAssetCategory addAssetCategory;
4129            protected ClearAssetCategories clearAssetCategories;
4130            protected RemoveAssetCategory removeAssetCategory;
4131            protected ContainsAssetTag containsAssetTag;
4132            protected AddAssetTag addAssetTag;
4133            protected ClearAssetTags clearAssetTags;
4134            protected RemoveAssetTag removeAssetTag;
4135    
4136            protected class ContainsAssetCategory {
4137                    protected ContainsAssetCategory() {
4138                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4139                                            _SQL_CONTAINSASSETCATEGORY,
4140                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4141                                            RowMapper.COUNT);
4142                    }
4143    
4144                    protected boolean contains(long entryId, long categoryId) {
4145                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4146                                                    new Long(entryId), new Long(categoryId)
4147                                            });
4148    
4149                            if (results.size() > 0) {
4150                                    Integer count = results.get(0);
4151    
4152                                    if (count.intValue() > 0) {
4153                                            return true;
4154                                    }
4155                            }
4156    
4157                            return false;
4158                    }
4159    
4160                    private MappingSqlQuery<Integer> _mappingSqlQuery;
4161            }
4162    
4163            protected class AddAssetCategory {
4164                    protected AddAssetCategory() {
4165                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4166                                            "INSERT INTO AssetEntries_AssetCategories (entryId, categoryId) VALUES (?, ?)",
4167                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4168                    }
4169    
4170                    protected void add(long entryId, long categoryId)
4171                            throws SystemException {
4172                            if (!containsAssetCategory.contains(entryId, categoryId)) {
4173                                    ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4174                                            assetCategoryPersistence.getListeners();
4175    
4176                                    for (ModelListener<AssetEntry> listener : listeners) {
4177                                            listener.onBeforeAddAssociation(entryId,
4178                                                    com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4179                                                    categoryId);
4180                                    }
4181    
4182                                    for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4183                                            listener.onBeforeAddAssociation(categoryId,
4184                                                    AssetEntry.class.getName(), entryId);
4185                                    }
4186    
4187                                    _sqlUpdate.update(new Object[] {
4188                                                    new Long(entryId), new Long(categoryId)
4189                                            });
4190    
4191                                    for (ModelListener<AssetEntry> listener : listeners) {
4192                                            listener.onAfterAddAssociation(entryId,
4193                                                    com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4194                                                    categoryId);
4195                                    }
4196    
4197                                    for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4198                                            listener.onAfterAddAssociation(categoryId,
4199                                                    AssetEntry.class.getName(), entryId);
4200                                    }
4201                            }
4202                    }
4203    
4204                    private SqlUpdate _sqlUpdate;
4205            }
4206    
4207            protected class ClearAssetCategories {
4208                    protected ClearAssetCategories() {
4209                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4210                                            "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ?",
4211                                            new int[] { java.sql.Types.BIGINT });
4212                    }
4213    
4214                    protected void clear(long entryId) throws SystemException {
4215                            ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4216                                    assetCategoryPersistence.getListeners();
4217    
4218                            List<com.liferay.portlet.asset.model.AssetCategory> assetCategories = null;
4219    
4220                            if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
4221                                    assetCategories = getAssetCategories(entryId);
4222    
4223                                    for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4224                                            for (ModelListener<AssetEntry> listener : listeners) {
4225                                                    listener.onBeforeRemoveAssociation(entryId,
4226                                                            com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4227                                                            assetCategory.getPrimaryKey());
4228                                            }
4229    
4230                                            for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4231                                                    listener.onBeforeRemoveAssociation(assetCategory.getPrimaryKey(),
4232                                                            AssetEntry.class.getName(), entryId);
4233                                            }
4234                                    }
4235                            }
4236    
4237                            _sqlUpdate.update(new Object[] { new Long(entryId) });
4238    
4239                            if ((listeners.length > 0) || (assetCategoryListeners.length > 0)) {
4240                                    for (com.liferay.portlet.asset.model.AssetCategory assetCategory : assetCategories) {
4241                                            for (ModelListener<AssetEntry> listener : listeners) {
4242                                                    listener.onAfterRemoveAssociation(entryId,
4243                                                            com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4244                                                            assetCategory.getPrimaryKey());
4245                                            }
4246    
4247                                            for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4248                                                    listener.onAfterRemoveAssociation(assetCategory.getPrimaryKey(),
4249                                                            AssetEntry.class.getName(), entryId);
4250                                            }
4251                                    }
4252                            }
4253                    }
4254    
4255                    private SqlUpdate _sqlUpdate;
4256            }
4257    
4258            protected class RemoveAssetCategory {
4259                    protected RemoveAssetCategory() {
4260                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4261                                            "DELETE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?",
4262                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4263                    }
4264    
4265                    protected void remove(long entryId, long categoryId)
4266                            throws SystemException {
4267                            if (containsAssetCategory.contains(entryId, categoryId)) {
4268                                    ModelListener<com.liferay.portlet.asset.model.AssetCategory>[] assetCategoryListeners =
4269                                            assetCategoryPersistence.getListeners();
4270    
4271                                    for (ModelListener<AssetEntry> listener : listeners) {
4272                                            listener.onBeforeRemoveAssociation(entryId,
4273                                                    com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4274                                                    categoryId);
4275                                    }
4276    
4277                                    for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4278                                            listener.onBeforeRemoveAssociation(categoryId,
4279                                                    AssetEntry.class.getName(), entryId);
4280                                    }
4281    
4282                                    _sqlUpdate.update(new Object[] {
4283                                                    new Long(entryId), new Long(categoryId)
4284                                            });
4285    
4286                                    for (ModelListener<AssetEntry> listener : listeners) {
4287                                            listener.onAfterRemoveAssociation(entryId,
4288                                                    com.liferay.portlet.asset.model.AssetCategory.class.getName(),
4289                                                    categoryId);
4290                                    }
4291    
4292                                    for (ModelListener<com.liferay.portlet.asset.model.AssetCategory> listener : assetCategoryListeners) {
4293                                            listener.onAfterRemoveAssociation(categoryId,
4294                                                    AssetEntry.class.getName(), entryId);
4295                                    }
4296                            }
4297                    }
4298    
4299                    private SqlUpdate _sqlUpdate;
4300            }
4301    
4302            protected class ContainsAssetTag {
4303                    protected ContainsAssetTag() {
4304                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4305                                            _SQL_CONTAINSASSETTAG,
4306                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4307                                            RowMapper.COUNT);
4308                    }
4309    
4310                    protected boolean contains(long entryId, long tagId) {
4311                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4312                                                    new Long(entryId), new Long(tagId)
4313                                            });
4314    
4315                            if (results.size() > 0) {
4316                                    Integer count = results.get(0);
4317    
4318                                    if (count.intValue() > 0) {
4319                                            return true;
4320                                    }
4321                            }
4322    
4323                            return false;
4324                    }
4325    
4326                    private MappingSqlQuery<Integer> _mappingSqlQuery;
4327            }
4328    
4329            protected class AddAssetTag {
4330                    protected AddAssetTag() {
4331                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4332                                            "INSERT INTO AssetEntries_AssetTags (entryId, tagId) VALUES (?, ?)",
4333                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4334                    }
4335    
4336                    protected void add(long entryId, long tagId) throws SystemException {
4337                            if (!containsAssetTag.contains(entryId, tagId)) {
4338                                    ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4339                                            assetTagPersistence.getListeners();
4340    
4341                                    for (ModelListener<AssetEntry> listener : listeners) {
4342                                            listener.onBeforeAddAssociation(entryId,
4343                                                    com.liferay.portlet.asset.model.AssetTag.class.getName(),
4344                                                    tagId);
4345                                    }
4346    
4347                                    for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4348                                            listener.onBeforeAddAssociation(tagId,
4349                                                    AssetEntry.class.getName(), entryId);
4350                                    }
4351    
4352                                    _sqlUpdate.update(new Object[] {
4353                                                    new Long(entryId), new Long(tagId)
4354                                            });
4355    
4356                                    for (ModelListener<AssetEntry> listener : listeners) {
4357                                            listener.onAfterAddAssociation(entryId,
4358                                                    com.liferay.portlet.asset.model.AssetTag.class.getName(),
4359                                                    tagId);
4360                                    }
4361    
4362                                    for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4363                                            listener.onAfterAddAssociation(tagId,
4364                                                    AssetEntry.class.getName(), entryId);
4365                                    }
4366                            }
4367                    }
4368    
4369                    private SqlUpdate _sqlUpdate;
4370            }
4371    
4372            protected class ClearAssetTags {
4373                    protected ClearAssetTags() {
4374                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4375                                            "DELETE FROM AssetEntries_AssetTags WHERE entryId = ?",
4376                                            new int[] { java.sql.Types.BIGINT });
4377                    }
4378    
4379                    protected void clear(long entryId) throws SystemException {
4380                            ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4381                                    assetTagPersistence.getListeners();
4382    
4383                            List<com.liferay.portlet.asset.model.AssetTag> assetTags = null;
4384    
4385                            if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
4386                                    assetTags = getAssetTags(entryId);
4387    
4388                                    for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4389                                            for (ModelListener<AssetEntry> listener : listeners) {
4390                                                    listener.onBeforeRemoveAssociation(entryId,
4391                                                            com.liferay.portlet.asset.model.AssetTag.class.getName(),
4392                                                            assetTag.getPrimaryKey());
4393                                            }
4394    
4395                                            for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4396                                                    listener.onBeforeRemoveAssociation(assetTag.getPrimaryKey(),
4397                                                            AssetEntry.class.getName(), entryId);
4398                                            }
4399                                    }
4400                            }
4401    
4402                            _sqlUpdate.update(new Object[] { new Long(entryId) });
4403    
4404                            if ((listeners.length > 0) || (assetTagListeners.length > 0)) {
4405                                    for (com.liferay.portlet.asset.model.AssetTag assetTag : assetTags) {
4406                                            for (ModelListener<AssetEntry> listener : listeners) {
4407                                                    listener.onAfterRemoveAssociation(entryId,
4408                                                            com.liferay.portlet.asset.model.AssetTag.class.getName(),
4409                                                            assetTag.getPrimaryKey());
4410                                            }
4411    
4412                                            for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4413                                                    listener.onAfterRemoveAssociation(assetTag.getPrimaryKey(),
4414                                                            AssetEntry.class.getName(), entryId);
4415                                            }
4416                                    }
4417                            }
4418                    }
4419    
4420                    private SqlUpdate _sqlUpdate;
4421            }
4422    
4423            protected class RemoveAssetTag {
4424                    protected RemoveAssetTag() {
4425                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4426                                            "DELETE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?",
4427                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4428                    }
4429    
4430                    protected void remove(long entryId, long tagId)
4431                            throws SystemException {
4432                            if (containsAssetTag.contains(entryId, tagId)) {
4433                                    ModelListener<com.liferay.portlet.asset.model.AssetTag>[] assetTagListeners =
4434                                            assetTagPersistence.getListeners();
4435    
4436                                    for (ModelListener<AssetEntry> listener : listeners) {
4437                                            listener.onBeforeRemoveAssociation(entryId,
4438                                                    com.liferay.portlet.asset.model.AssetTag.class.getName(),
4439                                                    tagId);
4440                                    }
4441    
4442                                    for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4443                                            listener.onBeforeRemoveAssociation(tagId,
4444                                                    AssetEntry.class.getName(), entryId);
4445                                    }
4446    
4447                                    _sqlUpdate.update(new Object[] {
4448                                                    new Long(entryId), new Long(tagId)
4449                                            });
4450    
4451                                    for (ModelListener<AssetEntry> listener : listeners) {
4452                                            listener.onAfterRemoveAssociation(entryId,
4453                                                    com.liferay.portlet.asset.model.AssetTag.class.getName(),
4454                                                    tagId);
4455                                    }
4456    
4457                                    for (ModelListener<com.liferay.portlet.asset.model.AssetTag> listener : assetTagListeners) {
4458                                            listener.onAfterRemoveAssociation(tagId,
4459                                                    AssetEntry.class.getName(), entryId);
4460                                    }
4461                            }
4462                    }
4463    
4464                    private SqlUpdate _sqlUpdate;
4465            }
4466    
4467            private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
4468            private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
4469            private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
4470            private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
4471            private static final String _SQL_GETASSETCATEGORIES = "SELECT {AssetCategory.*} FROM AssetCategory INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.categoryId = AssetCategory.categoryId) WHERE (AssetEntries_AssetCategories.entryId = ?)";
4472            private static final String _SQL_GETASSETCATEGORIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ?";
4473            private static final String _SQL_CONTAINSASSETCATEGORY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE entryId = ? AND categoryId = ?";
4474            private static final String _SQL_GETASSETTAGS = "SELECT {AssetTag.*} FROM AssetTag INNER JOIN AssetEntries_AssetTags ON (AssetEntries_AssetTags.tagId = AssetTag.tagId) WHERE (AssetEntries_AssetTags.entryId = ?)";
4475            private static final String _SQL_GETASSETTAGSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ?";
4476            private static final String _SQL_CONTAINSASSETTAG = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetTags WHERE entryId = ? AND tagId = ?";
4477            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
4478            private static final String _FINDER_COLUMN_VISIBLE_VISIBLE_2 = "assetEntry.visible = ?";
4479            private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1 = "assetEntry.publishDate IS NULL";
4480            private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2 = "assetEntry.publishDate = ?";
4481            private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1 = "assetEntry.expirationDate IS NULL";
4482            private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2 = "assetEntry.expirationDate = ?";
4483            private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
4484            private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
4485            private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
4486            private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = ?)";
4487            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
4488            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
4489            private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
4490            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
4491            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
4492            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4493            private static Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
4494            private static AssetEntry _nullAssetEntry = new AssetEntryImpl() {
4495                            @Override
4496                            public Object clone() {
4497                                    return this;
4498                            }
4499    
4500                            @Override
4501                            public CacheModel<AssetEntry> toCacheModel() {
4502                                    return _nullAssetEntryCacheModel;
4503                            }
4504                    };
4505    
4506            private static CacheModel<AssetEntry> _nullAssetEntryCacheModel = new CacheModel<AssetEntry>() {
4507                            public AssetEntry toEntityModel() {
4508                                    return _nullAssetEntry;
4509                            }
4510                    };
4511    }