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.asset.kernel.exception.NoSuchEntryException;
020    import com.liferay.asset.kernel.model.AssetEntry;
021    import com.liferay.asset.kernel.service.persistence.AssetCategoryPersistence;
022    import com.liferay.asset.kernel.service.persistence.AssetEntryPersistence;
023    import com.liferay.asset.kernel.service.persistence.AssetTagPersistence;
024    
025    import com.liferay.portal.kernel.bean.BeanReference;
026    import com.liferay.portal.kernel.dao.orm.EntityCache;
027    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
028    import com.liferay.portal.kernel.dao.orm.FinderCache;
029    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
030    import com.liferay.portal.kernel.dao.orm.FinderPath;
031    import com.liferay.portal.kernel.dao.orm.Query;
032    import com.liferay.portal.kernel.dao.orm.QueryPos;
033    import com.liferay.portal.kernel.dao.orm.QueryUtil;
034    import com.liferay.portal.kernel.dao.orm.Session;
035    import com.liferay.portal.kernel.log.Log;
036    import com.liferay.portal.kernel.log.LogFactoryUtil;
037    import com.liferay.portal.kernel.model.CacheModel;
038    import com.liferay.portal.kernel.service.ServiceContext;
039    import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
040    import com.liferay.portal.kernel.service.persistence.CompanyProvider;
041    import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
042    import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
043    import com.liferay.portal.kernel.service.persistence.impl.TableMapper;
044    import com.liferay.portal.kernel.service.persistence.impl.TableMapperFactory;
045    import com.liferay.portal.kernel.util.OrderByComparator;
046    import com.liferay.portal.kernel.util.SetUtil;
047    import com.liferay.portal.kernel.util.StringBundler;
048    import com.liferay.portal.kernel.util.StringPool;
049    import com.liferay.portal.kernel.util.StringUtil;
050    
051    import com.liferay.portlet.asset.model.impl.AssetEntryImpl;
052    import com.liferay.portlet.asset.model.impl.AssetEntryModelImpl;
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.Objects;
066    import java.util.Set;
067    
068    /**
069     * The persistence implementation for the asset entry service.
070     *
071     * <p>
072     * Caching information and settings can be found in <code>portal.properties</code>
073     * </p>
074     *
075     * @author Brian Wing Shun Chan
076     * @see AssetEntryPersistence
077     * @see com.liferay.asset.kernel.service.persistence.AssetEntryUtil
078     * @generated
079     */
080    @ProviderType
081    public class AssetEntryPersistenceImpl extends BasePersistenceImpl<AssetEntry>
082            implements AssetEntryPersistence {
083            /*
084             * NOTE FOR DEVELOPERS:
085             *
086             * 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.
087             */
088            public static final String FINDER_CLASS_NAME_ENTITY = AssetEntryImpl.class.getName();
089            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
090                    ".List1";
091            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092                    ".List2";
093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
094                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
095                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
096            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
097                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
099            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
100                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
102            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
103                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
104                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
105                            new String[] {
106                                    Long.class.getName(),
107                                    
108                            Integer.class.getName(), Integer.class.getName(),
109                                    OrderByComparator.class.getName()
110                            });
111            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
112                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
113                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
115                            new String[] { Long.class.getName() },
116                            AssetEntryModelImpl.GROUPID_COLUMN_BITMASK);
117            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
118                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
119                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
120                            new String[] { Long.class.getName() });
121    
122            /**
123             * Returns all the asset entries where groupId = &#63;.
124             *
125             * @param groupId the group ID
126             * @return the matching asset entries
127             */
128            @Override
129            public List<AssetEntry> findByGroupId(long groupId) {
130                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
131            }
132    
133            /**
134             * Returns a range of all the asset entries where groupId = &#63;.
135             *
136             * <p>
137             * 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.
138             * </p>
139             *
140             * @param groupId the group ID
141             * @param start the lower bound of the range of asset entries
142             * @param end the upper bound of the range of asset entries (not inclusive)
143             * @return the range of matching asset entries
144             */
145            @Override
146            public List<AssetEntry> findByGroupId(long groupId, int start, int end) {
147                    return findByGroupId(groupId, start, end, null);
148            }
149    
150            /**
151             * Returns an ordered range of all the asset entries where groupId = &#63;.
152             *
153             * <p>
154             * 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.
155             * </p>
156             *
157             * @param groupId the group ID
158             * @param start the lower bound of the range of asset entries
159             * @param end the upper bound of the range of asset entries (not inclusive)
160             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
161             * @return the ordered range of matching asset entries
162             */
163            @Override
164            public List<AssetEntry> findByGroupId(long groupId, int start, int end,
165                    OrderByComparator<AssetEntry> orderByComparator) {
166                    return findByGroupId(groupId, start, end, orderByComparator, true);
167            }
168    
169            /**
170             * Returns an ordered range of all the asset entries where groupId = &#63;.
171             *
172             * <p>
173             * 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.
174             * </p>
175             *
176             * @param groupId the group ID
177             * @param start the lower bound of the range of asset entries
178             * @param end the upper bound of the range of asset entries (not inclusive)
179             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
180             * @param retrieveFromCache whether to retrieve from the finder cache
181             * @return the ordered range of matching asset entries
182             */
183            @Override
184            public List<AssetEntry> findByGroupId(long groupId, int start, int end,
185                    OrderByComparator<AssetEntry> orderByComparator,
186                    boolean retrieveFromCache) {
187                    boolean pagination = true;
188                    FinderPath finderPath = null;
189                    Object[] finderArgs = null;
190    
191                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
192                                    (orderByComparator == null)) {
193                            pagination = false;
194                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
195                            finderArgs = new Object[] { groupId };
196                    }
197                    else {
198                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
199                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
200                    }
201    
202                    List<AssetEntry> list = null;
203    
204                    if (retrieveFromCache) {
205                            list = (List<AssetEntry>)finderCache.getResult(finderPath,
206                                            finderArgs, this);
207    
208                            if ((list != null) && !list.isEmpty()) {
209                                    for (AssetEntry assetEntry : list) {
210                                            if ((groupId != assetEntry.getGroupId())) {
211                                                    list = null;
212    
213                                                    break;
214                                            }
215                                    }
216                            }
217                    }
218    
219                    if (list == null) {
220                            StringBundler query = null;
221    
222                            if (orderByComparator != null) {
223                                    query = new StringBundler(3 +
224                                                    (orderByComparator.getOrderByFields().length * 2));
225                            }
226                            else {
227                                    query = new StringBundler(3);
228                            }
229    
230                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
231    
232                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
233    
234                            if (orderByComparator != null) {
235                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
236                                            orderByComparator);
237                            }
238                            else
239                             if (pagination) {
240                                    query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
241                            }
242    
243                            String sql = query.toString();
244    
245                            Session session = null;
246    
247                            try {
248                                    session = openSession();
249    
250                                    Query q = session.createQuery(sql);
251    
252                                    QueryPos qPos = QueryPos.getInstance(q);
253    
254                                    qPos.add(groupId);
255    
256                                    if (!pagination) {
257                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
258                                                            start, end, false);
259    
260                                            Collections.sort(list);
261    
262                                            list = Collections.unmodifiableList(list);
263                                    }
264                                    else {
265                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
266                                                            start, end);
267                                    }
268    
269                                    cacheResult(list);
270    
271                                    finderCache.putResult(finderPath, finderArgs, list);
272                            }
273                            catch (Exception e) {
274                                    finderCache.removeResult(finderPath, finderArgs);
275    
276                                    throw processException(e);
277                            }
278                            finally {
279                                    closeSession(session);
280                            }
281                    }
282    
283                    return list;
284            }
285    
286            /**
287             * Returns the first asset entry in the ordered set where groupId = &#63;.
288             *
289             * @param groupId the group ID
290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
291             * @return the first matching asset entry
292             * @throws NoSuchEntryException if a matching asset entry could not be found
293             */
294            @Override
295            public AssetEntry findByGroupId_First(long groupId,
296                    OrderByComparator<AssetEntry> orderByComparator)
297                    throws NoSuchEntryException {
298                    AssetEntry assetEntry = fetchByGroupId_First(groupId, orderByComparator);
299    
300                    if (assetEntry != null) {
301                            return assetEntry;
302                    }
303    
304                    StringBundler msg = new StringBundler(4);
305    
306                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
307    
308                    msg.append("groupId=");
309                    msg.append(groupId);
310    
311                    msg.append(StringPool.CLOSE_CURLY_BRACE);
312    
313                    throw new NoSuchEntryException(msg.toString());
314            }
315    
316            /**
317             * Returns the first asset entry in the ordered set where groupId = &#63;.
318             *
319             * @param groupId the group ID
320             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
321             * @return the first matching asset entry, or <code>null</code> if a matching asset entry could not be found
322             */
323            @Override
324            public AssetEntry fetchByGroupId_First(long groupId,
325                    OrderByComparator<AssetEntry> orderByComparator) {
326                    List<AssetEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
327    
328                    if (!list.isEmpty()) {
329                            return list.get(0);
330                    }
331    
332                    return null;
333            }
334    
335            /**
336             * Returns the last asset entry in the ordered set where groupId = &#63;.
337             *
338             * @param groupId the group ID
339             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
340             * @return the last matching asset entry
341             * @throws NoSuchEntryException if a matching asset entry could not be found
342             */
343            @Override
344            public AssetEntry findByGroupId_Last(long groupId,
345                    OrderByComparator<AssetEntry> orderByComparator)
346                    throws NoSuchEntryException {
347                    AssetEntry assetEntry = fetchByGroupId_Last(groupId, orderByComparator);
348    
349                    if (assetEntry != null) {
350                            return assetEntry;
351                    }
352    
353                    StringBundler msg = new StringBundler(4);
354    
355                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
356    
357                    msg.append("groupId=");
358                    msg.append(groupId);
359    
360                    msg.append(StringPool.CLOSE_CURLY_BRACE);
361    
362                    throw new NoSuchEntryException(msg.toString());
363            }
364    
365            /**
366             * Returns the last asset entry in the ordered set where groupId = &#63;.
367             *
368             * @param groupId the group ID
369             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
370             * @return the last matching asset entry, or <code>null</code> if a matching asset entry could not be found
371             */
372            @Override
373            public AssetEntry fetchByGroupId_Last(long groupId,
374                    OrderByComparator<AssetEntry> orderByComparator) {
375                    int count = countByGroupId(groupId);
376    
377                    if (count == 0) {
378                            return null;
379                    }
380    
381                    List<AssetEntry> list = findByGroupId(groupId, count - 1, count,
382                                    orderByComparator);
383    
384                    if (!list.isEmpty()) {
385                            return list.get(0);
386                    }
387    
388                    return null;
389            }
390    
391            /**
392             * Returns the asset entries before and after the current asset entry in the ordered set where groupId = &#63;.
393             *
394             * @param entryId the primary key of the current asset entry
395             * @param groupId the group ID
396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
397             * @return the previous, current, and next asset entry
398             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
399             */
400            @Override
401            public AssetEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
402                    OrderByComparator<AssetEntry> orderByComparator)
403                    throws NoSuchEntryException {
404                    AssetEntry assetEntry = findByPrimaryKey(entryId);
405    
406                    Session session = null;
407    
408                    try {
409                            session = openSession();
410    
411                            AssetEntry[] array = new AssetEntryImpl[3];
412    
413                            array[0] = getByGroupId_PrevAndNext(session, assetEntry, groupId,
414                                            orderByComparator, true);
415    
416                            array[1] = assetEntry;
417    
418                            array[2] = getByGroupId_PrevAndNext(session, assetEntry, groupId,
419                                            orderByComparator, false);
420    
421                            return array;
422                    }
423                    catch (Exception e) {
424                            throw processException(e);
425                    }
426                    finally {
427                            closeSession(session);
428                    }
429            }
430    
431            protected AssetEntry getByGroupId_PrevAndNext(Session session,
432                    AssetEntry assetEntry, long groupId,
433                    OrderByComparator<AssetEntry> orderByComparator, boolean previous) {
434                    StringBundler query = null;
435    
436                    if (orderByComparator != null) {
437                            query = new StringBundler(4 +
438                                            (orderByComparator.getOrderByConditionFields().length * 3) +
439                                            (orderByComparator.getOrderByFields().length * 3));
440                    }
441                    else {
442                            query = new StringBundler(3);
443                    }
444    
445                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
446    
447                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
448    
449                    if (orderByComparator != null) {
450                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
451    
452                            if (orderByConditionFields.length > 0) {
453                                    query.append(WHERE_AND);
454                            }
455    
456                            for (int i = 0; i < orderByConditionFields.length; i++) {
457                                    query.append(_ORDER_BY_ENTITY_ALIAS);
458                                    query.append(orderByConditionFields[i]);
459    
460                                    if ((i + 1) < orderByConditionFields.length) {
461                                            if (orderByComparator.isAscending() ^ previous) {
462                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
463                                            }
464                                            else {
465                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
466                                            }
467                                    }
468                                    else {
469                                            if (orderByComparator.isAscending() ^ previous) {
470                                                    query.append(WHERE_GREATER_THAN);
471                                            }
472                                            else {
473                                                    query.append(WHERE_LESSER_THAN);
474                                            }
475                                    }
476                            }
477    
478                            query.append(ORDER_BY_CLAUSE);
479    
480                            String[] orderByFields = orderByComparator.getOrderByFields();
481    
482                            for (int i = 0; i < orderByFields.length; i++) {
483                                    query.append(_ORDER_BY_ENTITY_ALIAS);
484                                    query.append(orderByFields[i]);
485    
486                                    if ((i + 1) < orderByFields.length) {
487                                            if (orderByComparator.isAscending() ^ previous) {
488                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
489                                            }
490                                            else {
491                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
492                                            }
493                                    }
494                                    else {
495                                            if (orderByComparator.isAscending() ^ previous) {
496                                                    query.append(ORDER_BY_ASC);
497                                            }
498                                            else {
499                                                    query.append(ORDER_BY_DESC);
500                                            }
501                                    }
502                            }
503                    }
504                    else {
505                            query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
506                    }
507    
508                    String sql = query.toString();
509    
510                    Query q = session.createQuery(sql);
511    
512                    q.setFirstResult(0);
513                    q.setMaxResults(2);
514    
515                    QueryPos qPos = QueryPos.getInstance(q);
516    
517                    qPos.add(groupId);
518    
519                    if (orderByComparator != null) {
520                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
521    
522                            for (Object value : values) {
523                                    qPos.add(value);
524                            }
525                    }
526    
527                    List<AssetEntry> list = q.list();
528    
529                    if (list.size() == 2) {
530                            return list.get(1);
531                    }
532                    else {
533                            return null;
534                    }
535            }
536    
537            /**
538             * Removes all the asset entries where groupId = &#63; from the database.
539             *
540             * @param groupId the group ID
541             */
542            @Override
543            public void removeByGroupId(long groupId) {
544                    for (AssetEntry assetEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
545                                    QueryUtil.ALL_POS, null)) {
546                            remove(assetEntry);
547                    }
548            }
549    
550            /**
551             * Returns the number of asset entries where groupId = &#63;.
552             *
553             * @param groupId the group ID
554             * @return the number of matching asset entries
555             */
556            @Override
557            public int countByGroupId(long groupId) {
558                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
559    
560                    Object[] finderArgs = new Object[] { groupId };
561    
562                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
563    
564                    if (count == null) {
565                            StringBundler query = new StringBundler(2);
566    
567                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
568    
569                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
570    
571                            String sql = query.toString();
572    
573                            Session session = null;
574    
575                            try {
576                                    session = openSession();
577    
578                                    Query q = session.createQuery(sql);
579    
580                                    QueryPos qPos = QueryPos.getInstance(q);
581    
582                                    qPos.add(groupId);
583    
584                                    count = (Long)q.uniqueResult();
585    
586                                    finderCache.putResult(finderPath, finderArgs, count);
587                            }
588                            catch (Exception e) {
589                                    finderCache.removeResult(finderPath, finderArgs);
590    
591                                    throw processException(e);
592                            }
593                            finally {
594                                    closeSession(session);
595                            }
596                    }
597    
598                    return count.intValue();
599            }
600    
601            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetEntry.groupId = ?";
602            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
603                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
604                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
605                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
606                            new String[] {
607                                    Long.class.getName(),
608                                    
609                            Integer.class.getName(), Integer.class.getName(),
610                                    OrderByComparator.class.getName()
611                            });
612            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
613                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
614                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
615                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
616                            new String[] { Long.class.getName() },
617                            AssetEntryModelImpl.COMPANYID_COLUMN_BITMASK);
618            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
619                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
620                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
621                            new String[] { Long.class.getName() });
622    
623            /**
624             * Returns all the asset entries where companyId = &#63;.
625             *
626             * @param companyId the company ID
627             * @return the matching asset entries
628             */
629            @Override
630            public List<AssetEntry> findByCompanyId(long companyId) {
631                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
632                            null);
633            }
634    
635            /**
636             * Returns a range of all the asset entries where companyId = &#63;.
637             *
638             * <p>
639             * 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.
640             * </p>
641             *
642             * @param companyId the company ID
643             * @param start the lower bound of the range of asset entries
644             * @param end the upper bound of the range of asset entries (not inclusive)
645             * @return the range of matching asset entries
646             */
647            @Override
648            public List<AssetEntry> findByCompanyId(long companyId, int start, int end) {
649                    return findByCompanyId(companyId, start, end, null);
650            }
651    
652            /**
653             * Returns an ordered range of all the asset entries where companyId = &#63;.
654             *
655             * <p>
656             * 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.
657             * </p>
658             *
659             * @param companyId the company ID
660             * @param start the lower bound of the range of asset entries
661             * @param end the upper bound of the range of asset entries (not inclusive)
662             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
663             * @return the ordered range of matching asset entries
664             */
665            @Override
666            public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
667                    OrderByComparator<AssetEntry> orderByComparator) {
668                    return findByCompanyId(companyId, start, end, orderByComparator, true);
669            }
670    
671            /**
672             * Returns an ordered range of all the asset entries where companyId = &#63;.
673             *
674             * <p>
675             * 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.
676             * </p>
677             *
678             * @param companyId the company ID
679             * @param start the lower bound of the range of asset entries
680             * @param end the upper bound of the range of asset entries (not inclusive)
681             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
682             * @param retrieveFromCache whether to retrieve from the finder cache
683             * @return the ordered range of matching asset entries
684             */
685            @Override
686            public List<AssetEntry> findByCompanyId(long companyId, int start, int end,
687                    OrderByComparator<AssetEntry> orderByComparator,
688                    boolean retrieveFromCache) {
689                    boolean pagination = true;
690                    FinderPath finderPath = null;
691                    Object[] finderArgs = null;
692    
693                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
694                                    (orderByComparator == null)) {
695                            pagination = false;
696                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
697                            finderArgs = new Object[] { companyId };
698                    }
699                    else {
700                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
701                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
702                    }
703    
704                    List<AssetEntry> list = null;
705    
706                    if (retrieveFromCache) {
707                            list = (List<AssetEntry>)finderCache.getResult(finderPath,
708                                            finderArgs, this);
709    
710                            if ((list != null) && !list.isEmpty()) {
711                                    for (AssetEntry assetEntry : list) {
712                                            if ((companyId != assetEntry.getCompanyId())) {
713                                                    list = null;
714    
715                                                    break;
716                                            }
717                                    }
718                            }
719                    }
720    
721                    if (list == null) {
722                            StringBundler query = null;
723    
724                            if (orderByComparator != null) {
725                                    query = new StringBundler(3 +
726                                                    (orderByComparator.getOrderByFields().length * 2));
727                            }
728                            else {
729                                    query = new StringBundler(3);
730                            }
731    
732                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
733    
734                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
735    
736                            if (orderByComparator != null) {
737                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
738                                            orderByComparator);
739                            }
740                            else
741                             if (pagination) {
742                                    query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
743                            }
744    
745                            String sql = query.toString();
746    
747                            Session session = null;
748    
749                            try {
750                                    session = openSession();
751    
752                                    Query q = session.createQuery(sql);
753    
754                                    QueryPos qPos = QueryPos.getInstance(q);
755    
756                                    qPos.add(companyId);
757    
758                                    if (!pagination) {
759                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
760                                                            start, end, false);
761    
762                                            Collections.sort(list);
763    
764                                            list = Collections.unmodifiableList(list);
765                                    }
766                                    else {
767                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
768                                                            start, end);
769                                    }
770    
771                                    cacheResult(list);
772    
773                                    finderCache.putResult(finderPath, finderArgs, list);
774                            }
775                            catch (Exception e) {
776                                    finderCache.removeResult(finderPath, finderArgs);
777    
778                                    throw processException(e);
779                            }
780                            finally {
781                                    closeSession(session);
782                            }
783                    }
784    
785                    return list;
786            }
787    
788            /**
789             * Returns the first asset entry in the ordered set where companyId = &#63;.
790             *
791             * @param companyId the company ID
792             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
793             * @return the first matching asset entry
794             * @throws NoSuchEntryException if a matching asset entry could not be found
795             */
796            @Override
797            public AssetEntry findByCompanyId_First(long companyId,
798                    OrderByComparator<AssetEntry> orderByComparator)
799                    throws NoSuchEntryException {
800                    AssetEntry assetEntry = fetchByCompanyId_First(companyId,
801                                    orderByComparator);
802    
803                    if (assetEntry != null) {
804                            return assetEntry;
805                    }
806    
807                    StringBundler msg = new StringBundler(4);
808    
809                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
810    
811                    msg.append("companyId=");
812                    msg.append(companyId);
813    
814                    msg.append(StringPool.CLOSE_CURLY_BRACE);
815    
816                    throw new NoSuchEntryException(msg.toString());
817            }
818    
819            /**
820             * Returns the first asset entry in the ordered set where companyId = &#63;.
821             *
822             * @param companyId the company ID
823             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
824             * @return the first matching asset entry, or <code>null</code> if a matching asset entry could not be found
825             */
826            @Override
827            public AssetEntry fetchByCompanyId_First(long companyId,
828                    OrderByComparator<AssetEntry> orderByComparator) {
829                    List<AssetEntry> list = findByCompanyId(companyId, 0, 1,
830                                    orderByComparator);
831    
832                    if (!list.isEmpty()) {
833                            return list.get(0);
834                    }
835    
836                    return null;
837            }
838    
839            /**
840             * Returns the last asset entry in the ordered set where companyId = &#63;.
841             *
842             * @param companyId the company ID
843             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
844             * @return the last matching asset entry
845             * @throws NoSuchEntryException if a matching asset entry could not be found
846             */
847            @Override
848            public AssetEntry findByCompanyId_Last(long companyId,
849                    OrderByComparator<AssetEntry> orderByComparator)
850                    throws NoSuchEntryException {
851                    AssetEntry assetEntry = fetchByCompanyId_Last(companyId,
852                                    orderByComparator);
853    
854                    if (assetEntry != null) {
855                            return assetEntry;
856                    }
857    
858                    StringBundler msg = new StringBundler(4);
859    
860                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
861    
862                    msg.append("companyId=");
863                    msg.append(companyId);
864    
865                    msg.append(StringPool.CLOSE_CURLY_BRACE);
866    
867                    throw new NoSuchEntryException(msg.toString());
868            }
869    
870            /**
871             * Returns the last asset entry in the ordered set where companyId = &#63;.
872             *
873             * @param companyId the company ID
874             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
875             * @return the last matching asset entry, or <code>null</code> if a matching asset entry could not be found
876             */
877            @Override
878            public AssetEntry fetchByCompanyId_Last(long companyId,
879                    OrderByComparator<AssetEntry> orderByComparator) {
880                    int count = countByCompanyId(companyId);
881    
882                    if (count == 0) {
883                            return null;
884                    }
885    
886                    List<AssetEntry> list = findByCompanyId(companyId, count - 1, count,
887                                    orderByComparator);
888    
889                    if (!list.isEmpty()) {
890                            return list.get(0);
891                    }
892    
893                    return null;
894            }
895    
896            /**
897             * Returns the asset entries before and after the current asset entry in the ordered set where companyId = &#63;.
898             *
899             * @param entryId the primary key of the current asset entry
900             * @param companyId the company ID
901             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
902             * @return the previous, current, and next asset entry
903             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
904             */
905            @Override
906            public AssetEntry[] findByCompanyId_PrevAndNext(long entryId,
907                    long companyId, OrderByComparator<AssetEntry> orderByComparator)
908                    throws NoSuchEntryException {
909                    AssetEntry assetEntry = findByPrimaryKey(entryId);
910    
911                    Session session = null;
912    
913                    try {
914                            session = openSession();
915    
916                            AssetEntry[] array = new AssetEntryImpl[3];
917    
918                            array[0] = getByCompanyId_PrevAndNext(session, assetEntry,
919                                            companyId, orderByComparator, true);
920    
921                            array[1] = assetEntry;
922    
923                            array[2] = getByCompanyId_PrevAndNext(session, assetEntry,
924                                            companyId, orderByComparator, false);
925    
926                            return array;
927                    }
928                    catch (Exception e) {
929                            throw processException(e);
930                    }
931                    finally {
932                            closeSession(session);
933                    }
934            }
935    
936            protected AssetEntry getByCompanyId_PrevAndNext(Session session,
937                    AssetEntry assetEntry, long companyId,
938                    OrderByComparator<AssetEntry> orderByComparator, boolean previous) {
939                    StringBundler query = null;
940    
941                    if (orderByComparator != null) {
942                            query = new StringBundler(4 +
943                                            (orderByComparator.getOrderByConditionFields().length * 3) +
944                                            (orderByComparator.getOrderByFields().length * 3));
945                    }
946                    else {
947                            query = new StringBundler(3);
948                    }
949    
950                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
951    
952                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
953    
954                    if (orderByComparator != null) {
955                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
956    
957                            if (orderByConditionFields.length > 0) {
958                                    query.append(WHERE_AND);
959                            }
960    
961                            for (int i = 0; i < orderByConditionFields.length; i++) {
962                                    query.append(_ORDER_BY_ENTITY_ALIAS);
963                                    query.append(orderByConditionFields[i]);
964    
965                                    if ((i + 1) < orderByConditionFields.length) {
966                                            if (orderByComparator.isAscending() ^ previous) {
967                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
968                                            }
969                                            else {
970                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
971                                            }
972                                    }
973                                    else {
974                                            if (orderByComparator.isAscending() ^ previous) {
975                                                    query.append(WHERE_GREATER_THAN);
976                                            }
977                                            else {
978                                                    query.append(WHERE_LESSER_THAN);
979                                            }
980                                    }
981                            }
982    
983                            query.append(ORDER_BY_CLAUSE);
984    
985                            String[] orderByFields = orderByComparator.getOrderByFields();
986    
987                            for (int i = 0; i < orderByFields.length; i++) {
988                                    query.append(_ORDER_BY_ENTITY_ALIAS);
989                                    query.append(orderByFields[i]);
990    
991                                    if ((i + 1) < orderByFields.length) {
992                                            if (orderByComparator.isAscending() ^ previous) {
993                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
994                                            }
995                                            else {
996                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
997                                            }
998                                    }
999                                    else {
1000                                            if (orderByComparator.isAscending() ^ previous) {
1001                                                    query.append(ORDER_BY_ASC);
1002                                            }
1003                                            else {
1004                                                    query.append(ORDER_BY_DESC);
1005                                            }
1006                                    }
1007                            }
1008                    }
1009                    else {
1010                            query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1011                    }
1012    
1013                    String sql = query.toString();
1014    
1015                    Query q = session.createQuery(sql);
1016    
1017                    q.setFirstResult(0);
1018                    q.setMaxResults(2);
1019    
1020                    QueryPos qPos = QueryPos.getInstance(q);
1021    
1022                    qPos.add(companyId);
1023    
1024                    if (orderByComparator != null) {
1025                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1026    
1027                            for (Object value : values) {
1028                                    qPos.add(value);
1029                            }
1030                    }
1031    
1032                    List<AssetEntry> list = q.list();
1033    
1034                    if (list.size() == 2) {
1035                            return list.get(1);
1036                    }
1037                    else {
1038                            return null;
1039                    }
1040            }
1041    
1042            /**
1043             * Removes all the asset entries where companyId = &#63; from the database.
1044             *
1045             * @param companyId the company ID
1046             */
1047            @Override
1048            public void removeByCompanyId(long companyId) {
1049                    for (AssetEntry assetEntry : findByCompanyId(companyId,
1050                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1051                            remove(assetEntry);
1052                    }
1053            }
1054    
1055            /**
1056             * Returns the number of asset entries where companyId = &#63;.
1057             *
1058             * @param companyId the company ID
1059             * @return the number of matching asset entries
1060             */
1061            @Override
1062            public int countByCompanyId(long companyId) {
1063                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1064    
1065                    Object[] finderArgs = new Object[] { companyId };
1066    
1067                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1068    
1069                    if (count == null) {
1070                            StringBundler query = new StringBundler(2);
1071    
1072                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1073    
1074                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1075    
1076                            String sql = query.toString();
1077    
1078                            Session session = null;
1079    
1080                            try {
1081                                    session = openSession();
1082    
1083                                    Query q = session.createQuery(sql);
1084    
1085                                    QueryPos qPos = QueryPos.getInstance(q);
1086    
1087                                    qPos.add(companyId);
1088    
1089                                    count = (Long)q.uniqueResult();
1090    
1091                                    finderCache.putResult(finderPath, finderArgs, count);
1092                            }
1093                            catch (Exception e) {
1094                                    finderCache.removeResult(finderPath, finderArgs);
1095    
1096                                    throw processException(e);
1097                            }
1098                            finally {
1099                                    closeSession(session);
1100                            }
1101                    }
1102    
1103                    return count.intValue();
1104            }
1105    
1106            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetEntry.companyId = ?";
1107            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1108                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1109                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVisible",
1110                            new String[] {
1111                                    Boolean.class.getName(),
1112                                    
1113                            Integer.class.getName(), Integer.class.getName(),
1114                                    OrderByComparator.class.getName()
1115                            });
1116            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE =
1117                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1118                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1119                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVisible",
1120                            new String[] { Boolean.class.getName() },
1121                            AssetEntryModelImpl.VISIBLE_COLUMN_BITMASK);
1122            public static final FinderPath FINDER_PATH_COUNT_BY_VISIBLE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1123                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1124                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVisible",
1125                            new String[] { Boolean.class.getName() });
1126    
1127            /**
1128             * Returns all the asset entries where visible = &#63;.
1129             *
1130             * @param visible the visible
1131             * @return the matching asset entries
1132             */
1133            @Override
1134            public List<AssetEntry> findByVisible(boolean visible) {
1135                    return findByVisible(visible, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1136            }
1137    
1138            /**
1139             * Returns a range of all the asset entries where visible = &#63;.
1140             *
1141             * <p>
1142             * 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.
1143             * </p>
1144             *
1145             * @param visible the visible
1146             * @param start the lower bound of the range of asset entries
1147             * @param end the upper bound of the range of asset entries (not inclusive)
1148             * @return the range of matching asset entries
1149             */
1150            @Override
1151            public List<AssetEntry> findByVisible(boolean visible, int start, int end) {
1152                    return findByVisible(visible, start, end, null);
1153            }
1154    
1155            /**
1156             * Returns an ordered range of all the asset entries where visible = &#63;.
1157             *
1158             * <p>
1159             * 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.
1160             * </p>
1161             *
1162             * @param visible the visible
1163             * @param start the lower bound of the range of asset entries
1164             * @param end the upper bound of the range of asset entries (not inclusive)
1165             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1166             * @return the ordered range of matching asset entries
1167             */
1168            @Override
1169            public List<AssetEntry> findByVisible(boolean visible, int start, int end,
1170                    OrderByComparator<AssetEntry> orderByComparator) {
1171                    return findByVisible(visible, start, end, orderByComparator, true);
1172            }
1173    
1174            /**
1175             * Returns an ordered range of all the asset entries where visible = &#63;.
1176             *
1177             * <p>
1178             * 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.
1179             * </p>
1180             *
1181             * @param visible the visible
1182             * @param start the lower bound of the range of asset entries
1183             * @param end the upper bound of the range of asset entries (not inclusive)
1184             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1185             * @param retrieveFromCache whether to retrieve from the finder cache
1186             * @return the ordered range of matching asset entries
1187             */
1188            @Override
1189            public List<AssetEntry> findByVisible(boolean visible, int start, int end,
1190                    OrderByComparator<AssetEntry> orderByComparator,
1191                    boolean retrieveFromCache) {
1192                    boolean pagination = true;
1193                    FinderPath finderPath = null;
1194                    Object[] finderArgs = null;
1195    
1196                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1197                                    (orderByComparator == null)) {
1198                            pagination = false;
1199                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE;
1200                            finderArgs = new Object[] { visible };
1201                    }
1202                    else {
1203                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VISIBLE;
1204                            finderArgs = new Object[] { visible, start, end, orderByComparator };
1205                    }
1206    
1207                    List<AssetEntry> list = null;
1208    
1209                    if (retrieveFromCache) {
1210                            list = (List<AssetEntry>)finderCache.getResult(finderPath,
1211                                            finderArgs, this);
1212    
1213                            if ((list != null) && !list.isEmpty()) {
1214                                    for (AssetEntry assetEntry : list) {
1215                                            if ((visible != assetEntry.getVisible())) {
1216                                                    list = null;
1217    
1218                                                    break;
1219                                            }
1220                                    }
1221                            }
1222                    }
1223    
1224                    if (list == null) {
1225                            StringBundler query = null;
1226    
1227                            if (orderByComparator != null) {
1228                                    query = new StringBundler(3 +
1229                                                    (orderByComparator.getOrderByFields().length * 2));
1230                            }
1231                            else {
1232                                    query = new StringBundler(3);
1233                            }
1234    
1235                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1236    
1237                            query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1238    
1239                            if (orderByComparator != null) {
1240                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1241                                            orderByComparator);
1242                            }
1243                            else
1244                             if (pagination) {
1245                                    query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1246                            }
1247    
1248                            String sql = query.toString();
1249    
1250                            Session session = null;
1251    
1252                            try {
1253                                    session = openSession();
1254    
1255                                    Query q = session.createQuery(sql);
1256    
1257                                    QueryPos qPos = QueryPos.getInstance(q);
1258    
1259                                    qPos.add(visible);
1260    
1261                                    if (!pagination) {
1262                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1263                                                            start, end, false);
1264    
1265                                            Collections.sort(list);
1266    
1267                                            list = Collections.unmodifiableList(list);
1268                                    }
1269                                    else {
1270                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1271                                                            start, end);
1272                                    }
1273    
1274                                    cacheResult(list);
1275    
1276                                    finderCache.putResult(finderPath, finderArgs, list);
1277                            }
1278                            catch (Exception e) {
1279                                    finderCache.removeResult(finderPath, finderArgs);
1280    
1281                                    throw processException(e);
1282                            }
1283                            finally {
1284                                    closeSession(session);
1285                            }
1286                    }
1287    
1288                    return list;
1289            }
1290    
1291            /**
1292             * Returns the first asset entry in the ordered set where visible = &#63;.
1293             *
1294             * @param visible the visible
1295             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1296             * @return the first matching asset entry
1297             * @throws NoSuchEntryException if a matching asset entry could not be found
1298             */
1299            @Override
1300            public AssetEntry findByVisible_First(boolean visible,
1301                    OrderByComparator<AssetEntry> orderByComparator)
1302                    throws NoSuchEntryException {
1303                    AssetEntry assetEntry = fetchByVisible_First(visible, orderByComparator);
1304    
1305                    if (assetEntry != null) {
1306                            return assetEntry;
1307                    }
1308    
1309                    StringBundler msg = new StringBundler(4);
1310    
1311                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1312    
1313                    msg.append("visible=");
1314                    msg.append(visible);
1315    
1316                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1317    
1318                    throw new NoSuchEntryException(msg.toString());
1319            }
1320    
1321            /**
1322             * Returns the first asset entry in the ordered set where visible = &#63;.
1323             *
1324             * @param visible the visible
1325             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1326             * @return the first matching asset entry, or <code>null</code> if a matching asset entry could not be found
1327             */
1328            @Override
1329            public AssetEntry fetchByVisible_First(boolean visible,
1330                    OrderByComparator<AssetEntry> orderByComparator) {
1331                    List<AssetEntry> list = findByVisible(visible, 0, 1, orderByComparator);
1332    
1333                    if (!list.isEmpty()) {
1334                            return list.get(0);
1335                    }
1336    
1337                    return null;
1338            }
1339    
1340            /**
1341             * Returns the last asset entry in the ordered set where visible = &#63;.
1342             *
1343             * @param visible the visible
1344             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1345             * @return the last matching asset entry
1346             * @throws NoSuchEntryException if a matching asset entry could not be found
1347             */
1348            @Override
1349            public AssetEntry findByVisible_Last(boolean visible,
1350                    OrderByComparator<AssetEntry> orderByComparator)
1351                    throws NoSuchEntryException {
1352                    AssetEntry assetEntry = fetchByVisible_Last(visible, orderByComparator);
1353    
1354                    if (assetEntry != null) {
1355                            return assetEntry;
1356                    }
1357    
1358                    StringBundler msg = new StringBundler(4);
1359    
1360                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1361    
1362                    msg.append("visible=");
1363                    msg.append(visible);
1364    
1365                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1366    
1367                    throw new NoSuchEntryException(msg.toString());
1368            }
1369    
1370            /**
1371             * Returns the last asset entry in the ordered set where visible = &#63;.
1372             *
1373             * @param visible the visible
1374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1375             * @return the last matching asset entry, or <code>null</code> if a matching asset entry could not be found
1376             */
1377            @Override
1378            public AssetEntry fetchByVisible_Last(boolean visible,
1379                    OrderByComparator<AssetEntry> orderByComparator) {
1380                    int count = countByVisible(visible);
1381    
1382                    if (count == 0) {
1383                            return null;
1384                    }
1385    
1386                    List<AssetEntry> list = findByVisible(visible, count - 1, count,
1387                                    orderByComparator);
1388    
1389                    if (!list.isEmpty()) {
1390                            return list.get(0);
1391                    }
1392    
1393                    return null;
1394            }
1395    
1396            /**
1397             * Returns the asset entries before and after the current asset entry in the ordered set where visible = &#63;.
1398             *
1399             * @param entryId the primary key of the current asset entry
1400             * @param visible the visible
1401             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1402             * @return the previous, current, and next asset entry
1403             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
1404             */
1405            @Override
1406            public AssetEntry[] findByVisible_PrevAndNext(long entryId,
1407                    boolean visible, OrderByComparator<AssetEntry> orderByComparator)
1408                    throws NoSuchEntryException {
1409                    AssetEntry assetEntry = findByPrimaryKey(entryId);
1410    
1411                    Session session = null;
1412    
1413                    try {
1414                            session = openSession();
1415    
1416                            AssetEntry[] array = new AssetEntryImpl[3];
1417    
1418                            array[0] = getByVisible_PrevAndNext(session, assetEntry, visible,
1419                                            orderByComparator, true);
1420    
1421                            array[1] = assetEntry;
1422    
1423                            array[2] = getByVisible_PrevAndNext(session, assetEntry, visible,
1424                                            orderByComparator, false);
1425    
1426                            return array;
1427                    }
1428                    catch (Exception e) {
1429                            throw processException(e);
1430                    }
1431                    finally {
1432                            closeSession(session);
1433                    }
1434            }
1435    
1436            protected AssetEntry getByVisible_PrevAndNext(Session session,
1437                    AssetEntry assetEntry, boolean visible,
1438                    OrderByComparator<AssetEntry> orderByComparator, boolean previous) {
1439                    StringBundler query = null;
1440    
1441                    if (orderByComparator != null) {
1442                            query = new StringBundler(4 +
1443                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1444                                            (orderByComparator.getOrderByFields().length * 3));
1445                    }
1446                    else {
1447                            query = new StringBundler(3);
1448                    }
1449    
1450                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1451    
1452                    query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1453    
1454                    if (orderByComparator != null) {
1455                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1456    
1457                            if (orderByConditionFields.length > 0) {
1458                                    query.append(WHERE_AND);
1459                            }
1460    
1461                            for (int i = 0; i < orderByConditionFields.length; i++) {
1462                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1463                                    query.append(orderByConditionFields[i]);
1464    
1465                                    if ((i + 1) < orderByConditionFields.length) {
1466                                            if (orderByComparator.isAscending() ^ previous) {
1467                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1468                                            }
1469                                            else {
1470                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1471                                            }
1472                                    }
1473                                    else {
1474                                            if (orderByComparator.isAscending() ^ previous) {
1475                                                    query.append(WHERE_GREATER_THAN);
1476                                            }
1477                                            else {
1478                                                    query.append(WHERE_LESSER_THAN);
1479                                            }
1480                                    }
1481                            }
1482    
1483                            query.append(ORDER_BY_CLAUSE);
1484    
1485                            String[] orderByFields = orderByComparator.getOrderByFields();
1486    
1487                            for (int i = 0; i < orderByFields.length; i++) {
1488                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1489                                    query.append(orderByFields[i]);
1490    
1491                                    if ((i + 1) < orderByFields.length) {
1492                                            if (orderByComparator.isAscending() ^ previous) {
1493                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1494                                            }
1495                                            else {
1496                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1497                                            }
1498                                    }
1499                                    else {
1500                                            if (orderByComparator.isAscending() ^ previous) {
1501                                                    query.append(ORDER_BY_ASC);
1502                                            }
1503                                            else {
1504                                                    query.append(ORDER_BY_DESC);
1505                                            }
1506                                    }
1507                            }
1508                    }
1509                    else {
1510                            query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1511                    }
1512    
1513                    String sql = query.toString();
1514    
1515                    Query q = session.createQuery(sql);
1516    
1517                    q.setFirstResult(0);
1518                    q.setMaxResults(2);
1519    
1520                    QueryPos qPos = QueryPos.getInstance(q);
1521    
1522                    qPos.add(visible);
1523    
1524                    if (orderByComparator != null) {
1525                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
1526    
1527                            for (Object value : values) {
1528                                    qPos.add(value);
1529                            }
1530                    }
1531    
1532                    List<AssetEntry> list = q.list();
1533    
1534                    if (list.size() == 2) {
1535                            return list.get(1);
1536                    }
1537                    else {
1538                            return null;
1539                    }
1540            }
1541    
1542            /**
1543             * Removes all the asset entries where visible = &#63; from the database.
1544             *
1545             * @param visible the visible
1546             */
1547            @Override
1548            public void removeByVisible(boolean visible) {
1549                    for (AssetEntry assetEntry : findByVisible(visible, QueryUtil.ALL_POS,
1550                                    QueryUtil.ALL_POS, null)) {
1551                            remove(assetEntry);
1552                    }
1553            }
1554    
1555            /**
1556             * Returns the number of asset entries where visible = &#63;.
1557             *
1558             * @param visible the visible
1559             * @return the number of matching asset entries
1560             */
1561            @Override
1562            public int countByVisible(boolean visible) {
1563                    FinderPath finderPath = FINDER_PATH_COUNT_BY_VISIBLE;
1564    
1565                    Object[] finderArgs = new Object[] { visible };
1566    
1567                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1568    
1569                    if (count == null) {
1570                            StringBundler query = new StringBundler(2);
1571    
1572                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
1573    
1574                            query.append(_FINDER_COLUMN_VISIBLE_VISIBLE_2);
1575    
1576                            String sql = query.toString();
1577    
1578                            Session session = null;
1579    
1580                            try {
1581                                    session = openSession();
1582    
1583                                    Query q = session.createQuery(sql);
1584    
1585                                    QueryPos qPos = QueryPos.getInstance(q);
1586    
1587                                    qPos.add(visible);
1588    
1589                                    count = (Long)q.uniqueResult();
1590    
1591                                    finderCache.putResult(finderPath, finderArgs, count);
1592                            }
1593                            catch (Exception e) {
1594                                    finderCache.removeResult(finderPath, finderArgs);
1595    
1596                                    throw processException(e);
1597                            }
1598                            finally {
1599                                    closeSession(session);
1600                            }
1601                    }
1602    
1603                    return count.intValue();
1604            }
1605    
1606            private static final String _FINDER_COLUMN_VISIBLE_VISIBLE_2 = "assetEntry.visible = ?";
1607            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE =
1608                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1609                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1610                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPublishDate",
1611                            new String[] {
1612                                    Date.class.getName(),
1613                                    
1614                            Integer.class.getName(), Integer.class.getName(),
1615                                    OrderByComparator.class.getName()
1616                            });
1617            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE =
1618                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1619                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
1620                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPublishDate",
1621                            new String[] { Date.class.getName() },
1622                            AssetEntryModelImpl.PUBLISHDATE_COLUMN_BITMASK);
1623            public static final FinderPath FINDER_PATH_COUNT_BY_PUBLISHDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
1624                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1625                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPublishDate",
1626                            new String[] { Date.class.getName() });
1627    
1628            /**
1629             * Returns all the asset entries where publishDate = &#63;.
1630             *
1631             * @param publishDate the publish date
1632             * @return the matching asset entries
1633             */
1634            @Override
1635            public List<AssetEntry> findByPublishDate(Date publishDate) {
1636                    return findByPublishDate(publishDate, QueryUtil.ALL_POS,
1637                            QueryUtil.ALL_POS, null);
1638            }
1639    
1640            /**
1641             * Returns a range of all the asset entries where publishDate = &#63;.
1642             *
1643             * <p>
1644             * 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.
1645             * </p>
1646             *
1647             * @param publishDate the publish date
1648             * @param start the lower bound of the range of asset entries
1649             * @param end the upper bound of the range of asset entries (not inclusive)
1650             * @return the range of matching asset entries
1651             */
1652            @Override
1653            public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1654                    int end) {
1655                    return findByPublishDate(publishDate, start, end, null);
1656            }
1657    
1658            /**
1659             * Returns an ordered range of all the asset entries where publishDate = &#63;.
1660             *
1661             * <p>
1662             * 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.
1663             * </p>
1664             *
1665             * @param publishDate the publish date
1666             * @param start the lower bound of the range of asset entries
1667             * @param end the upper bound of the range of asset entries (not inclusive)
1668             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1669             * @return the ordered range of matching asset entries
1670             */
1671            @Override
1672            public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1673                    int end, OrderByComparator<AssetEntry> orderByComparator) {
1674                    return findByPublishDate(publishDate, start, end, orderByComparator,
1675                            true);
1676            }
1677    
1678            /**
1679             * Returns an ordered range of all the asset entries where publishDate = &#63;.
1680             *
1681             * <p>
1682             * 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.
1683             * </p>
1684             *
1685             * @param publishDate the publish date
1686             * @param start the lower bound of the range of asset entries
1687             * @param end the upper bound of the range of asset entries (not inclusive)
1688             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1689             * @param retrieveFromCache whether to retrieve from the finder cache
1690             * @return the ordered range of matching asset entries
1691             */
1692            @Override
1693            public List<AssetEntry> findByPublishDate(Date publishDate, int start,
1694                    int end, OrderByComparator<AssetEntry> orderByComparator,
1695                    boolean retrieveFromCache) {
1696                    boolean pagination = true;
1697                    FinderPath finderPath = null;
1698                    Object[] finderArgs = null;
1699    
1700                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1701                                    (orderByComparator == null)) {
1702                            pagination = false;
1703                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE;
1704                            finderArgs = new Object[] { publishDate };
1705                    }
1706                    else {
1707                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PUBLISHDATE;
1708                            finderArgs = new Object[] { publishDate, start, end, orderByComparator };
1709                    }
1710    
1711                    List<AssetEntry> list = null;
1712    
1713                    if (retrieveFromCache) {
1714                            list = (List<AssetEntry>)finderCache.getResult(finderPath,
1715                                            finderArgs, this);
1716    
1717                            if ((list != null) && !list.isEmpty()) {
1718                                    for (AssetEntry assetEntry : list) {
1719                                            if (!Objects.equals(publishDate, 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 (!Objects.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 (!Objects.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.isDebugEnabled()) {
3282                                    _log.debug(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                                            !Objects.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.isDebugEnabled()) {
3543                                    _log.debug(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.isDebugEnabled()) {
3963                                            _log.debug(_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.kernel.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.isDebugEnabled()) {
4248                                    _log.debug(_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.asset.kernel.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.asset.kernel.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.asset.kernel.model.AssetCategory> getAssetCategories(
4669                    long pk, int start, int end,
4670                    OrderByComparator<com.liferay.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.model.AssetCategory> assetCategories) {
4867                    for (com.liferay.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.model.AssetTag> getAssetTags(long pk,
4976                    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.asset.kernel.model.AssetTag> getAssetTags(long pk,
4995                    int start, int end,
4996                    OrderByComparator<com.liferay.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.model.AssetTag> assetTags) {
5191                    for (com.liferay.asset.kernel.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.asset.kernel.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.asset.kernel.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.asset.kernel.model.AssetCategory> assetEntryToAssetCategoryTableMapper;
5296            @BeanReference(type = AssetTagPersistence.class)
5297            protected AssetTagPersistence assetTagPersistence;
5298            protected TableMapper<AssetEntry, com.liferay.asset.kernel.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    }