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