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