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