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    import com.liferay.portal.kernel.util.Validator;
051    
052    import com.liferay.portlet.asset.model.impl.AssetEntryImpl;
053    import com.liferay.portlet.asset.model.impl.AssetEntryModelImpl;
054    
055    import java.io.Serializable;
056    
057    import java.sql.Timestamp;
058    
059    import java.util.Collections;
060    import java.util.Date;
061    import java.util.HashMap;
062    import java.util.HashSet;
063    import java.util.Iterator;
064    import java.util.List;
065    import java.util.Map;
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 (!Validator.equals(publishDate,
1720                                                                    assetEntry.getPublishDate())) {
1721                                                    list = null;
1722    
1723                                                    break;
1724                                            }
1725                                    }
1726                            }
1727                    }
1728    
1729                    if (list == null) {
1730                            StringBundler query = null;
1731    
1732                            if (orderByComparator != null) {
1733                                    query = new StringBundler(3 +
1734                                                    (orderByComparator.getOrderByFields().length * 2));
1735                            }
1736                            else {
1737                                    query = new StringBundler(3);
1738                            }
1739    
1740                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1741    
1742                            boolean bindPublishDate = false;
1743    
1744                            if (publishDate == null) {
1745                                    query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1746                            }
1747                            else {
1748                                    bindPublishDate = true;
1749    
1750                                    query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1751                            }
1752    
1753                            if (orderByComparator != null) {
1754                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1755                                            orderByComparator);
1756                            }
1757                            else
1758                             if (pagination) {
1759                                    query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
1760                            }
1761    
1762                            String sql = query.toString();
1763    
1764                            Session session = null;
1765    
1766                            try {
1767                                    session = openSession();
1768    
1769                                    Query q = session.createQuery(sql);
1770    
1771                                    QueryPos qPos = QueryPos.getInstance(q);
1772    
1773                                    if (bindPublishDate) {
1774                                            qPos.add(new Timestamp(publishDate.getTime()));
1775                                    }
1776    
1777                                    if (!pagination) {
1778                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1779                                                            start, end, false);
1780    
1781                                            Collections.sort(list);
1782    
1783                                            list = Collections.unmodifiableList(list);
1784                                    }
1785                                    else {
1786                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
1787                                                            start, end);
1788                                    }
1789    
1790                                    cacheResult(list);
1791    
1792                                    finderCache.putResult(finderPath, finderArgs, list);
1793                            }
1794                            catch (Exception e) {
1795                                    finderCache.removeResult(finderPath, finderArgs);
1796    
1797                                    throw processException(e);
1798                            }
1799                            finally {
1800                                    closeSession(session);
1801                            }
1802                    }
1803    
1804                    return list;
1805            }
1806    
1807            /**
1808             * Returns the first asset entry in the ordered set where publishDate = &#63;.
1809             *
1810             * @param publishDate the publish date
1811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1812             * @return the first matching asset entry
1813             * @throws NoSuchEntryException if a matching asset entry could not be found
1814             */
1815            @Override
1816            public AssetEntry findByPublishDate_First(Date publishDate,
1817                    OrderByComparator<AssetEntry> orderByComparator)
1818                    throws NoSuchEntryException {
1819                    AssetEntry assetEntry = fetchByPublishDate_First(publishDate,
1820                                    orderByComparator);
1821    
1822                    if (assetEntry != null) {
1823                            return assetEntry;
1824                    }
1825    
1826                    StringBundler msg = new StringBundler(4);
1827    
1828                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1829    
1830                    msg.append("publishDate=");
1831                    msg.append(publishDate);
1832    
1833                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1834    
1835                    throw new NoSuchEntryException(msg.toString());
1836            }
1837    
1838            /**
1839             * Returns the first asset entry in the ordered set where publishDate = &#63;.
1840             *
1841             * @param publishDate the publish date
1842             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1843             * @return the first matching asset entry, or <code>null</code> if a matching asset entry could not be found
1844             */
1845            @Override
1846            public AssetEntry fetchByPublishDate_First(Date publishDate,
1847                    OrderByComparator<AssetEntry> orderByComparator) {
1848                    List<AssetEntry> list = findByPublishDate(publishDate, 0, 1,
1849                                    orderByComparator);
1850    
1851                    if (!list.isEmpty()) {
1852                            return list.get(0);
1853                    }
1854    
1855                    return null;
1856            }
1857    
1858            /**
1859             * Returns the last asset entry in the ordered set where publishDate = &#63;.
1860             *
1861             * @param publishDate the publish date
1862             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1863             * @return the last matching asset entry
1864             * @throws NoSuchEntryException if a matching asset entry could not be found
1865             */
1866            @Override
1867            public AssetEntry findByPublishDate_Last(Date publishDate,
1868                    OrderByComparator<AssetEntry> orderByComparator)
1869                    throws NoSuchEntryException {
1870                    AssetEntry assetEntry = fetchByPublishDate_Last(publishDate,
1871                                    orderByComparator);
1872    
1873                    if (assetEntry != null) {
1874                            return assetEntry;
1875                    }
1876    
1877                    StringBundler msg = new StringBundler(4);
1878    
1879                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1880    
1881                    msg.append("publishDate=");
1882                    msg.append(publishDate);
1883    
1884                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1885    
1886                    throw new NoSuchEntryException(msg.toString());
1887            }
1888    
1889            /**
1890             * Returns the last asset entry in the ordered set where publishDate = &#63;.
1891             *
1892             * @param publishDate the publish date
1893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1894             * @return the last matching asset entry, or <code>null</code> if a matching asset entry could not be found
1895             */
1896            @Override
1897            public AssetEntry fetchByPublishDate_Last(Date publishDate,
1898                    OrderByComparator<AssetEntry> orderByComparator) {
1899                    int count = countByPublishDate(publishDate);
1900    
1901                    if (count == 0) {
1902                            return null;
1903                    }
1904    
1905                    List<AssetEntry> list = findByPublishDate(publishDate, count - 1,
1906                                    count, orderByComparator);
1907    
1908                    if (!list.isEmpty()) {
1909                            return list.get(0);
1910                    }
1911    
1912                    return null;
1913            }
1914    
1915            /**
1916             * Returns the asset entries before and after the current asset entry in the ordered set where publishDate = &#63;.
1917             *
1918             * @param entryId the primary key of the current asset entry
1919             * @param publishDate the publish date
1920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1921             * @return the previous, current, and next asset entry
1922             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
1923             */
1924            @Override
1925            public AssetEntry[] findByPublishDate_PrevAndNext(long entryId,
1926                    Date publishDate, OrderByComparator<AssetEntry> orderByComparator)
1927                    throws NoSuchEntryException {
1928                    AssetEntry assetEntry = findByPrimaryKey(entryId);
1929    
1930                    Session session = null;
1931    
1932                    try {
1933                            session = openSession();
1934    
1935                            AssetEntry[] array = new AssetEntryImpl[3];
1936    
1937                            array[0] = getByPublishDate_PrevAndNext(session, assetEntry,
1938                                            publishDate, orderByComparator, true);
1939    
1940                            array[1] = assetEntry;
1941    
1942                            array[2] = getByPublishDate_PrevAndNext(session, assetEntry,
1943                                            publishDate, orderByComparator, false);
1944    
1945                            return array;
1946                    }
1947                    catch (Exception e) {
1948                            throw processException(e);
1949                    }
1950                    finally {
1951                            closeSession(session);
1952                    }
1953            }
1954    
1955            protected AssetEntry getByPublishDate_PrevAndNext(Session session,
1956                    AssetEntry assetEntry, Date publishDate,
1957                    OrderByComparator<AssetEntry> orderByComparator, boolean previous) {
1958                    StringBundler query = null;
1959    
1960                    if (orderByComparator != null) {
1961                            query = new StringBundler(4 +
1962                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1963                                            (orderByComparator.getOrderByFields().length * 3));
1964                    }
1965                    else {
1966                            query = new StringBundler(3);
1967                    }
1968    
1969                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
1970    
1971                    boolean bindPublishDate = false;
1972    
1973                    if (publishDate == null) {
1974                            query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
1975                    }
1976                    else {
1977                            bindPublishDate = true;
1978    
1979                            query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
1980                    }
1981    
1982                    if (orderByComparator != null) {
1983                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1984    
1985                            if (orderByConditionFields.length > 0) {
1986                                    query.append(WHERE_AND);
1987                            }
1988    
1989                            for (int i = 0; i < orderByConditionFields.length; i++) {
1990                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1991                                    query.append(orderByConditionFields[i]);
1992    
1993                                    if ((i + 1) < orderByConditionFields.length) {
1994                                            if (orderByComparator.isAscending() ^ previous) {
1995                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1996                                            }
1997                                            else {
1998                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1999                                            }
2000                                    }
2001                                    else {
2002                                            if (orderByComparator.isAscending() ^ previous) {
2003                                                    query.append(WHERE_GREATER_THAN);
2004                                            }
2005                                            else {
2006                                                    query.append(WHERE_LESSER_THAN);
2007                                            }
2008                                    }
2009                            }
2010    
2011                            query.append(ORDER_BY_CLAUSE);
2012    
2013                            String[] orderByFields = orderByComparator.getOrderByFields();
2014    
2015                            for (int i = 0; i < orderByFields.length; i++) {
2016                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2017                                    query.append(orderByFields[i]);
2018    
2019                                    if ((i + 1) < orderByFields.length) {
2020                                            if (orderByComparator.isAscending() ^ previous) {
2021                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2022                                            }
2023                                            else {
2024                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2025                                            }
2026                                    }
2027                                    else {
2028                                            if (orderByComparator.isAscending() ^ previous) {
2029                                                    query.append(ORDER_BY_ASC);
2030                                            }
2031                                            else {
2032                                                    query.append(ORDER_BY_DESC);
2033                                            }
2034                                    }
2035                            }
2036                    }
2037                    else {
2038                            query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2039                    }
2040    
2041                    String sql = query.toString();
2042    
2043                    Query q = session.createQuery(sql);
2044    
2045                    q.setFirstResult(0);
2046                    q.setMaxResults(2);
2047    
2048                    QueryPos qPos = QueryPos.getInstance(q);
2049    
2050                    if (bindPublishDate) {
2051                            qPos.add(new Timestamp(publishDate.getTime()));
2052                    }
2053    
2054                    if (orderByComparator != null) {
2055                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
2056    
2057                            for (Object value : values) {
2058                                    qPos.add(value);
2059                            }
2060                    }
2061    
2062                    List<AssetEntry> list = q.list();
2063    
2064                    if (list.size() == 2) {
2065                            return list.get(1);
2066                    }
2067                    else {
2068                            return null;
2069                    }
2070            }
2071    
2072            /**
2073             * Removes all the asset entries where publishDate = &#63; from the database.
2074             *
2075             * @param publishDate the publish date
2076             */
2077            @Override
2078            public void removeByPublishDate(Date publishDate) {
2079                    for (AssetEntry assetEntry : findByPublishDate(publishDate,
2080                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2081                            remove(assetEntry);
2082                    }
2083            }
2084    
2085            /**
2086             * Returns the number of asset entries where publishDate = &#63;.
2087             *
2088             * @param publishDate the publish date
2089             * @return the number of matching asset entries
2090             */
2091            @Override
2092            public int countByPublishDate(Date publishDate) {
2093                    FinderPath finderPath = FINDER_PATH_COUNT_BY_PUBLISHDATE;
2094    
2095                    Object[] finderArgs = new Object[] { publishDate };
2096    
2097                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2098    
2099                    if (count == null) {
2100                            StringBundler query = new StringBundler(2);
2101    
2102                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2103    
2104                            boolean bindPublishDate = false;
2105    
2106                            if (publishDate == null) {
2107                                    query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1);
2108                            }
2109                            else {
2110                                    bindPublishDate = true;
2111    
2112                                    query.append(_FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2);
2113                            }
2114    
2115                            String sql = query.toString();
2116    
2117                            Session session = null;
2118    
2119                            try {
2120                                    session = openSession();
2121    
2122                                    Query q = session.createQuery(sql);
2123    
2124                                    QueryPos qPos = QueryPos.getInstance(q);
2125    
2126                                    if (bindPublishDate) {
2127                                            qPos.add(new Timestamp(publishDate.getTime()));
2128                                    }
2129    
2130                                    count = (Long)q.uniqueResult();
2131    
2132                                    finderCache.putResult(finderPath, finderArgs, count);
2133                            }
2134                            catch (Exception e) {
2135                                    finderCache.removeResult(finderPath, finderArgs);
2136    
2137                                    throw processException(e);
2138                            }
2139                            finally {
2140                                    closeSession(session);
2141                            }
2142                    }
2143    
2144                    return count.intValue();
2145            }
2146    
2147            private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_1 = "assetEntry.publishDate IS NULL";
2148            private static final String _FINDER_COLUMN_PUBLISHDATE_PUBLISHDATE_2 = "assetEntry.publishDate = ?";
2149            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE =
2150                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2151                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2152                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByExpirationDate",
2153                            new String[] {
2154                                    Date.class.getName(),
2155                                    
2156                            Integer.class.getName(), Integer.class.getName(),
2157                                    OrderByComparator.class.getName()
2158                            });
2159            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE =
2160                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2161                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2162                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByExpirationDate",
2163                            new String[] { Date.class.getName() },
2164                            AssetEntryModelImpl.EXPIRATIONDATE_COLUMN_BITMASK);
2165            public static final FinderPath FINDER_PATH_COUNT_BY_EXPIRATIONDATE = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2166                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2167                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByExpirationDate",
2168                            new String[] { Date.class.getName() });
2169    
2170            /**
2171             * Returns all the asset entries where expirationDate = &#63;.
2172             *
2173             * @param expirationDate the expiration date
2174             * @return the matching asset entries
2175             */
2176            @Override
2177            public List<AssetEntry> findByExpirationDate(Date expirationDate) {
2178                    return findByExpirationDate(expirationDate, QueryUtil.ALL_POS,
2179                            QueryUtil.ALL_POS, null);
2180            }
2181    
2182            /**
2183             * Returns a range of all the asset entries where expirationDate = &#63;.
2184             *
2185             * <p>
2186             * 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.
2187             * </p>
2188             *
2189             * @param expirationDate the expiration date
2190             * @param start the lower bound of the range of asset entries
2191             * @param end the upper bound of the range of asset entries (not inclusive)
2192             * @return the range of matching asset entries
2193             */
2194            @Override
2195            public List<AssetEntry> findByExpirationDate(Date expirationDate,
2196                    int start, int end) {
2197                    return findByExpirationDate(expirationDate, start, end, null);
2198            }
2199    
2200            /**
2201             * Returns an ordered range of all the asset entries where expirationDate = &#63;.
2202             *
2203             * <p>
2204             * 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.
2205             * </p>
2206             *
2207             * @param expirationDate the expiration date
2208             * @param start the lower bound of the range of asset entries
2209             * @param end the upper bound of the range of asset entries (not inclusive)
2210             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2211             * @return the ordered range of matching asset entries
2212             */
2213            @Override
2214            public List<AssetEntry> findByExpirationDate(Date expirationDate,
2215                    int start, int end, OrderByComparator<AssetEntry> orderByComparator) {
2216                    return findByExpirationDate(expirationDate, start, end,
2217                            orderByComparator, true);
2218            }
2219    
2220            /**
2221             * Returns an ordered range of all the asset entries where expirationDate = &#63;.
2222             *
2223             * <p>
2224             * 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.
2225             * </p>
2226             *
2227             * @param expirationDate the expiration date
2228             * @param start the lower bound of the range of asset entries
2229             * @param end the upper bound of the range of asset entries (not inclusive)
2230             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2231             * @param retrieveFromCache whether to retrieve from the finder cache
2232             * @return the ordered range of matching asset entries
2233             */
2234            @Override
2235            public List<AssetEntry> findByExpirationDate(Date expirationDate,
2236                    int start, int end, OrderByComparator<AssetEntry> orderByComparator,
2237                    boolean retrieveFromCache) {
2238                    boolean pagination = true;
2239                    FinderPath finderPath = null;
2240                    Object[] finderArgs = null;
2241    
2242                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2243                                    (orderByComparator == null)) {
2244                            pagination = false;
2245                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE;
2246                            finderArgs = new Object[] { expirationDate };
2247                    }
2248                    else {
2249                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EXPIRATIONDATE;
2250                            finderArgs = new Object[] {
2251                                            expirationDate,
2252                                            
2253                                            start, end, orderByComparator
2254                                    };
2255                    }
2256    
2257                    List<AssetEntry> list = null;
2258    
2259                    if (retrieveFromCache) {
2260                            list = (List<AssetEntry>)finderCache.getResult(finderPath,
2261                                            finderArgs, this);
2262    
2263                            if ((list != null) && !list.isEmpty()) {
2264                                    for (AssetEntry assetEntry : list) {
2265                                            if (!Validator.equals(expirationDate,
2266                                                                    assetEntry.getExpirationDate())) {
2267                                                    list = null;
2268    
2269                                                    break;
2270                                            }
2271                                    }
2272                            }
2273                    }
2274    
2275                    if (list == null) {
2276                            StringBundler query = null;
2277    
2278                            if (orderByComparator != null) {
2279                                    query = new StringBundler(3 +
2280                                                    (orderByComparator.getOrderByFields().length * 2));
2281                            }
2282                            else {
2283                                    query = new StringBundler(3);
2284                            }
2285    
2286                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2287    
2288                            boolean bindExpirationDate = false;
2289    
2290                            if (expirationDate == null) {
2291                                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2292                            }
2293                            else {
2294                                    bindExpirationDate = true;
2295    
2296                                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2297                            }
2298    
2299                            if (orderByComparator != null) {
2300                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2301                                            orderByComparator);
2302                            }
2303                            else
2304                             if (pagination) {
2305                                    query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2306                            }
2307    
2308                            String sql = query.toString();
2309    
2310                            Session session = null;
2311    
2312                            try {
2313                                    session = openSession();
2314    
2315                                    Query q = session.createQuery(sql);
2316    
2317                                    QueryPos qPos = QueryPos.getInstance(q);
2318    
2319                                    if (bindExpirationDate) {
2320                                            qPos.add(new Timestamp(expirationDate.getTime()));
2321                                    }
2322    
2323                                    if (!pagination) {
2324                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2325                                                            start, end, false);
2326    
2327                                            Collections.sort(list);
2328    
2329                                            list = Collections.unmodifiableList(list);
2330                                    }
2331                                    else {
2332                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2333                                                            start, end);
2334                                    }
2335    
2336                                    cacheResult(list);
2337    
2338                                    finderCache.putResult(finderPath, finderArgs, list);
2339                            }
2340                            catch (Exception e) {
2341                                    finderCache.removeResult(finderPath, finderArgs);
2342    
2343                                    throw processException(e);
2344                            }
2345                            finally {
2346                                    closeSession(session);
2347                            }
2348                    }
2349    
2350                    return list;
2351            }
2352    
2353            /**
2354             * Returns the first asset entry in the ordered set where expirationDate = &#63;.
2355             *
2356             * @param expirationDate the expiration date
2357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2358             * @return the first matching asset entry
2359             * @throws NoSuchEntryException if a matching asset entry could not be found
2360             */
2361            @Override
2362            public AssetEntry findByExpirationDate_First(Date expirationDate,
2363                    OrderByComparator<AssetEntry> orderByComparator)
2364                    throws NoSuchEntryException {
2365                    AssetEntry assetEntry = fetchByExpirationDate_First(expirationDate,
2366                                    orderByComparator);
2367    
2368                    if (assetEntry != null) {
2369                            return assetEntry;
2370                    }
2371    
2372                    StringBundler msg = new StringBundler(4);
2373    
2374                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2375    
2376                    msg.append("expirationDate=");
2377                    msg.append(expirationDate);
2378    
2379                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2380    
2381                    throw new NoSuchEntryException(msg.toString());
2382            }
2383    
2384            /**
2385             * Returns the first asset entry in the ordered set where expirationDate = &#63;.
2386             *
2387             * @param expirationDate the expiration date
2388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2389             * @return the first matching asset entry, or <code>null</code> if a matching asset entry could not be found
2390             */
2391            @Override
2392            public AssetEntry fetchByExpirationDate_First(Date expirationDate,
2393                    OrderByComparator<AssetEntry> orderByComparator) {
2394                    List<AssetEntry> list = findByExpirationDate(expirationDate, 0, 1,
2395                                    orderByComparator);
2396    
2397                    if (!list.isEmpty()) {
2398                            return list.get(0);
2399                    }
2400    
2401                    return null;
2402            }
2403    
2404            /**
2405             * Returns the last asset entry in the ordered set where expirationDate = &#63;.
2406             *
2407             * @param expirationDate the expiration date
2408             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2409             * @return the last matching asset entry
2410             * @throws NoSuchEntryException if a matching asset entry could not be found
2411             */
2412            @Override
2413            public AssetEntry findByExpirationDate_Last(Date expirationDate,
2414                    OrderByComparator<AssetEntry> orderByComparator)
2415                    throws NoSuchEntryException {
2416                    AssetEntry assetEntry = fetchByExpirationDate_Last(expirationDate,
2417                                    orderByComparator);
2418    
2419                    if (assetEntry != null) {
2420                            return assetEntry;
2421                    }
2422    
2423                    StringBundler msg = new StringBundler(4);
2424    
2425                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2426    
2427                    msg.append("expirationDate=");
2428                    msg.append(expirationDate);
2429    
2430                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2431    
2432                    throw new NoSuchEntryException(msg.toString());
2433            }
2434    
2435            /**
2436             * Returns the last asset entry in the ordered set where expirationDate = &#63;.
2437             *
2438             * @param expirationDate the expiration date
2439             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2440             * @return the last matching asset entry, or <code>null</code> if a matching asset entry could not be found
2441             */
2442            @Override
2443            public AssetEntry fetchByExpirationDate_Last(Date expirationDate,
2444                    OrderByComparator<AssetEntry> orderByComparator) {
2445                    int count = countByExpirationDate(expirationDate);
2446    
2447                    if (count == 0) {
2448                            return null;
2449                    }
2450    
2451                    List<AssetEntry> list = findByExpirationDate(expirationDate, count - 1,
2452                                    count, orderByComparator);
2453    
2454                    if (!list.isEmpty()) {
2455                            return list.get(0);
2456                    }
2457    
2458                    return null;
2459            }
2460    
2461            /**
2462             * Returns the asset entries before and after the current asset entry in the ordered set where expirationDate = &#63;.
2463             *
2464             * @param entryId the primary key of the current asset entry
2465             * @param expirationDate the expiration date
2466             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2467             * @return the previous, current, and next asset entry
2468             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
2469             */
2470            @Override
2471            public AssetEntry[] findByExpirationDate_PrevAndNext(long entryId,
2472                    Date expirationDate, OrderByComparator<AssetEntry> orderByComparator)
2473                    throws NoSuchEntryException {
2474                    AssetEntry assetEntry = findByPrimaryKey(entryId);
2475    
2476                    Session session = null;
2477    
2478                    try {
2479                            session = openSession();
2480    
2481                            AssetEntry[] array = new AssetEntryImpl[3];
2482    
2483                            array[0] = getByExpirationDate_PrevAndNext(session, assetEntry,
2484                                            expirationDate, orderByComparator, true);
2485    
2486                            array[1] = assetEntry;
2487    
2488                            array[2] = getByExpirationDate_PrevAndNext(session, assetEntry,
2489                                            expirationDate, orderByComparator, false);
2490    
2491                            return array;
2492                    }
2493                    catch (Exception e) {
2494                            throw processException(e);
2495                    }
2496                    finally {
2497                            closeSession(session);
2498                    }
2499            }
2500    
2501            protected AssetEntry getByExpirationDate_PrevAndNext(Session session,
2502                    AssetEntry assetEntry, Date expirationDate,
2503                    OrderByComparator<AssetEntry> orderByComparator, boolean previous) {
2504                    StringBundler query = null;
2505    
2506                    if (orderByComparator != null) {
2507                            query = new StringBundler(4 +
2508                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2509                                            (orderByComparator.getOrderByFields().length * 3));
2510                    }
2511                    else {
2512                            query = new StringBundler(3);
2513                    }
2514    
2515                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2516    
2517                    boolean bindExpirationDate = false;
2518    
2519                    if (expirationDate == null) {
2520                            query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2521                    }
2522                    else {
2523                            bindExpirationDate = true;
2524    
2525                            query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2526                    }
2527    
2528                    if (orderByComparator != null) {
2529                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2530    
2531                            if (orderByConditionFields.length > 0) {
2532                                    query.append(WHERE_AND);
2533                            }
2534    
2535                            for (int i = 0; i < orderByConditionFields.length; i++) {
2536                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2537                                    query.append(orderByConditionFields[i]);
2538    
2539                                    if ((i + 1) < orderByConditionFields.length) {
2540                                            if (orderByComparator.isAscending() ^ previous) {
2541                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2542                                            }
2543                                            else {
2544                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2545                                            }
2546                                    }
2547                                    else {
2548                                            if (orderByComparator.isAscending() ^ previous) {
2549                                                    query.append(WHERE_GREATER_THAN);
2550                                            }
2551                                            else {
2552                                                    query.append(WHERE_LESSER_THAN);
2553                                            }
2554                                    }
2555                            }
2556    
2557                            query.append(ORDER_BY_CLAUSE);
2558    
2559                            String[] orderByFields = orderByComparator.getOrderByFields();
2560    
2561                            for (int i = 0; i < orderByFields.length; i++) {
2562                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2563                                    query.append(orderByFields[i]);
2564    
2565                                    if ((i + 1) < orderByFields.length) {
2566                                            if (orderByComparator.isAscending() ^ previous) {
2567                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2568                                            }
2569                                            else {
2570                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2571                                            }
2572                                    }
2573                                    else {
2574                                            if (orderByComparator.isAscending() ^ previous) {
2575                                                    query.append(ORDER_BY_ASC);
2576                                            }
2577                                            else {
2578                                                    query.append(ORDER_BY_DESC);
2579                                            }
2580                                    }
2581                            }
2582                    }
2583                    else {
2584                            query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2585                    }
2586    
2587                    String sql = query.toString();
2588    
2589                    Query q = session.createQuery(sql);
2590    
2591                    q.setFirstResult(0);
2592                    q.setMaxResults(2);
2593    
2594                    QueryPos qPos = QueryPos.getInstance(q);
2595    
2596                    if (bindExpirationDate) {
2597                            qPos.add(new Timestamp(expirationDate.getTime()));
2598                    }
2599    
2600                    if (orderByComparator != null) {
2601                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
2602    
2603                            for (Object value : values) {
2604                                    qPos.add(value);
2605                            }
2606                    }
2607    
2608                    List<AssetEntry> list = q.list();
2609    
2610                    if (list.size() == 2) {
2611                            return list.get(1);
2612                    }
2613                    else {
2614                            return null;
2615                    }
2616            }
2617    
2618            /**
2619             * Removes all the asset entries where expirationDate = &#63; from the database.
2620             *
2621             * @param expirationDate the expiration date
2622             */
2623            @Override
2624            public void removeByExpirationDate(Date expirationDate) {
2625                    for (AssetEntry assetEntry : findByExpirationDate(expirationDate,
2626                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2627                            remove(assetEntry);
2628                    }
2629            }
2630    
2631            /**
2632             * Returns the number of asset entries where expirationDate = &#63;.
2633             *
2634             * @param expirationDate the expiration date
2635             * @return the number of matching asset entries
2636             */
2637            @Override
2638            public int countByExpirationDate(Date expirationDate) {
2639                    FinderPath finderPath = FINDER_PATH_COUNT_BY_EXPIRATIONDATE;
2640    
2641                    Object[] finderArgs = new Object[] { expirationDate };
2642    
2643                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2644    
2645                    if (count == null) {
2646                            StringBundler query = new StringBundler(2);
2647    
2648                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
2649    
2650                            boolean bindExpirationDate = false;
2651    
2652                            if (expirationDate == null) {
2653                                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1);
2654                            }
2655                            else {
2656                                    bindExpirationDate = true;
2657    
2658                                    query.append(_FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2);
2659                            }
2660    
2661                            String sql = query.toString();
2662    
2663                            Session session = null;
2664    
2665                            try {
2666                                    session = openSession();
2667    
2668                                    Query q = session.createQuery(sql);
2669    
2670                                    QueryPos qPos = QueryPos.getInstance(q);
2671    
2672                                    if (bindExpirationDate) {
2673                                            qPos.add(new Timestamp(expirationDate.getTime()));
2674                                    }
2675    
2676                                    count = (Long)q.uniqueResult();
2677    
2678                                    finderCache.putResult(finderPath, finderArgs, count);
2679                            }
2680                            catch (Exception e) {
2681                                    finderCache.removeResult(finderPath, finderArgs);
2682    
2683                                    throw processException(e);
2684                            }
2685                            finally {
2686                                    closeSession(session);
2687                            }
2688                    }
2689    
2690                    return count.intValue();
2691            }
2692    
2693            private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_1 = "assetEntry.expirationDate IS NULL";
2694            private static final String _FINDER_COLUMN_EXPIRATIONDATE_EXPIRATIONDATE_2 = "assetEntry.expirationDate = ?";
2695            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID =
2696                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2697                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2698                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLayoutUuid",
2699                            new String[] {
2700                                    String.class.getName(),
2701                                    
2702                            Integer.class.getName(), Integer.class.getName(),
2703                                    OrderByComparator.class.getName()
2704                            });
2705            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID =
2706                    new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2707                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
2708                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutUuid",
2709                            new String[] { String.class.getName() },
2710                            AssetEntryModelImpl.LAYOUTUUID_COLUMN_BITMASK);
2711            public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTUUID = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
2712                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2713                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutUuid",
2714                            new String[] { String.class.getName() });
2715    
2716            /**
2717             * Returns all the asset entries where layoutUuid = &#63;.
2718             *
2719             * @param layoutUuid the layout uuid
2720             * @return the matching asset entries
2721             */
2722            @Override
2723            public List<AssetEntry> findByLayoutUuid(String layoutUuid) {
2724                    return findByLayoutUuid(layoutUuid, QueryUtil.ALL_POS,
2725                            QueryUtil.ALL_POS, null);
2726            }
2727    
2728            /**
2729             * Returns a range of all the asset entries where layoutUuid = &#63;.
2730             *
2731             * <p>
2732             * 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.
2733             * </p>
2734             *
2735             * @param layoutUuid the layout uuid
2736             * @param start the lower bound of the range of asset entries
2737             * @param end the upper bound of the range of asset entries (not inclusive)
2738             * @return the range of matching asset entries
2739             */
2740            @Override
2741            public List<AssetEntry> findByLayoutUuid(String layoutUuid, int start,
2742                    int end) {
2743                    return findByLayoutUuid(layoutUuid, start, end, null);
2744            }
2745    
2746            /**
2747             * Returns an ordered range of all the asset entries where layoutUuid = &#63;.
2748             *
2749             * <p>
2750             * 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.
2751             * </p>
2752             *
2753             * @param layoutUuid the layout uuid
2754             * @param start the lower bound of the range of asset entries
2755             * @param end the upper bound of the range of asset entries (not inclusive)
2756             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2757             * @return the ordered range of matching asset entries
2758             */
2759            @Override
2760            public List<AssetEntry> findByLayoutUuid(String layoutUuid, int start,
2761                    int end, OrderByComparator<AssetEntry> orderByComparator) {
2762                    return findByLayoutUuid(layoutUuid, start, end, orderByComparator, true);
2763            }
2764    
2765            /**
2766             * Returns an ordered range of all the asset entries where layoutUuid = &#63;.
2767             *
2768             * <p>
2769             * 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.
2770             * </p>
2771             *
2772             * @param layoutUuid the layout uuid
2773             * @param start the lower bound of the range of asset entries
2774             * @param end the upper bound of the range of asset entries (not inclusive)
2775             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2776             * @param retrieveFromCache whether to retrieve from the finder cache
2777             * @return the ordered range of matching asset entries
2778             */
2779            @Override
2780            public List<AssetEntry> findByLayoutUuid(String layoutUuid, int start,
2781                    int end, OrderByComparator<AssetEntry> orderByComparator,
2782                    boolean retrieveFromCache) {
2783                    boolean pagination = true;
2784                    FinderPath finderPath = null;
2785                    Object[] finderArgs = null;
2786    
2787                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2788                                    (orderByComparator == null)) {
2789                            pagination = false;
2790                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID;
2791                            finderArgs = new Object[] { layoutUuid };
2792                    }
2793                    else {
2794                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTUUID;
2795                            finderArgs = new Object[] { layoutUuid, start, end, orderByComparator };
2796                    }
2797    
2798                    List<AssetEntry> list = null;
2799    
2800                    if (retrieveFromCache) {
2801                            list = (List<AssetEntry>)finderCache.getResult(finderPath,
2802                                            finderArgs, this);
2803    
2804                            if ((list != null) && !list.isEmpty()) {
2805                                    for (AssetEntry assetEntry : list) {
2806                                            if (!Validator.equals(layoutUuid, assetEntry.getLayoutUuid())) {
2807                                                    list = null;
2808    
2809                                                    break;
2810                                            }
2811                                    }
2812                            }
2813                    }
2814    
2815                    if (list == null) {
2816                            StringBundler query = null;
2817    
2818                            if (orderByComparator != null) {
2819                                    query = new StringBundler(3 +
2820                                                    (orderByComparator.getOrderByFields().length * 2));
2821                            }
2822                            else {
2823                                    query = new StringBundler(3);
2824                            }
2825    
2826                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
2827    
2828                            boolean bindLayoutUuid = false;
2829    
2830                            if (layoutUuid == null) {
2831                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
2832                            }
2833                            else if (layoutUuid.equals(StringPool.BLANK)) {
2834                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
2835                            }
2836                            else {
2837                                    bindLayoutUuid = true;
2838    
2839                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
2840                            }
2841    
2842                            if (orderByComparator != null) {
2843                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2844                                            orderByComparator);
2845                            }
2846                            else
2847                             if (pagination) {
2848                                    query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
2849                            }
2850    
2851                            String sql = query.toString();
2852    
2853                            Session session = null;
2854    
2855                            try {
2856                                    session = openSession();
2857    
2858                                    Query q = session.createQuery(sql);
2859    
2860                                    QueryPos qPos = QueryPos.getInstance(q);
2861    
2862                                    if (bindLayoutUuid) {
2863                                            qPos.add(layoutUuid);
2864                                    }
2865    
2866                                    if (!pagination) {
2867                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2868                                                            start, end, false);
2869    
2870                                            Collections.sort(list);
2871    
2872                                            list = Collections.unmodifiableList(list);
2873                                    }
2874                                    else {
2875                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
2876                                                            start, end);
2877                                    }
2878    
2879                                    cacheResult(list);
2880    
2881                                    finderCache.putResult(finderPath, finderArgs, list);
2882                            }
2883                            catch (Exception e) {
2884                                    finderCache.removeResult(finderPath, finderArgs);
2885    
2886                                    throw processException(e);
2887                            }
2888                            finally {
2889                                    closeSession(session);
2890                            }
2891                    }
2892    
2893                    return list;
2894            }
2895    
2896            /**
2897             * Returns the first asset entry in the ordered set where layoutUuid = &#63;.
2898             *
2899             * @param layoutUuid the layout uuid
2900             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2901             * @return the first matching asset entry
2902             * @throws NoSuchEntryException if a matching asset entry could not be found
2903             */
2904            @Override
2905            public AssetEntry findByLayoutUuid_First(String layoutUuid,
2906                    OrderByComparator<AssetEntry> orderByComparator)
2907                    throws NoSuchEntryException {
2908                    AssetEntry assetEntry = fetchByLayoutUuid_First(layoutUuid,
2909                                    orderByComparator);
2910    
2911                    if (assetEntry != null) {
2912                            return assetEntry;
2913                    }
2914    
2915                    StringBundler msg = new StringBundler(4);
2916    
2917                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2918    
2919                    msg.append("layoutUuid=");
2920                    msg.append(layoutUuid);
2921    
2922                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2923    
2924                    throw new NoSuchEntryException(msg.toString());
2925            }
2926    
2927            /**
2928             * Returns the first asset entry in the ordered set where layoutUuid = &#63;.
2929             *
2930             * @param layoutUuid the layout uuid
2931             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2932             * @return the first matching asset entry, or <code>null</code> if a matching asset entry could not be found
2933             */
2934            @Override
2935            public AssetEntry fetchByLayoutUuid_First(String layoutUuid,
2936                    OrderByComparator<AssetEntry> orderByComparator) {
2937                    List<AssetEntry> list = findByLayoutUuid(layoutUuid, 0, 1,
2938                                    orderByComparator);
2939    
2940                    if (!list.isEmpty()) {
2941                            return list.get(0);
2942                    }
2943    
2944                    return null;
2945            }
2946    
2947            /**
2948             * Returns the last asset entry in the ordered set where layoutUuid = &#63;.
2949             *
2950             * @param layoutUuid the layout uuid
2951             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2952             * @return the last matching asset entry
2953             * @throws NoSuchEntryException if a matching asset entry could not be found
2954             */
2955            @Override
2956            public AssetEntry findByLayoutUuid_Last(String layoutUuid,
2957                    OrderByComparator<AssetEntry> orderByComparator)
2958                    throws NoSuchEntryException {
2959                    AssetEntry assetEntry = fetchByLayoutUuid_Last(layoutUuid,
2960                                    orderByComparator);
2961    
2962                    if (assetEntry != null) {
2963                            return assetEntry;
2964                    }
2965    
2966                    StringBundler msg = new StringBundler(4);
2967    
2968                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2969    
2970                    msg.append("layoutUuid=");
2971                    msg.append(layoutUuid);
2972    
2973                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2974    
2975                    throw new NoSuchEntryException(msg.toString());
2976            }
2977    
2978            /**
2979             * Returns the last asset entry in the ordered set where layoutUuid = &#63;.
2980             *
2981             * @param layoutUuid the layout uuid
2982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2983             * @return the last matching asset entry, or <code>null</code> if a matching asset entry could not be found
2984             */
2985            @Override
2986            public AssetEntry fetchByLayoutUuid_Last(String layoutUuid,
2987                    OrderByComparator<AssetEntry> orderByComparator) {
2988                    int count = countByLayoutUuid(layoutUuid);
2989    
2990                    if (count == 0) {
2991                            return null;
2992                    }
2993    
2994                    List<AssetEntry> list = findByLayoutUuid(layoutUuid, count - 1, count,
2995                                    orderByComparator);
2996    
2997                    if (!list.isEmpty()) {
2998                            return list.get(0);
2999                    }
3000    
3001                    return null;
3002            }
3003    
3004            /**
3005             * Returns the asset entries before and after the current asset entry in the ordered set where layoutUuid = &#63;.
3006             *
3007             * @param entryId the primary key of the current asset entry
3008             * @param layoutUuid the layout uuid
3009             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3010             * @return the previous, current, and next asset entry
3011             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
3012             */
3013            @Override
3014            public AssetEntry[] findByLayoutUuid_PrevAndNext(long entryId,
3015                    String layoutUuid, OrderByComparator<AssetEntry> orderByComparator)
3016                    throws NoSuchEntryException {
3017                    AssetEntry assetEntry = findByPrimaryKey(entryId);
3018    
3019                    Session session = null;
3020    
3021                    try {
3022                            session = openSession();
3023    
3024                            AssetEntry[] array = new AssetEntryImpl[3];
3025    
3026                            array[0] = getByLayoutUuid_PrevAndNext(session, assetEntry,
3027                                            layoutUuid, orderByComparator, true);
3028    
3029                            array[1] = assetEntry;
3030    
3031                            array[2] = getByLayoutUuid_PrevAndNext(session, assetEntry,
3032                                            layoutUuid, orderByComparator, false);
3033    
3034                            return array;
3035                    }
3036                    catch (Exception e) {
3037                            throw processException(e);
3038                    }
3039                    finally {
3040                            closeSession(session);
3041                    }
3042            }
3043    
3044            protected AssetEntry getByLayoutUuid_PrevAndNext(Session session,
3045                    AssetEntry assetEntry, String layoutUuid,
3046                    OrderByComparator<AssetEntry> orderByComparator, boolean previous) {
3047                    StringBundler query = null;
3048    
3049                    if (orderByComparator != null) {
3050                            query = new StringBundler(4 +
3051                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3052                                            (orderByComparator.getOrderByFields().length * 3));
3053                    }
3054                    else {
3055                            query = new StringBundler(3);
3056                    }
3057    
3058                    query.append(_SQL_SELECT_ASSETENTRY_WHERE);
3059    
3060                    boolean bindLayoutUuid = false;
3061    
3062                    if (layoutUuid == null) {
3063                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
3064                    }
3065                    else if (layoutUuid.equals(StringPool.BLANK)) {
3066                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
3067                    }
3068                    else {
3069                            bindLayoutUuid = true;
3070    
3071                            query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
3072                    }
3073    
3074                    if (orderByComparator != null) {
3075                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3076    
3077                            if (orderByConditionFields.length > 0) {
3078                                    query.append(WHERE_AND);
3079                            }
3080    
3081                            for (int i = 0; i < orderByConditionFields.length; i++) {
3082                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3083                                    query.append(orderByConditionFields[i]);
3084    
3085                                    if ((i + 1) < orderByConditionFields.length) {
3086                                            if (orderByComparator.isAscending() ^ previous) {
3087                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3088                                            }
3089                                            else {
3090                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3091                                            }
3092                                    }
3093                                    else {
3094                                            if (orderByComparator.isAscending() ^ previous) {
3095                                                    query.append(WHERE_GREATER_THAN);
3096                                            }
3097                                            else {
3098                                                    query.append(WHERE_LESSER_THAN);
3099                                            }
3100                                    }
3101                            }
3102    
3103                            query.append(ORDER_BY_CLAUSE);
3104    
3105                            String[] orderByFields = orderByComparator.getOrderByFields();
3106    
3107                            for (int i = 0; i < orderByFields.length; i++) {
3108                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3109                                    query.append(orderByFields[i]);
3110    
3111                                    if ((i + 1) < orderByFields.length) {
3112                                            if (orderByComparator.isAscending() ^ previous) {
3113                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3114                                            }
3115                                            else {
3116                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3117                                            }
3118                                    }
3119                                    else {
3120                                            if (orderByComparator.isAscending() ^ previous) {
3121                                                    query.append(ORDER_BY_ASC);
3122                                            }
3123                                            else {
3124                                                    query.append(ORDER_BY_DESC);
3125                                            }
3126                                    }
3127                            }
3128                    }
3129                    else {
3130                            query.append(AssetEntryModelImpl.ORDER_BY_JPQL);
3131                    }
3132    
3133                    String sql = query.toString();
3134    
3135                    Query q = session.createQuery(sql);
3136    
3137                    q.setFirstResult(0);
3138                    q.setMaxResults(2);
3139    
3140                    QueryPos qPos = QueryPos.getInstance(q);
3141    
3142                    if (bindLayoutUuid) {
3143                            qPos.add(layoutUuid);
3144                    }
3145    
3146                    if (orderByComparator != null) {
3147                            Object[] values = orderByComparator.getOrderByConditionValues(assetEntry);
3148    
3149                            for (Object value : values) {
3150                                    qPos.add(value);
3151                            }
3152                    }
3153    
3154                    List<AssetEntry> list = q.list();
3155    
3156                    if (list.size() == 2) {
3157                            return list.get(1);
3158                    }
3159                    else {
3160                            return null;
3161                    }
3162            }
3163    
3164            /**
3165             * Removes all the asset entries where layoutUuid = &#63; from the database.
3166             *
3167             * @param layoutUuid the layout uuid
3168             */
3169            @Override
3170            public void removeByLayoutUuid(String layoutUuid) {
3171                    for (AssetEntry assetEntry : findByLayoutUuid(layoutUuid,
3172                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3173                            remove(assetEntry);
3174                    }
3175            }
3176    
3177            /**
3178             * Returns the number of asset entries where layoutUuid = &#63;.
3179             *
3180             * @param layoutUuid the layout uuid
3181             * @return the number of matching asset entries
3182             */
3183            @Override
3184            public int countByLayoutUuid(String layoutUuid) {
3185                    FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTUUID;
3186    
3187                    Object[] finderArgs = new Object[] { layoutUuid };
3188    
3189                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3190    
3191                    if (count == null) {
3192                            StringBundler query = new StringBundler(2);
3193    
3194                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
3195    
3196                            boolean bindLayoutUuid = false;
3197    
3198                            if (layoutUuid == null) {
3199                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1);
3200                            }
3201                            else if (layoutUuid.equals(StringPool.BLANK)) {
3202                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3);
3203                            }
3204                            else {
3205                                    bindLayoutUuid = true;
3206    
3207                                    query.append(_FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2);
3208                            }
3209    
3210                            String sql = query.toString();
3211    
3212                            Session session = null;
3213    
3214                            try {
3215                                    session = openSession();
3216    
3217                                    Query q = session.createQuery(sql);
3218    
3219                                    QueryPos qPos = QueryPos.getInstance(q);
3220    
3221                                    if (bindLayoutUuid) {
3222                                            qPos.add(layoutUuid);
3223                                    }
3224    
3225                                    count = (Long)q.uniqueResult();
3226    
3227                                    finderCache.putResult(finderPath, finderArgs, count);
3228                            }
3229                            catch (Exception e) {
3230                                    finderCache.removeResult(finderPath, finderArgs);
3231    
3232                                    throw processException(e);
3233                            }
3234                            finally {
3235                                    closeSession(session);
3236                            }
3237                    }
3238    
3239                    return count.intValue();
3240            }
3241    
3242            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_1 = "assetEntry.layoutUuid IS NULL";
3243            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_2 = "assetEntry.layoutUuid = ?";
3244            private static final String _FINDER_COLUMN_LAYOUTUUID_LAYOUTUUID_3 = "(assetEntry.layoutUuid IS NULL OR assetEntry.layoutUuid = '')";
3245            public static final FinderPath FINDER_PATH_FETCH_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3246                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
3247                            FINDER_CLASS_NAME_ENTITY, "fetchByG_CU",
3248                            new String[] { Long.class.getName(), String.class.getName() },
3249                            AssetEntryModelImpl.GROUPID_COLUMN_BITMASK |
3250                            AssetEntryModelImpl.CLASSUUID_COLUMN_BITMASK);
3251            public static final FinderPath FINDER_PATH_COUNT_BY_G_CU = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3252                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3253                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_CU",
3254                            new String[] { Long.class.getName(), String.class.getName() });
3255    
3256            /**
3257             * Returns the asset entry where groupId = &#63; and classUuid = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
3258             *
3259             * @param groupId the group ID
3260             * @param classUuid the class uuid
3261             * @return the matching asset entry
3262             * @throws NoSuchEntryException if a matching asset entry could not be found
3263             */
3264            @Override
3265            public AssetEntry findByG_CU(long groupId, String classUuid)
3266                    throws NoSuchEntryException {
3267                    AssetEntry assetEntry = fetchByG_CU(groupId, classUuid);
3268    
3269                    if (assetEntry == null) {
3270                            StringBundler msg = new StringBundler(6);
3271    
3272                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3273    
3274                            msg.append("groupId=");
3275                            msg.append(groupId);
3276    
3277                            msg.append(", classUuid=");
3278                            msg.append(classUuid);
3279    
3280                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3281    
3282                            if (_log.isWarnEnabled()) {
3283                                    _log.warn(msg.toString());
3284                            }
3285    
3286                            throw new NoSuchEntryException(msg.toString());
3287                    }
3288    
3289                    return assetEntry;
3290            }
3291    
3292            /**
3293             * 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.
3294             *
3295             * @param groupId the group ID
3296             * @param classUuid the class uuid
3297             * @return the matching asset entry, or <code>null</code> if a matching asset entry could not be found
3298             */
3299            @Override
3300            public AssetEntry fetchByG_CU(long groupId, String classUuid) {
3301                    return fetchByG_CU(groupId, classUuid, true);
3302            }
3303    
3304            /**
3305             * 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.
3306             *
3307             * @param groupId the group ID
3308             * @param classUuid the class uuid
3309             * @param retrieveFromCache whether to retrieve from the finder cache
3310             * @return the matching asset entry, or <code>null</code> if a matching asset entry could not be found
3311             */
3312            @Override
3313            public AssetEntry fetchByG_CU(long groupId, String classUuid,
3314                    boolean retrieveFromCache) {
3315                    Object[] finderArgs = new Object[] { groupId, classUuid };
3316    
3317                    Object result = null;
3318    
3319                    if (retrieveFromCache) {
3320                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_CU,
3321                                            finderArgs, this);
3322                    }
3323    
3324                    if (result instanceof AssetEntry) {
3325                            AssetEntry assetEntry = (AssetEntry)result;
3326    
3327                            if ((groupId != assetEntry.getGroupId()) ||
3328                                            !Validator.equals(classUuid, assetEntry.getClassUuid())) {
3329                                    result = null;
3330                            }
3331                    }
3332    
3333                    if (result == null) {
3334                            StringBundler query = new StringBundler(4);
3335    
3336                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
3337    
3338                            query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
3339    
3340                            boolean bindClassUuid = false;
3341    
3342                            if (classUuid == null) {
3343                                    query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
3344                            }
3345                            else if (classUuid.equals(StringPool.BLANK)) {
3346                                    query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
3347                            }
3348                            else {
3349                                    bindClassUuid = true;
3350    
3351                                    query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
3352                            }
3353    
3354                            String sql = query.toString();
3355    
3356                            Session session = null;
3357    
3358                            try {
3359                                    session = openSession();
3360    
3361                                    Query q = session.createQuery(sql);
3362    
3363                                    QueryPos qPos = QueryPos.getInstance(q);
3364    
3365                                    qPos.add(groupId);
3366    
3367                                    if (bindClassUuid) {
3368                                            qPos.add(classUuid);
3369                                    }
3370    
3371                                    List<AssetEntry> list = q.list();
3372    
3373                                    if (list.isEmpty()) {
3374                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_CU,
3375                                                    finderArgs, list);
3376                                    }
3377                                    else {
3378                                            if ((list.size() > 1) && _log.isWarnEnabled()) {
3379                                                    _log.warn(
3380                                                            "AssetEntryPersistenceImpl.fetchByG_CU(long, String, boolean) with parameters (" +
3381                                                            StringUtil.merge(finderArgs) +
3382                                                            ") 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.");
3383                                            }
3384    
3385                                            AssetEntry assetEntry = list.get(0);
3386    
3387                                            result = assetEntry;
3388    
3389                                            cacheResult(assetEntry);
3390    
3391                                            if ((assetEntry.getGroupId() != groupId) ||
3392                                                            (assetEntry.getClassUuid() == null) ||
3393                                                            !assetEntry.getClassUuid().equals(classUuid)) {
3394                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_CU,
3395                                                            finderArgs, assetEntry);
3396                                            }
3397                                    }
3398                            }
3399                            catch (Exception e) {
3400                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_CU, finderArgs);
3401    
3402                                    throw processException(e);
3403                            }
3404                            finally {
3405                                    closeSession(session);
3406                            }
3407                    }
3408    
3409                    if (result instanceof List<?>) {
3410                            return null;
3411                    }
3412                    else {
3413                            return (AssetEntry)result;
3414                    }
3415            }
3416    
3417            /**
3418             * Removes the asset entry where groupId = &#63; and classUuid = &#63; from the database.
3419             *
3420             * @param groupId the group ID
3421             * @param classUuid the class uuid
3422             * @return the asset entry that was removed
3423             */
3424            @Override
3425            public AssetEntry removeByG_CU(long groupId, String classUuid)
3426                    throws NoSuchEntryException {
3427                    AssetEntry assetEntry = findByG_CU(groupId, classUuid);
3428    
3429                    return remove(assetEntry);
3430            }
3431    
3432            /**
3433             * Returns the number of asset entries where groupId = &#63; and classUuid = &#63;.
3434             *
3435             * @param groupId the group ID
3436             * @param classUuid the class uuid
3437             * @return the number of matching asset entries
3438             */
3439            @Override
3440            public int countByG_CU(long groupId, String classUuid) {
3441                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_CU;
3442    
3443                    Object[] finderArgs = new Object[] { groupId, classUuid };
3444    
3445                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3446    
3447                    if (count == null) {
3448                            StringBundler query = new StringBundler(3);
3449    
3450                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
3451    
3452                            query.append(_FINDER_COLUMN_G_CU_GROUPID_2);
3453    
3454                            boolean bindClassUuid = false;
3455    
3456                            if (classUuid == null) {
3457                                    query.append(_FINDER_COLUMN_G_CU_CLASSUUID_1);
3458                            }
3459                            else if (classUuid.equals(StringPool.BLANK)) {
3460                                    query.append(_FINDER_COLUMN_G_CU_CLASSUUID_3);
3461                            }
3462                            else {
3463                                    bindClassUuid = true;
3464    
3465                                    query.append(_FINDER_COLUMN_G_CU_CLASSUUID_2);
3466                            }
3467    
3468                            String sql = query.toString();
3469    
3470                            Session session = null;
3471    
3472                            try {
3473                                    session = openSession();
3474    
3475                                    Query q = session.createQuery(sql);
3476    
3477                                    QueryPos qPos = QueryPos.getInstance(q);
3478    
3479                                    qPos.add(groupId);
3480    
3481                                    if (bindClassUuid) {
3482                                            qPos.add(classUuid);
3483                                    }
3484    
3485                                    count = (Long)q.uniqueResult();
3486    
3487                                    finderCache.putResult(finderPath, finderArgs, count);
3488                            }
3489                            catch (Exception e) {
3490                                    finderCache.removeResult(finderPath, finderArgs);
3491    
3492                                    throw processException(e);
3493                            }
3494                            finally {
3495                                    closeSession(session);
3496                            }
3497                    }
3498    
3499                    return count.intValue();
3500            }
3501    
3502            private static final String _FINDER_COLUMN_G_CU_GROUPID_2 = "assetEntry.groupId = ? AND ";
3503            private static final String _FINDER_COLUMN_G_CU_CLASSUUID_1 = "assetEntry.classUuid IS NULL";
3504            private static final String _FINDER_COLUMN_G_CU_CLASSUUID_2 = "assetEntry.classUuid = ?";
3505            private static final String _FINDER_COLUMN_G_CU_CLASSUUID_3 = "(assetEntry.classUuid IS NULL OR assetEntry.classUuid = '')";
3506            public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3507                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, AssetEntryImpl.class,
3508                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
3509                            new String[] { Long.class.getName(), Long.class.getName() },
3510                            AssetEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
3511                            AssetEntryModelImpl.CLASSPK_COLUMN_BITMASK);
3512            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3513                            AssetEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3514                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
3515                            new String[] { Long.class.getName(), Long.class.getName() });
3516    
3517            /**
3518             * Returns the asset entry where classNameId = &#63; and classPK = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
3519             *
3520             * @param classNameId the class name ID
3521             * @param classPK the class p k
3522             * @return the matching asset entry
3523             * @throws NoSuchEntryException if a matching asset entry could not be found
3524             */
3525            @Override
3526            public AssetEntry findByC_C(long classNameId, long classPK)
3527                    throws NoSuchEntryException {
3528                    AssetEntry assetEntry = fetchByC_C(classNameId, classPK);
3529    
3530                    if (assetEntry == null) {
3531                            StringBundler msg = new StringBundler(6);
3532    
3533                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3534    
3535                            msg.append("classNameId=");
3536                            msg.append(classNameId);
3537    
3538                            msg.append(", classPK=");
3539                            msg.append(classPK);
3540    
3541                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3542    
3543                            if (_log.isWarnEnabled()) {
3544                                    _log.warn(msg.toString());
3545                            }
3546    
3547                            throw new NoSuchEntryException(msg.toString());
3548                    }
3549    
3550                    return assetEntry;
3551            }
3552    
3553            /**
3554             * 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.
3555             *
3556             * @param classNameId the class name ID
3557             * @param classPK the class p k
3558             * @return the matching asset entry, or <code>null</code> if a matching asset entry could not be found
3559             */
3560            @Override
3561            public AssetEntry fetchByC_C(long classNameId, long classPK) {
3562                    return fetchByC_C(classNameId, classPK, true);
3563            }
3564    
3565            /**
3566             * 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.
3567             *
3568             * @param classNameId the class name ID
3569             * @param classPK the class p k
3570             * @param retrieveFromCache whether to retrieve from the finder cache
3571             * @return the matching asset entry, or <code>null</code> if a matching asset entry could not be found
3572             */
3573            @Override
3574            public AssetEntry fetchByC_C(long classNameId, long classPK,
3575                    boolean retrieveFromCache) {
3576                    Object[] finderArgs = new Object[] { classNameId, classPK };
3577    
3578                    Object result = null;
3579    
3580                    if (retrieveFromCache) {
3581                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_C_C,
3582                                            finderArgs, this);
3583                    }
3584    
3585                    if (result instanceof AssetEntry) {
3586                            AssetEntry assetEntry = (AssetEntry)result;
3587    
3588                            if ((classNameId != assetEntry.getClassNameId()) ||
3589                                            (classPK != assetEntry.getClassPK())) {
3590                                    result = null;
3591                            }
3592                    }
3593    
3594                    if (result == null) {
3595                            StringBundler query = new StringBundler(4);
3596    
3597                            query.append(_SQL_SELECT_ASSETENTRY_WHERE);
3598    
3599                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3600    
3601                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3602    
3603                            String sql = query.toString();
3604    
3605                            Session session = null;
3606    
3607                            try {
3608                                    session = openSession();
3609    
3610                                    Query q = session.createQuery(sql);
3611    
3612                                    QueryPos qPos = QueryPos.getInstance(q);
3613    
3614                                    qPos.add(classNameId);
3615    
3616                                    qPos.add(classPK);
3617    
3618                                    List<AssetEntry> list = q.list();
3619    
3620                                    if (list.isEmpty()) {
3621                                            finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, finderArgs,
3622                                                    list);
3623                                    }
3624                                    else {
3625                                            AssetEntry assetEntry = list.get(0);
3626    
3627                                            result = assetEntry;
3628    
3629                                            cacheResult(assetEntry);
3630    
3631                                            if ((assetEntry.getClassNameId() != classNameId) ||
3632                                                            (assetEntry.getClassPK() != classPK)) {
3633                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_C_C,
3634                                                            finderArgs, assetEntry);
3635                                            }
3636                                    }
3637                            }
3638                            catch (Exception e) {
3639                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, finderArgs);
3640    
3641                                    throw processException(e);
3642                            }
3643                            finally {
3644                                    closeSession(session);
3645                            }
3646                    }
3647    
3648                    if (result instanceof List<?>) {
3649                            return null;
3650                    }
3651                    else {
3652                            return (AssetEntry)result;
3653                    }
3654            }
3655    
3656            /**
3657             * Removes the asset entry where classNameId = &#63; and classPK = &#63; from the database.
3658             *
3659             * @param classNameId the class name ID
3660             * @param classPK the class p k
3661             * @return the asset entry that was removed
3662             */
3663            @Override
3664            public AssetEntry removeByC_C(long classNameId, long classPK)
3665                    throws NoSuchEntryException {
3666                    AssetEntry assetEntry = findByC_C(classNameId, classPK);
3667    
3668                    return remove(assetEntry);
3669            }
3670    
3671            /**
3672             * Returns the number of asset entries where classNameId = &#63; and classPK = &#63;.
3673             *
3674             * @param classNameId the class name ID
3675             * @param classPK the class p k
3676             * @return the number of matching asset entries
3677             */
3678            @Override
3679            public int countByC_C(long classNameId, long classPK) {
3680                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
3681    
3682                    Object[] finderArgs = new Object[] { classNameId, classPK };
3683    
3684                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3685    
3686                    if (count == null) {
3687                            StringBundler query = new StringBundler(3);
3688    
3689                            query.append(_SQL_COUNT_ASSETENTRY_WHERE);
3690    
3691                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3692    
3693                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3694    
3695                            String sql = query.toString();
3696    
3697                            Session session = null;
3698    
3699                            try {
3700                                    session = openSession();
3701    
3702                                    Query q = session.createQuery(sql);
3703    
3704                                    QueryPos qPos = QueryPos.getInstance(q);
3705    
3706                                    qPos.add(classNameId);
3707    
3708                                    qPos.add(classPK);
3709    
3710                                    count = (Long)q.uniqueResult();
3711    
3712                                    finderCache.putResult(finderPath, finderArgs, count);
3713                            }
3714                            catch (Exception e) {
3715                                    finderCache.removeResult(finderPath, finderArgs);
3716    
3717                                    throw processException(e);
3718                            }
3719                            finally {
3720                                    closeSession(session);
3721                            }
3722                    }
3723    
3724                    return count.intValue();
3725            }
3726    
3727            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "assetEntry.classNameId = ? AND ";
3728            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "assetEntry.classPK = ?";
3729    
3730            public AssetEntryPersistenceImpl() {
3731                    setModelClass(AssetEntry.class);
3732            }
3733    
3734            /**
3735             * Caches the asset entry in the entity cache if it is enabled.
3736             *
3737             * @param assetEntry the asset entry
3738             */
3739            @Override
3740            public void cacheResult(AssetEntry assetEntry) {
3741                    entityCache.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3742                            AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry);
3743    
3744                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_CU,
3745                            new Object[] { assetEntry.getGroupId(), assetEntry.getClassUuid() },
3746                            assetEntry);
3747    
3748                    finderCache.putResult(FINDER_PATH_FETCH_BY_C_C,
3749                            new Object[] { assetEntry.getClassNameId(), assetEntry.getClassPK() },
3750                            assetEntry);
3751    
3752                    assetEntry.resetOriginalValues();
3753            }
3754    
3755            /**
3756             * Caches the asset entries in the entity cache if it is enabled.
3757             *
3758             * @param assetEntries the asset entries
3759             */
3760            @Override
3761            public void cacheResult(List<AssetEntry> assetEntries) {
3762                    for (AssetEntry assetEntry : assetEntries) {
3763                            if (entityCache.getResult(
3764                                                    AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3765                                                    AssetEntryImpl.class, assetEntry.getPrimaryKey()) == null) {
3766                                    cacheResult(assetEntry);
3767                            }
3768                            else {
3769                                    assetEntry.resetOriginalValues();
3770                            }
3771                    }
3772            }
3773    
3774            /**
3775             * Clears the cache for all asset entries.
3776             *
3777             * <p>
3778             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
3779             * </p>
3780             */
3781            @Override
3782            public void clearCache() {
3783                    entityCache.clearCache(AssetEntryImpl.class);
3784    
3785                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
3786                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3787                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3788            }
3789    
3790            /**
3791             * Clears the cache for the asset entry.
3792             *
3793             * <p>
3794             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
3795             * </p>
3796             */
3797            @Override
3798            public void clearCache(AssetEntry assetEntry) {
3799                    entityCache.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3800                            AssetEntryImpl.class, assetEntry.getPrimaryKey());
3801    
3802                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3803                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3804    
3805                    clearUniqueFindersCache((AssetEntryModelImpl)assetEntry);
3806            }
3807    
3808            @Override
3809            public void clearCache(List<AssetEntry> assetEntries) {
3810                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3811                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3812    
3813                    for (AssetEntry assetEntry : assetEntries) {
3814                            entityCache.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
3815                                    AssetEntryImpl.class, assetEntry.getPrimaryKey());
3816    
3817                            clearUniqueFindersCache((AssetEntryModelImpl)assetEntry);
3818                    }
3819            }
3820    
3821            protected void cacheUniqueFindersCache(
3822                    AssetEntryModelImpl assetEntryModelImpl, boolean isNew) {
3823                    if (isNew) {
3824                            Object[] args = new Object[] {
3825                                            assetEntryModelImpl.getGroupId(),
3826                                            assetEntryModelImpl.getClassUuid()
3827                                    };
3828    
3829                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_CU, args,
3830                                    Long.valueOf(1));
3831                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_CU, args,
3832                                    assetEntryModelImpl);
3833    
3834                            args = new Object[] {
3835                                            assetEntryModelImpl.getClassNameId(),
3836                                            assetEntryModelImpl.getClassPK()
3837                                    };
3838    
3839                            finderCache.putResult(FINDER_PATH_COUNT_BY_C_C, args,
3840                                    Long.valueOf(1));
3841                            finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, args,
3842                                    assetEntryModelImpl);
3843                    }
3844                    else {
3845                            if ((assetEntryModelImpl.getColumnBitmask() &
3846                                            FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
3847                                    Object[] args = new Object[] {
3848                                                    assetEntryModelImpl.getGroupId(),
3849                                                    assetEntryModelImpl.getClassUuid()
3850                                            };
3851    
3852                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_CU, args,
3853                                            Long.valueOf(1));
3854                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_CU, args,
3855                                            assetEntryModelImpl);
3856                            }
3857    
3858                            if ((assetEntryModelImpl.getColumnBitmask() &
3859                                            FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
3860                                    Object[] args = new Object[] {
3861                                                    assetEntryModelImpl.getClassNameId(),
3862                                                    assetEntryModelImpl.getClassPK()
3863                                            };
3864    
3865                                    finderCache.putResult(FINDER_PATH_COUNT_BY_C_C, args,
3866                                            Long.valueOf(1));
3867                                    finderCache.putResult(FINDER_PATH_FETCH_BY_C_C, args,
3868                                            assetEntryModelImpl);
3869                            }
3870                    }
3871            }
3872    
3873            protected void clearUniqueFindersCache(
3874                    AssetEntryModelImpl assetEntryModelImpl) {
3875                    Object[] args = new Object[] {
3876                                    assetEntryModelImpl.getGroupId(),
3877                                    assetEntryModelImpl.getClassUuid()
3878                            };
3879    
3880                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
3881                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
3882    
3883                    if ((assetEntryModelImpl.getColumnBitmask() &
3884                                    FINDER_PATH_FETCH_BY_G_CU.getColumnBitmask()) != 0) {
3885                            args = new Object[] {
3886                                            assetEntryModelImpl.getOriginalGroupId(),
3887                                            assetEntryModelImpl.getOriginalClassUuid()
3888                                    };
3889    
3890                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_CU, args);
3891                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_CU, args);
3892                    }
3893    
3894                    args = new Object[] {
3895                                    assetEntryModelImpl.getClassNameId(),
3896                                    assetEntryModelImpl.getClassPK()
3897                            };
3898    
3899                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
3900                    finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
3901    
3902                    if ((assetEntryModelImpl.getColumnBitmask() &
3903                                    FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
3904                            args = new Object[] {
3905                                            assetEntryModelImpl.getOriginalClassNameId(),
3906                                            assetEntryModelImpl.getOriginalClassPK()
3907                                    };
3908    
3909                            finderCache.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
3910                            finderCache.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
3911                    }
3912            }
3913    
3914            /**
3915             * Creates a new asset entry with the primary key. Does not add the asset entry to the database.
3916             *
3917             * @param entryId the primary key for the new asset entry
3918             * @return the new asset entry
3919             */
3920            @Override
3921            public AssetEntry create(long entryId) {
3922                    AssetEntry assetEntry = new AssetEntryImpl();
3923    
3924                    assetEntry.setNew(true);
3925                    assetEntry.setPrimaryKey(entryId);
3926    
3927                    assetEntry.setCompanyId(companyProvider.getCompanyId());
3928    
3929                    return assetEntry;
3930            }
3931    
3932            /**
3933             * Removes the asset entry with the primary key from the database. Also notifies the appropriate model listeners.
3934             *
3935             * @param entryId the primary key of the asset entry
3936             * @return the asset entry that was removed
3937             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
3938             */
3939            @Override
3940            public AssetEntry remove(long entryId) throws NoSuchEntryException {
3941                    return remove((Serializable)entryId);
3942            }
3943    
3944            /**
3945             * Removes the asset entry with the primary key from the database. Also notifies the appropriate model listeners.
3946             *
3947             * @param primaryKey the primary key of the asset entry
3948             * @return the asset entry that was removed
3949             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
3950             */
3951            @Override
3952            public AssetEntry remove(Serializable primaryKey)
3953                    throws NoSuchEntryException {
3954                    Session session = null;
3955    
3956                    try {
3957                            session = openSession();
3958    
3959                            AssetEntry assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
3960                                            primaryKey);
3961    
3962                            if (assetEntry == null) {
3963                                    if (_log.isWarnEnabled()) {
3964                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3965                                    }
3966    
3967                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3968                                            primaryKey);
3969                            }
3970    
3971                            return remove(assetEntry);
3972                    }
3973                    catch (NoSuchEntryException nsee) {
3974                            throw nsee;
3975                    }
3976                    catch (Exception e) {
3977                            throw processException(e);
3978                    }
3979                    finally {
3980                            closeSession(session);
3981                    }
3982            }
3983    
3984            @Override
3985            protected AssetEntry removeImpl(AssetEntry assetEntry) {
3986                    assetEntry = toUnwrappedModel(assetEntry);
3987    
3988                    assetEntryToAssetCategoryTableMapper.deleteLeftPrimaryKeyTableMappings(assetEntry.getPrimaryKey());
3989    
3990                    assetEntryToAssetTagTableMapper.deleteLeftPrimaryKeyTableMappings(assetEntry.getPrimaryKey());
3991    
3992                    Session session = null;
3993    
3994                    try {
3995                            session = openSession();
3996    
3997                            if (!session.contains(assetEntry)) {
3998                                    assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
3999                                                    assetEntry.getPrimaryKeyObj());
4000                            }
4001    
4002                            if (assetEntry != null) {
4003                                    session.delete(assetEntry);
4004                            }
4005                    }
4006                    catch (Exception e) {
4007                            throw processException(e);
4008                    }
4009                    finally {
4010                            closeSession(session);
4011                    }
4012    
4013                    if (assetEntry != null) {
4014                            clearCache(assetEntry);
4015                    }
4016    
4017                    return assetEntry;
4018            }
4019    
4020            @Override
4021            public AssetEntry updateImpl(AssetEntry assetEntry) {
4022                    assetEntry = toUnwrappedModel(assetEntry);
4023    
4024                    boolean isNew = assetEntry.isNew();
4025    
4026                    AssetEntryModelImpl assetEntryModelImpl = (AssetEntryModelImpl)assetEntry;
4027    
4028                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
4029    
4030                    Date now = new Date();
4031    
4032                    if (isNew && (assetEntry.getCreateDate() == null)) {
4033                            if (serviceContext == null) {
4034                                    assetEntry.setCreateDate(now);
4035                            }
4036                            else {
4037                                    assetEntry.setCreateDate(serviceContext.getCreateDate(now));
4038                            }
4039                    }
4040    
4041                    if (!assetEntryModelImpl.hasSetModifiedDate()) {
4042                            if (serviceContext == null) {
4043                                    assetEntry.setModifiedDate(now);
4044                            }
4045                            else {
4046                                    assetEntry.setModifiedDate(serviceContext.getModifiedDate(now));
4047                            }
4048                    }
4049    
4050                    Session session = null;
4051    
4052                    try {
4053                            session = openSession();
4054    
4055                            if (assetEntry.isNew()) {
4056                                    session.save(assetEntry);
4057    
4058                                    assetEntry.setNew(false);
4059                            }
4060                            else {
4061                                    assetEntry = (AssetEntry)session.merge(assetEntry);
4062                            }
4063                    }
4064                    catch (Exception e) {
4065                            throw processException(e);
4066                    }
4067                    finally {
4068                            closeSession(session);
4069                    }
4070    
4071                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4072    
4073                    if (isNew || !AssetEntryModelImpl.COLUMN_BITMASK_ENABLED) {
4074                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4075                    }
4076    
4077                    else {
4078                            if ((assetEntryModelImpl.getColumnBitmask() &
4079                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
4080                                    Object[] args = new Object[] {
4081                                                    assetEntryModelImpl.getOriginalGroupId()
4082                                            };
4083    
4084                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
4085                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
4086                                            args);
4087    
4088                                    args = new Object[] { assetEntryModelImpl.getGroupId() };
4089    
4090                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
4091                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
4092                                            args);
4093                            }
4094    
4095                            if ((assetEntryModelImpl.getColumnBitmask() &
4096                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
4097                                    Object[] args = new Object[] {
4098                                                    assetEntryModelImpl.getOriginalCompanyId()
4099                                            };
4100    
4101                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
4102                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4103                                            args);
4104    
4105                                    args = new Object[] { assetEntryModelImpl.getCompanyId() };
4106    
4107                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
4108                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4109                                            args);
4110                            }
4111    
4112                            if ((assetEntryModelImpl.getColumnBitmask() &
4113                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE.getColumnBitmask()) != 0) {
4114                                    Object[] args = new Object[] {
4115                                                    assetEntryModelImpl.getOriginalVisible()
4116                                            };
4117    
4118                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
4119                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
4120                                            args);
4121    
4122                                    args = new Object[] { assetEntryModelImpl.getVisible() };
4123    
4124                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_VISIBLE, args);
4125                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VISIBLE,
4126                                            args);
4127                            }
4128    
4129                            if ((assetEntryModelImpl.getColumnBitmask() &
4130                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE.getColumnBitmask()) != 0) {
4131                                    Object[] args = new Object[] {
4132                                                    assetEntryModelImpl.getOriginalPublishDate()
4133                                            };
4134    
4135                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE, args);
4136                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
4137                                            args);
4138    
4139                                    args = new Object[] { assetEntryModelImpl.getPublishDate() };
4140    
4141                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_PUBLISHDATE, args);
4142                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PUBLISHDATE,
4143                                            args);
4144                            }
4145    
4146                            if ((assetEntryModelImpl.getColumnBitmask() &
4147                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE.getColumnBitmask()) != 0) {
4148                                    Object[] args = new Object[] {
4149                                                    assetEntryModelImpl.getOriginalExpirationDate()
4150                                            };
4151    
4152                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
4153                                            args);
4154                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
4155                                            args);
4156    
4157                                    args = new Object[] { assetEntryModelImpl.getExpirationDate() };
4158    
4159                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_EXPIRATIONDATE,
4160                                            args);
4161                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EXPIRATIONDATE,
4162                                            args);
4163                            }
4164    
4165                            if ((assetEntryModelImpl.getColumnBitmask() &
4166                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID.getColumnBitmask()) != 0) {
4167                                    Object[] args = new Object[] {
4168                                                    assetEntryModelImpl.getOriginalLayoutUuid()
4169                                            };
4170    
4171                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID, args);
4172                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
4173                                            args);
4174    
4175                                    args = new Object[] { assetEntryModelImpl.getLayoutUuid() };
4176    
4177                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_LAYOUTUUID, args);
4178                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTUUID,
4179                                            args);
4180                            }
4181                    }
4182    
4183                    entityCache.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4184                            AssetEntryImpl.class, assetEntry.getPrimaryKey(), assetEntry, false);
4185    
4186                    clearUniqueFindersCache(assetEntryModelImpl);
4187                    cacheUniqueFindersCache(assetEntryModelImpl, isNew);
4188    
4189                    assetEntry.resetOriginalValues();
4190    
4191                    return assetEntry;
4192            }
4193    
4194            protected AssetEntry toUnwrappedModel(AssetEntry assetEntry) {
4195                    if (assetEntry instanceof AssetEntryImpl) {
4196                            return assetEntry;
4197                    }
4198    
4199                    AssetEntryImpl assetEntryImpl = new AssetEntryImpl();
4200    
4201                    assetEntryImpl.setNew(assetEntry.isNew());
4202                    assetEntryImpl.setPrimaryKey(assetEntry.getPrimaryKey());
4203    
4204                    assetEntryImpl.setEntryId(assetEntry.getEntryId());
4205                    assetEntryImpl.setGroupId(assetEntry.getGroupId());
4206                    assetEntryImpl.setCompanyId(assetEntry.getCompanyId());
4207                    assetEntryImpl.setUserId(assetEntry.getUserId());
4208                    assetEntryImpl.setUserName(assetEntry.getUserName());
4209                    assetEntryImpl.setCreateDate(assetEntry.getCreateDate());
4210                    assetEntryImpl.setModifiedDate(assetEntry.getModifiedDate());
4211                    assetEntryImpl.setClassNameId(assetEntry.getClassNameId());
4212                    assetEntryImpl.setClassPK(assetEntry.getClassPK());
4213                    assetEntryImpl.setClassUuid(assetEntry.getClassUuid());
4214                    assetEntryImpl.setClassTypeId(assetEntry.getClassTypeId());
4215                    assetEntryImpl.setListable(assetEntry.isListable());
4216                    assetEntryImpl.setVisible(assetEntry.isVisible());
4217                    assetEntryImpl.setStartDate(assetEntry.getStartDate());
4218                    assetEntryImpl.setEndDate(assetEntry.getEndDate());
4219                    assetEntryImpl.setPublishDate(assetEntry.getPublishDate());
4220                    assetEntryImpl.setExpirationDate(assetEntry.getExpirationDate());
4221                    assetEntryImpl.setMimeType(assetEntry.getMimeType());
4222                    assetEntryImpl.setTitle(assetEntry.getTitle());
4223                    assetEntryImpl.setDescription(assetEntry.getDescription());
4224                    assetEntryImpl.setSummary(assetEntry.getSummary());
4225                    assetEntryImpl.setUrl(assetEntry.getUrl());
4226                    assetEntryImpl.setLayoutUuid(assetEntry.getLayoutUuid());
4227                    assetEntryImpl.setHeight(assetEntry.getHeight());
4228                    assetEntryImpl.setWidth(assetEntry.getWidth());
4229                    assetEntryImpl.setPriority(assetEntry.getPriority());
4230                    assetEntryImpl.setViewCount(assetEntry.getViewCount());
4231    
4232                    return assetEntryImpl;
4233            }
4234    
4235            /**
4236             * Returns the asset entry with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found.
4237             *
4238             * @param primaryKey the primary key of the asset entry
4239             * @return the asset entry
4240             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
4241             */
4242            @Override
4243            public AssetEntry findByPrimaryKey(Serializable primaryKey)
4244                    throws NoSuchEntryException {
4245                    AssetEntry assetEntry = fetchByPrimaryKey(primaryKey);
4246    
4247                    if (assetEntry == null) {
4248                            if (_log.isWarnEnabled()) {
4249                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4250                            }
4251    
4252                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4253                                    primaryKey);
4254                    }
4255    
4256                    return assetEntry;
4257            }
4258    
4259            /**
4260             * Returns the asset entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found.
4261             *
4262             * @param entryId the primary key of the asset entry
4263             * @return the asset entry
4264             * @throws NoSuchEntryException if a asset entry with the primary key could not be found
4265             */
4266            @Override
4267            public AssetEntry findByPrimaryKey(long entryId)
4268                    throws NoSuchEntryException {
4269                    return findByPrimaryKey((Serializable)entryId);
4270            }
4271    
4272            /**
4273             * Returns the asset entry with the primary key or returns <code>null</code> if it could not be found.
4274             *
4275             * @param primaryKey the primary key of the asset entry
4276             * @return the asset entry, or <code>null</code> if a asset entry with the primary key could not be found
4277             */
4278            @Override
4279            public AssetEntry fetchByPrimaryKey(Serializable primaryKey) {
4280                    AssetEntry assetEntry = (AssetEntry)entityCache.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4281                                    AssetEntryImpl.class, primaryKey);
4282    
4283                    if (assetEntry == _nullAssetEntry) {
4284                            return null;
4285                    }
4286    
4287                    if (assetEntry == null) {
4288                            Session session = null;
4289    
4290                            try {
4291                                    session = openSession();
4292    
4293                                    assetEntry = (AssetEntry)session.get(AssetEntryImpl.class,
4294                                                    primaryKey);
4295    
4296                                    if (assetEntry != null) {
4297                                            cacheResult(assetEntry);
4298                                    }
4299                                    else {
4300                                            entityCache.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4301                                                    AssetEntryImpl.class, primaryKey, _nullAssetEntry);
4302                                    }
4303                            }
4304                            catch (Exception e) {
4305                                    entityCache.removeResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4306                                            AssetEntryImpl.class, primaryKey);
4307    
4308                                    throw processException(e);
4309                            }
4310                            finally {
4311                                    closeSession(session);
4312                            }
4313                    }
4314    
4315                    return assetEntry;
4316            }
4317    
4318            /**
4319             * Returns the asset entry with the primary key or returns <code>null</code> if it could not be found.
4320             *
4321             * @param entryId the primary key of the asset entry
4322             * @return the asset entry, or <code>null</code> if a asset entry with the primary key could not be found
4323             */
4324            @Override
4325            public AssetEntry fetchByPrimaryKey(long entryId) {
4326                    return fetchByPrimaryKey((Serializable)entryId);
4327            }
4328    
4329            @Override
4330            public Map<Serializable, AssetEntry> fetchByPrimaryKeys(
4331                    Set<Serializable> primaryKeys) {
4332                    if (primaryKeys.isEmpty()) {
4333                            return Collections.emptyMap();
4334                    }
4335    
4336                    Map<Serializable, AssetEntry> map = new HashMap<Serializable, AssetEntry>();
4337    
4338                    if (primaryKeys.size() == 1) {
4339                            Iterator<Serializable> iterator = primaryKeys.iterator();
4340    
4341                            Serializable primaryKey = iterator.next();
4342    
4343                            AssetEntry assetEntry = fetchByPrimaryKey(primaryKey);
4344    
4345                            if (assetEntry != null) {
4346                                    map.put(primaryKey, assetEntry);
4347                            }
4348    
4349                            return map;
4350                    }
4351    
4352                    Set<Serializable> uncachedPrimaryKeys = null;
4353    
4354                    for (Serializable primaryKey : primaryKeys) {
4355                            AssetEntry assetEntry = (AssetEntry)entityCache.getResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4356                                            AssetEntryImpl.class, primaryKey);
4357    
4358                            if (assetEntry == null) {
4359                                    if (uncachedPrimaryKeys == null) {
4360                                            uncachedPrimaryKeys = new HashSet<Serializable>();
4361                                    }
4362    
4363                                    uncachedPrimaryKeys.add(primaryKey);
4364                            }
4365                            else {
4366                                    map.put(primaryKey, assetEntry);
4367                            }
4368                    }
4369    
4370                    if (uncachedPrimaryKeys == null) {
4371                            return map;
4372                    }
4373    
4374                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
4375                                    1);
4376    
4377                    query.append(_SQL_SELECT_ASSETENTRY_WHERE_PKS_IN);
4378    
4379                    for (Serializable primaryKey : uncachedPrimaryKeys) {
4380                            query.append(String.valueOf(primaryKey));
4381    
4382                            query.append(StringPool.COMMA);
4383                    }
4384    
4385                    query.setIndex(query.index() - 1);
4386    
4387                    query.append(StringPool.CLOSE_PARENTHESIS);
4388    
4389                    String sql = query.toString();
4390    
4391                    Session session = null;
4392    
4393                    try {
4394                            session = openSession();
4395    
4396                            Query q = session.createQuery(sql);
4397    
4398                            for (AssetEntry assetEntry : (List<AssetEntry>)q.list()) {
4399                                    map.put(assetEntry.getPrimaryKeyObj(), assetEntry);
4400    
4401                                    cacheResult(assetEntry);
4402    
4403                                    uncachedPrimaryKeys.remove(assetEntry.getPrimaryKeyObj());
4404                            }
4405    
4406                            for (Serializable primaryKey : uncachedPrimaryKeys) {
4407                                    entityCache.putResult(AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
4408                                            AssetEntryImpl.class, primaryKey, _nullAssetEntry);
4409                            }
4410                    }
4411                    catch (Exception e) {
4412                            throw processException(e);
4413                    }
4414                    finally {
4415                            closeSession(session);
4416                    }
4417    
4418                    return map;
4419            }
4420    
4421            /**
4422             * Returns all the asset entries.
4423             *
4424             * @return the asset entries
4425             */
4426            @Override
4427            public List<AssetEntry> findAll() {
4428                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4429            }
4430    
4431            /**
4432             * Returns a range of all the asset entries.
4433             *
4434             * <p>
4435             * 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.
4436             * </p>
4437             *
4438             * @param start the lower bound of the range of asset entries
4439             * @param end the upper bound of the range of asset entries (not inclusive)
4440             * @return the range of asset entries
4441             */
4442            @Override
4443            public List<AssetEntry> findAll(int start, int end) {
4444                    return findAll(start, end, null);
4445            }
4446    
4447            /**
4448             * Returns an ordered range of all the asset entries.
4449             *
4450             * <p>
4451             * 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.
4452             * </p>
4453             *
4454             * @param start the lower bound of the range of asset entries
4455             * @param end the upper bound of the range of asset entries (not inclusive)
4456             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4457             * @return the ordered range of asset entries
4458             */
4459            @Override
4460            public List<AssetEntry> findAll(int start, int end,
4461                    OrderByComparator<AssetEntry> orderByComparator) {
4462                    return findAll(start, end, orderByComparator, true);
4463            }
4464    
4465            /**
4466             * Returns an ordered range of all the asset entries.
4467             *
4468             * <p>
4469             * 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.
4470             * </p>
4471             *
4472             * @param start the lower bound of the range of asset entries
4473             * @param end the upper bound of the range of asset entries (not inclusive)
4474             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4475             * @param retrieveFromCache whether to retrieve from the finder cache
4476             * @return the ordered range of asset entries
4477             */
4478            @Override
4479            public List<AssetEntry> findAll(int start, int end,
4480                    OrderByComparator<AssetEntry> orderByComparator,
4481                    boolean retrieveFromCache) {
4482                    boolean pagination = true;
4483                    FinderPath finderPath = null;
4484                    Object[] finderArgs = null;
4485    
4486                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4487                                    (orderByComparator == null)) {
4488                            pagination = false;
4489                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4490                            finderArgs = FINDER_ARGS_EMPTY;
4491                    }
4492                    else {
4493                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4494                            finderArgs = new Object[] { start, end, orderByComparator };
4495                    }
4496    
4497                    List<AssetEntry> list = null;
4498    
4499                    if (retrieveFromCache) {
4500                            list = (List<AssetEntry>)finderCache.getResult(finderPath,
4501                                            finderArgs, this);
4502                    }
4503    
4504                    if (list == null) {
4505                            StringBundler query = null;
4506                            String sql = null;
4507    
4508                            if (orderByComparator != null) {
4509                                    query = new StringBundler(2 +
4510                                                    (orderByComparator.getOrderByFields().length * 2));
4511    
4512                                    query.append(_SQL_SELECT_ASSETENTRY);
4513    
4514                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4515                                            orderByComparator);
4516    
4517                                    sql = query.toString();
4518                            }
4519                            else {
4520                                    sql = _SQL_SELECT_ASSETENTRY;
4521    
4522                                    if (pagination) {
4523                                            sql = sql.concat(AssetEntryModelImpl.ORDER_BY_JPQL);
4524                                    }
4525                            }
4526    
4527                            Session session = null;
4528    
4529                            try {
4530                                    session = openSession();
4531    
4532                                    Query q = session.createQuery(sql);
4533    
4534                                    if (!pagination) {
4535                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
4536                                                            start, end, false);
4537    
4538                                            Collections.sort(list);
4539    
4540                                            list = Collections.unmodifiableList(list);
4541                                    }
4542                                    else {
4543                                            list = (List<AssetEntry>)QueryUtil.list(q, getDialect(),
4544                                                            start, end);
4545                                    }
4546    
4547                                    cacheResult(list);
4548    
4549                                    finderCache.putResult(finderPath, finderArgs, list);
4550                            }
4551                            catch (Exception e) {
4552                                    finderCache.removeResult(finderPath, finderArgs);
4553    
4554                                    throw processException(e);
4555                            }
4556                            finally {
4557                                    closeSession(session);
4558                            }
4559                    }
4560    
4561                    return list;
4562            }
4563    
4564            /**
4565             * Removes all the asset entries from the database.
4566             *
4567             */
4568            @Override
4569            public void removeAll() {
4570                    for (AssetEntry assetEntry : findAll()) {
4571                            remove(assetEntry);
4572                    }
4573            }
4574    
4575            /**
4576             * Returns the number of asset entries.
4577             *
4578             * @return the number of asset entries
4579             */
4580            @Override
4581            public int countAll() {
4582                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
4583                                    FINDER_ARGS_EMPTY, this);
4584    
4585                    if (count == null) {
4586                            Session session = null;
4587    
4588                            try {
4589                                    session = openSession();
4590    
4591                                    Query q = session.createQuery(_SQL_COUNT_ASSETENTRY);
4592    
4593                                    count = (Long)q.uniqueResult();
4594    
4595                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
4596                                            count);
4597                            }
4598                            catch (Exception e) {
4599                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
4600                                            FINDER_ARGS_EMPTY);
4601    
4602                                    throw processException(e);
4603                            }
4604                            finally {
4605                                    closeSession(session);
4606                            }
4607                    }
4608    
4609                    return count.intValue();
4610            }
4611    
4612            /**
4613             * Returns the primaryKeys of asset categories associated with the asset entry.
4614             *
4615             * @param pk the primary key of the asset entry
4616             * @return long[] of the primaryKeys of asset categories associated with the asset entry
4617             */
4618            @Override
4619            public long[] getAssetCategoryPrimaryKeys(long pk) {
4620                    long[] pks = assetEntryToAssetCategoryTableMapper.getRightPrimaryKeys(pk);
4621    
4622                    return pks.clone();
4623            }
4624    
4625            /**
4626             * Returns all the asset categories associated with the asset entry.
4627             *
4628             * @param pk the primary key of the asset entry
4629             * @return the asset categories associated with the asset entry
4630             */
4631            @Override
4632            public List<com.liferay.asset.kernel.model.AssetCategory> getAssetCategories(
4633                    long pk) {
4634                    return getAssetCategories(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4635            }
4636    
4637            /**
4638             * Returns a range of all the asset categories associated with the asset entry.
4639             *
4640             * <p>
4641             * 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.
4642             * </p>
4643             *
4644             * @param pk the primary key of the asset entry
4645             * @param start the lower bound of the range of asset entries
4646             * @param end the upper bound of the range of asset entries (not inclusive)
4647             * @return the range of asset categories associated with the asset entry
4648             */
4649            @Override
4650            public List<com.liferay.asset.kernel.model.AssetCategory> getAssetCategories(
4651                    long pk, int start, int end) {
4652                    return getAssetCategories(pk, start, end, null);
4653            }
4654    
4655            /**
4656             * Returns an ordered range of all the asset categories associated with the asset entry.
4657             *
4658             * <p>
4659             * 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.
4660             * </p>
4661             *
4662             * @param pk the primary key of the asset entry
4663             * @param start the lower bound of the range of asset entries
4664             * @param end the upper bound of the range of asset entries (not inclusive)
4665             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4666             * @return the ordered range of asset categories associated with the asset entry
4667             */
4668            @Override
4669            public List<com.liferay.asset.kernel.model.AssetCategory> getAssetCategories(
4670                    long pk, int start, int end,
4671                    OrderByComparator<com.liferay.asset.kernel.model.AssetCategory> orderByComparator) {
4672                    return assetEntryToAssetCategoryTableMapper.getRightBaseModels(pk,
4673                            start, end, orderByComparator);
4674            }
4675    
4676            /**
4677             * Returns the number of asset categories associated with the asset entry.
4678             *
4679             * @param pk the primary key of the asset entry
4680             * @return the number of asset categories associated with the asset entry
4681             */
4682            @Override
4683            public int getAssetCategoriesSize(long pk) {
4684                    long[] pks = assetEntryToAssetCategoryTableMapper.getRightPrimaryKeys(pk);
4685    
4686                    return pks.length;
4687            }
4688    
4689            /**
4690             * Returns <code>true</code> if the asset category is associated with the asset entry.
4691             *
4692             * @param pk the primary key of the asset entry
4693             * @param assetCategoryPK the primary key of the asset category
4694             * @return <code>true</code> if the asset category is associated with the asset entry; <code>false</code> otherwise
4695             */
4696            @Override
4697            public boolean containsAssetCategory(long pk, long assetCategoryPK) {
4698                    return assetEntryToAssetCategoryTableMapper.containsTableMapping(pk,
4699                            assetCategoryPK);
4700            }
4701    
4702            /**
4703             * Returns <code>true</code> if the asset entry has any asset categories associated with it.
4704             *
4705             * @param pk the primary key of the asset entry to check for associations with asset categories
4706             * @return <code>true</code> if the asset entry has any asset categories associated with it; <code>false</code> otherwise
4707             */
4708            @Override
4709            public boolean containsAssetCategories(long pk) {
4710                    if (getAssetCategoriesSize(pk) > 0) {
4711                            return true;
4712                    }
4713                    else {
4714                            return false;
4715                    }
4716            }
4717    
4718            /**
4719             * Adds an association between the asset entry and the asset category. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4720             *
4721             * @param pk the primary key of the asset entry
4722             * @param assetCategoryPK the primary key of the asset category
4723             */
4724            @Override
4725            public void addAssetCategory(long pk, long assetCategoryPK) {
4726                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
4727    
4728                    if (assetEntry == null) {
4729                            assetEntryToAssetCategoryTableMapper.addTableMapping(companyProvider.getCompanyId(),
4730                                    pk, assetCategoryPK);
4731                    }
4732                    else {
4733                            assetEntryToAssetCategoryTableMapper.addTableMapping(assetEntry.getCompanyId(),
4734                                    pk, assetCategoryPK);
4735                    }
4736            }
4737    
4738            /**
4739             * Adds an association between the asset entry and the asset category. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4740             *
4741             * @param pk the primary key of the asset entry
4742             * @param assetCategory the asset category
4743             */
4744            @Override
4745            public void addAssetCategory(long pk,
4746                    com.liferay.asset.kernel.model.AssetCategory assetCategory) {
4747                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
4748    
4749                    if (assetEntry == null) {
4750                            assetEntryToAssetCategoryTableMapper.addTableMapping(companyProvider.getCompanyId(),
4751                                    pk, assetCategory.getPrimaryKey());
4752                    }
4753                    else {
4754                            assetEntryToAssetCategoryTableMapper.addTableMapping(assetEntry.getCompanyId(),
4755                                    pk, assetCategory.getPrimaryKey());
4756                    }
4757            }
4758    
4759            /**
4760             * Adds an association between the asset entry and the asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4761             *
4762             * @param pk the primary key of the asset entry
4763             * @param assetCategoryPKs the primary keys of the asset categories
4764             */
4765            @Override
4766            public void addAssetCategories(long pk, long[] assetCategoryPKs) {
4767                    long companyId = 0;
4768    
4769                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
4770    
4771                    if (assetEntry == null) {
4772                            companyId = companyProvider.getCompanyId();
4773                    }
4774                    else {
4775                            companyId = assetEntry.getCompanyId();
4776                    }
4777    
4778                    for (long assetCategoryPK : assetCategoryPKs) {
4779                            assetEntryToAssetCategoryTableMapper.addTableMapping(companyId, pk,
4780                                    assetCategoryPK);
4781                    }
4782            }
4783    
4784            /**
4785             * Adds an association between the asset entry and the asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4786             *
4787             * @param pk the primary key of the asset entry
4788             * @param assetCategories the asset categories
4789             */
4790            @Override
4791            public void addAssetCategories(long pk,
4792                    List<com.liferay.asset.kernel.model.AssetCategory> assetCategories) {
4793                    long companyId = 0;
4794    
4795                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
4796    
4797                    if (assetEntry == null) {
4798                            companyId = companyProvider.getCompanyId();
4799                    }
4800                    else {
4801                            companyId = assetEntry.getCompanyId();
4802                    }
4803    
4804                    for (com.liferay.asset.kernel.model.AssetCategory assetCategory : assetCategories) {
4805                            assetEntryToAssetCategoryTableMapper.addTableMapping(companyId, pk,
4806                                    assetCategory.getPrimaryKey());
4807                    }
4808            }
4809    
4810            /**
4811             * Clears all associations between the asset entry and its asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4812             *
4813             * @param pk the primary key of the asset entry to clear the associated asset categories from
4814             */
4815            @Override
4816            public void clearAssetCategories(long pk) {
4817                    assetEntryToAssetCategoryTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
4818            }
4819    
4820            /**
4821             * Removes the association between the asset entry and the asset category. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4822             *
4823             * @param pk the primary key of the asset entry
4824             * @param assetCategoryPK the primary key of the asset category
4825             */
4826            @Override
4827            public void removeAssetCategory(long pk, long assetCategoryPK) {
4828                    assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4829                            assetCategoryPK);
4830            }
4831    
4832            /**
4833             * Removes the association between the asset entry and the asset category. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4834             *
4835             * @param pk the primary key of the asset entry
4836             * @param assetCategory the asset category
4837             */
4838            @Override
4839            public void removeAssetCategory(long pk,
4840                    com.liferay.asset.kernel.model.AssetCategory assetCategory) {
4841                    assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4842                            assetCategory.getPrimaryKey());
4843            }
4844    
4845            /**
4846             * Removes the association between the asset entry and the asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4847             *
4848             * @param pk the primary key of the asset entry
4849             * @param assetCategoryPKs the primary keys of the asset categories
4850             */
4851            @Override
4852            public void removeAssetCategories(long pk, long[] assetCategoryPKs) {
4853                    for (long assetCategoryPK : assetCategoryPKs) {
4854                            assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4855                                    assetCategoryPK);
4856                    }
4857            }
4858    
4859            /**
4860             * Removes the association between the asset entry and the asset categories. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4861             *
4862             * @param pk the primary key of the asset entry
4863             * @param assetCategories the asset categories
4864             */
4865            @Override
4866            public void removeAssetCategories(long pk,
4867                    List<com.liferay.asset.kernel.model.AssetCategory> assetCategories) {
4868                    for (com.liferay.asset.kernel.model.AssetCategory assetCategory : assetCategories) {
4869                            assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4870                                    assetCategory.getPrimaryKey());
4871                    }
4872            }
4873    
4874            /**
4875             * 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.
4876             *
4877             * @param pk the primary key of the asset entry
4878             * @param assetCategoryPKs the primary keys of the asset categories to be associated with the asset entry
4879             */
4880            @Override
4881            public void setAssetCategories(long pk, long[] assetCategoryPKs) {
4882                    Set<Long> newAssetCategoryPKsSet = SetUtil.fromArray(assetCategoryPKs);
4883                    Set<Long> oldAssetCategoryPKsSet = SetUtil.fromArray(assetEntryToAssetCategoryTableMapper.getRightPrimaryKeys(
4884                                            pk));
4885    
4886                    Set<Long> removeAssetCategoryPKsSet = new HashSet<Long>(oldAssetCategoryPKsSet);
4887    
4888                    removeAssetCategoryPKsSet.removeAll(newAssetCategoryPKsSet);
4889    
4890                    for (long removeAssetCategoryPK : removeAssetCategoryPKsSet) {
4891                            assetEntryToAssetCategoryTableMapper.deleteTableMapping(pk,
4892                                    removeAssetCategoryPK);
4893                    }
4894    
4895                    newAssetCategoryPKsSet.removeAll(oldAssetCategoryPKsSet);
4896    
4897                    long companyId = 0;
4898    
4899                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
4900    
4901                    if (assetEntry == null) {
4902                            companyId = companyProvider.getCompanyId();
4903                    }
4904                    else {
4905                            companyId = assetEntry.getCompanyId();
4906                    }
4907    
4908                    for (long newAssetCategoryPK : newAssetCategoryPKsSet) {
4909                            assetEntryToAssetCategoryTableMapper.addTableMapping(companyId, pk,
4910                                    newAssetCategoryPK);
4911                    }
4912            }
4913    
4914            /**
4915             * 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.
4916             *
4917             * @param pk the primary key of the asset entry
4918             * @param assetCategories the asset categories to be associated with the asset entry
4919             */
4920            @Override
4921            public void setAssetCategories(long pk,
4922                    List<com.liferay.asset.kernel.model.AssetCategory> assetCategories) {
4923                    try {
4924                            long[] assetCategoryPKs = new long[assetCategories.size()];
4925    
4926                            for (int i = 0; i < assetCategories.size(); i++) {
4927                                    com.liferay.asset.kernel.model.AssetCategory assetCategory = assetCategories.get(i);
4928    
4929                                    assetCategoryPKs[i] = assetCategory.getPrimaryKey();
4930                            }
4931    
4932                            setAssetCategories(pk, assetCategoryPKs);
4933                    }
4934                    catch (Exception e) {
4935                            throw processException(e);
4936                    }
4937            }
4938    
4939            /**
4940             * Returns the primaryKeys of asset tags associated with the asset entry.
4941             *
4942             * @param pk the primary key of the asset entry
4943             * @return long[] of the primaryKeys of asset tags associated with the asset entry
4944             */
4945            @Override
4946            public long[] getAssetTagPrimaryKeys(long pk) {
4947                    long[] pks = assetEntryToAssetTagTableMapper.getRightPrimaryKeys(pk);
4948    
4949                    return pks.clone();
4950            }
4951    
4952            /**
4953             * Returns all the asset tags associated with the asset entry.
4954             *
4955             * @param pk the primary key of the asset entry
4956             * @return the asset tags associated with the asset entry
4957             */
4958            @Override
4959            public List<com.liferay.asset.kernel.model.AssetTag> getAssetTags(long pk) {
4960                    return getAssetTags(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4961            }
4962    
4963            /**
4964             * Returns a range of all the asset tags associated with the asset entry.
4965             *
4966             * <p>
4967             * 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.
4968             * </p>
4969             *
4970             * @param pk the primary key of the asset entry
4971             * @param start the lower bound of the range of asset entries
4972             * @param end the upper bound of the range of asset entries (not inclusive)
4973             * @return the range of asset tags associated with the asset entry
4974             */
4975            @Override
4976            public List<com.liferay.asset.kernel.model.AssetTag> getAssetTags(long pk,
4977                    int start, int end) {
4978                    return getAssetTags(pk, start, end, null);
4979            }
4980    
4981            /**
4982             * Returns an ordered range of all the asset tags associated with the asset entry.
4983             *
4984             * <p>
4985             * 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.
4986             * </p>
4987             *
4988             * @param pk the primary key of the asset entry
4989             * @param start the lower bound of the range of asset entries
4990             * @param end the upper bound of the range of asset entries (not inclusive)
4991             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4992             * @return the ordered range of asset tags associated with the asset entry
4993             */
4994            @Override
4995            public List<com.liferay.asset.kernel.model.AssetTag> getAssetTags(long pk,
4996                    int start, int end,
4997                    OrderByComparator<com.liferay.asset.kernel.model.AssetTag> orderByComparator) {
4998                    return assetEntryToAssetTagTableMapper.getRightBaseModels(pk, start,
4999                            end, orderByComparator);
5000            }
5001    
5002            /**
5003             * Returns the number of asset tags associated with the asset entry.
5004             *
5005             * @param pk the primary key of the asset entry
5006             * @return the number of asset tags associated with the asset entry
5007             */
5008            @Override
5009            public int getAssetTagsSize(long pk) {
5010                    long[] pks = assetEntryToAssetTagTableMapper.getRightPrimaryKeys(pk);
5011    
5012                    return pks.length;
5013            }
5014    
5015            /**
5016             * Returns <code>true</code> if the asset tag is associated with the asset entry.
5017             *
5018             * @param pk the primary key of the asset entry
5019             * @param assetTagPK the primary key of the asset tag
5020             * @return <code>true</code> if the asset tag is associated with the asset entry; <code>false</code> otherwise
5021             */
5022            @Override
5023            public boolean containsAssetTag(long pk, long assetTagPK) {
5024                    return assetEntryToAssetTagTableMapper.containsTableMapping(pk,
5025                            assetTagPK);
5026            }
5027    
5028            /**
5029             * Returns <code>true</code> if the asset entry has any asset tags associated with it.
5030             *
5031             * @param pk the primary key of the asset entry to check for associations with asset tags
5032             * @return <code>true</code> if the asset entry has any asset tags associated with it; <code>false</code> otherwise
5033             */
5034            @Override
5035            public boolean containsAssetTags(long pk) {
5036                    if (getAssetTagsSize(pk) > 0) {
5037                            return true;
5038                    }
5039                    else {
5040                            return false;
5041                    }
5042            }
5043    
5044            /**
5045             * Adds an association between the asset entry and the asset tag. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5046             *
5047             * @param pk the primary key of the asset entry
5048             * @param assetTagPK the primary key of the asset tag
5049             */
5050            @Override
5051            public void addAssetTag(long pk, long assetTagPK) {
5052                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
5053    
5054                    if (assetEntry == null) {
5055                            assetEntryToAssetTagTableMapper.addTableMapping(companyProvider.getCompanyId(),
5056                                    pk, assetTagPK);
5057                    }
5058                    else {
5059                            assetEntryToAssetTagTableMapper.addTableMapping(assetEntry.getCompanyId(),
5060                                    pk, assetTagPK);
5061                    }
5062            }
5063    
5064            /**
5065             * Adds an association between the asset entry and the asset tag. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5066             *
5067             * @param pk the primary key of the asset entry
5068             * @param assetTag the asset tag
5069             */
5070            @Override
5071            public void addAssetTag(long pk,
5072                    com.liferay.asset.kernel.model.AssetTag assetTag) {
5073                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
5074    
5075                    if (assetEntry == null) {
5076                            assetEntryToAssetTagTableMapper.addTableMapping(companyProvider.getCompanyId(),
5077                                    pk, assetTag.getPrimaryKey());
5078                    }
5079                    else {
5080                            assetEntryToAssetTagTableMapper.addTableMapping(assetEntry.getCompanyId(),
5081                                    pk, assetTag.getPrimaryKey());
5082                    }
5083            }
5084    
5085            /**
5086             * Adds an association between the asset entry and the asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5087             *
5088             * @param pk the primary key of the asset entry
5089             * @param assetTagPKs the primary keys of the asset tags
5090             */
5091            @Override
5092            public void addAssetTags(long pk, long[] assetTagPKs) {
5093                    long companyId = 0;
5094    
5095                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
5096    
5097                    if (assetEntry == null) {
5098                            companyId = companyProvider.getCompanyId();
5099                    }
5100                    else {
5101                            companyId = assetEntry.getCompanyId();
5102                    }
5103    
5104                    for (long assetTagPK : assetTagPKs) {
5105                            assetEntryToAssetTagTableMapper.addTableMapping(companyId, pk,
5106                                    assetTagPK);
5107                    }
5108            }
5109    
5110            /**
5111             * Adds an association between the asset entry and the asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5112             *
5113             * @param pk the primary key of the asset entry
5114             * @param assetTags the asset tags
5115             */
5116            @Override
5117            public void addAssetTags(long pk,
5118                    List<com.liferay.asset.kernel.model.AssetTag> assetTags) {
5119                    long companyId = 0;
5120    
5121                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
5122    
5123                    if (assetEntry == null) {
5124                            companyId = companyProvider.getCompanyId();
5125                    }
5126                    else {
5127                            companyId = assetEntry.getCompanyId();
5128                    }
5129    
5130                    for (com.liferay.asset.kernel.model.AssetTag assetTag : assetTags) {
5131                            assetEntryToAssetTagTableMapper.addTableMapping(companyId, pk,
5132                                    assetTag.getPrimaryKey());
5133                    }
5134            }
5135    
5136            /**
5137             * Clears all associations between the asset entry and its asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5138             *
5139             * @param pk the primary key of the asset entry to clear the associated asset tags from
5140             */
5141            @Override
5142            public void clearAssetTags(long pk) {
5143                    assetEntryToAssetTagTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
5144            }
5145    
5146            /**
5147             * Removes the association between the asset entry and the asset tag. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5148             *
5149             * @param pk the primary key of the asset entry
5150             * @param assetTagPK the primary key of the asset tag
5151             */
5152            @Override
5153            public void removeAssetTag(long pk, long assetTagPK) {
5154                    assetEntryToAssetTagTableMapper.deleteTableMapping(pk, assetTagPK);
5155            }
5156    
5157            /**
5158             * Removes the association between the asset entry and the asset tag. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5159             *
5160             * @param pk the primary key of the asset entry
5161             * @param assetTag the asset tag
5162             */
5163            @Override
5164            public void removeAssetTag(long pk,
5165                    com.liferay.asset.kernel.model.AssetTag assetTag) {
5166                    assetEntryToAssetTagTableMapper.deleteTableMapping(pk,
5167                            assetTag.getPrimaryKey());
5168            }
5169    
5170            /**
5171             * Removes the association between the asset entry and the asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5172             *
5173             * @param pk the primary key of the asset entry
5174             * @param assetTagPKs the primary keys of the asset tags
5175             */
5176            @Override
5177            public void removeAssetTags(long pk, long[] assetTagPKs) {
5178                    for (long assetTagPK : assetTagPKs) {
5179                            assetEntryToAssetTagTableMapper.deleteTableMapping(pk, assetTagPK);
5180                    }
5181            }
5182    
5183            /**
5184             * Removes the association between the asset entry and the asset tags. Also notifies the appropriate model listeners and clears the mapping table finder cache.
5185             *
5186             * @param pk the primary key of the asset entry
5187             * @param assetTags the asset tags
5188             */
5189            @Override
5190            public void removeAssetTags(long pk,
5191                    List<com.liferay.asset.kernel.model.AssetTag> assetTags) {
5192                    for (com.liferay.asset.kernel.model.AssetTag assetTag : assetTags) {
5193                            assetEntryToAssetTagTableMapper.deleteTableMapping(pk,
5194                                    assetTag.getPrimaryKey());
5195                    }
5196            }
5197    
5198            /**
5199             * 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.
5200             *
5201             * @param pk the primary key of the asset entry
5202             * @param assetTagPKs the primary keys of the asset tags to be associated with the asset entry
5203             */
5204            @Override
5205            public void setAssetTags(long pk, long[] assetTagPKs) {
5206                    Set<Long> newAssetTagPKsSet = SetUtil.fromArray(assetTagPKs);
5207                    Set<Long> oldAssetTagPKsSet = SetUtil.fromArray(assetEntryToAssetTagTableMapper.getRightPrimaryKeys(
5208                                            pk));
5209    
5210                    Set<Long> removeAssetTagPKsSet = new HashSet<Long>(oldAssetTagPKsSet);
5211    
5212                    removeAssetTagPKsSet.removeAll(newAssetTagPKsSet);
5213    
5214                    for (long removeAssetTagPK : removeAssetTagPKsSet) {
5215                            assetEntryToAssetTagTableMapper.deleteTableMapping(pk,
5216                                    removeAssetTagPK);
5217                    }
5218    
5219                    newAssetTagPKsSet.removeAll(oldAssetTagPKsSet);
5220    
5221                    long companyId = 0;
5222    
5223                    AssetEntry assetEntry = fetchByPrimaryKey(pk);
5224    
5225                    if (assetEntry == null) {
5226                            companyId = companyProvider.getCompanyId();
5227                    }
5228                    else {
5229                            companyId = assetEntry.getCompanyId();
5230                    }
5231    
5232                    for (long newAssetTagPK : newAssetTagPKsSet) {
5233                            assetEntryToAssetTagTableMapper.addTableMapping(companyId, pk,
5234                                    newAssetTagPK);
5235                    }
5236            }
5237    
5238            /**
5239             * 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.
5240             *
5241             * @param pk the primary key of the asset entry
5242             * @param assetTags the asset tags to be associated with the asset entry
5243             */
5244            @Override
5245            public void setAssetTags(long pk,
5246                    List<com.liferay.asset.kernel.model.AssetTag> assetTags) {
5247                    try {
5248                            long[] assetTagPKs = new long[assetTags.size()];
5249    
5250                            for (int i = 0; i < assetTags.size(); i++) {
5251                                    com.liferay.asset.kernel.model.AssetTag assetTag = assetTags.get(i);
5252    
5253                                    assetTagPKs[i] = assetTag.getPrimaryKey();
5254                            }
5255    
5256                            setAssetTags(pk, assetTagPKs);
5257                    }
5258                    catch (Exception e) {
5259                            throw processException(e);
5260                    }
5261            }
5262    
5263            @Override
5264            protected Map<String, Integer> getTableColumnsMap() {
5265                    return AssetEntryModelImpl.TABLE_COLUMNS_MAP;
5266            }
5267    
5268            /**
5269             * Initializes the asset entry persistence.
5270             */
5271            public void afterPropertiesSet() {
5272                    assetEntryToAssetCategoryTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetCategories",
5273                                    "companyId", "entryId", "categoryId", this,
5274                                    assetCategoryPersistence);
5275    
5276                    assetEntryToAssetTagTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetTags",
5277                                    "companyId", "entryId", "tagId", this, assetTagPersistence);
5278            }
5279    
5280            public void destroy() {
5281                    entityCache.removeCache(AssetEntryImpl.class.getName());
5282                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
5283                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5284                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5285    
5286                    TableMapperFactory.removeTableMapper("AssetEntries_AssetCategories");
5287                    TableMapperFactory.removeTableMapper("AssetEntries_AssetTags");
5288            }
5289    
5290            @BeanReference(type = CompanyProviderWrapper.class)
5291            protected CompanyProvider companyProvider;
5292            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
5293            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
5294            @BeanReference(type = AssetCategoryPersistence.class)
5295            protected AssetCategoryPersistence assetCategoryPersistence;
5296            protected TableMapper<AssetEntry, com.liferay.asset.kernel.model.AssetCategory> assetEntryToAssetCategoryTableMapper;
5297            @BeanReference(type = AssetTagPersistence.class)
5298            protected AssetTagPersistence assetTagPersistence;
5299            protected TableMapper<AssetEntry, com.liferay.asset.kernel.model.AssetTag> assetEntryToAssetTagTableMapper;
5300            private static final String _SQL_SELECT_ASSETENTRY = "SELECT assetEntry FROM AssetEntry assetEntry";
5301            private static final String _SQL_SELECT_ASSETENTRY_WHERE_PKS_IN = "SELECT assetEntry FROM AssetEntry assetEntry WHERE entryId IN (";
5302            private static final String _SQL_SELECT_ASSETENTRY_WHERE = "SELECT assetEntry FROM AssetEntry assetEntry WHERE ";
5303            private static final String _SQL_COUNT_ASSETENTRY = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry";
5304            private static final String _SQL_COUNT_ASSETENTRY_WHERE = "SELECT COUNT(assetEntry) FROM AssetEntry assetEntry WHERE ";
5305            private static final String _ORDER_BY_ENTITY_ALIAS = "assetEntry.";
5306            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetEntry exists with the primary key ";
5307            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetEntry exists with the key {";
5308            private static final Log _log = LogFactoryUtil.getLog(AssetEntryPersistenceImpl.class);
5309            private static final AssetEntry _nullAssetEntry = new AssetEntryImpl() {
5310                            @Override
5311                            public Object clone() {
5312                                    return this;
5313                            }
5314    
5315                            @Override
5316                            public CacheModel<AssetEntry> toCacheModel() {
5317                                    return _nullAssetEntryCacheModel;
5318                            }
5319                    };
5320    
5321            private static final CacheModel<AssetEntry> _nullAssetEntryCacheModel = new CacheModel<AssetEntry>() {
5322                            @Override
5323                            public AssetEntry toEntityModel() {
5324                                    return _nullAssetEntry;
5325                            }
5326                    };
5327    }