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.trash.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.OrderByComparator;
030    import com.liferay.portal.kernel.util.StringBundler;
031    import com.liferay.portal.kernel.util.StringPool;
032    import com.liferay.portal.model.CacheModel;
033    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
034    
035    import com.liferay.portlet.trash.NoSuchEntryException;
036    import com.liferay.portlet.trash.model.TrashEntry;
037    import com.liferay.portlet.trash.model.impl.TrashEntryImpl;
038    import com.liferay.portlet.trash.model.impl.TrashEntryModelImpl;
039    import com.liferay.portlet.trash.service.persistence.TrashEntryPersistence;
040    
041    import java.io.Serializable;
042    
043    import java.sql.Timestamp;
044    
045    import java.util.Collections;
046    import java.util.Date;
047    import java.util.HashMap;
048    import java.util.HashSet;
049    import java.util.Iterator;
050    import java.util.List;
051    import java.util.Map;
052    import java.util.Set;
053    
054    /**
055     * The persistence implementation for the trash entry service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see TrashEntryPersistence
063     * @see TrashEntryUtil
064     * @generated
065     */
066    @ProviderType
067    public class TrashEntryPersistenceImpl extends BasePersistenceImpl<TrashEntry>
068            implements TrashEntryPersistence {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link TrashEntryUtil} to access the trash entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
073             */
074            public static final String FINDER_CLASS_NAME_ENTITY = TrashEntryImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List1";
077            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List2";
079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
080                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
081                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
082            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
083                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
086                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
089                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
091                            new String[] {
092                                    Long.class.getName(),
093                                    
094                            Integer.class.getName(), Integer.class.getName(),
095                                    OrderByComparator.class.getName()
096                            });
097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
098                    new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
099                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
101                            new String[] { Long.class.getName() },
102                            TrashEntryModelImpl.GROUPID_COLUMN_BITMASK |
103                            TrashEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
105                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
107                            new String[] { Long.class.getName() });
108    
109            /**
110             * Returns all the trash entries where groupId = &#63;.
111             *
112             * @param groupId the group ID
113             * @return the matching trash entries
114             */
115            @Override
116            public List<TrashEntry> findByGroupId(long groupId) {
117                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
118            }
119    
120            /**
121             * Returns a range of all the trash entries where groupId = &#63;.
122             *
123             * <p>
124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
125             * </p>
126             *
127             * @param groupId the group ID
128             * @param start the lower bound of the range of trash entries
129             * @param end the upper bound of the range of trash entries (not inclusive)
130             * @return the range of matching trash entries
131             */
132            @Override
133            public List<TrashEntry> findByGroupId(long groupId, int start, int end) {
134                    return findByGroupId(groupId, start, end, null);
135            }
136    
137            /**
138             * Returns an ordered range of all the trash entries where groupId = &#63;.
139             *
140             * <p>
141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
142             * </p>
143             *
144             * @param groupId the group ID
145             * @param start the lower bound of the range of trash entries
146             * @param end the upper bound of the range of trash entries (not inclusive)
147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
148             * @return the ordered range of matching trash entries
149             */
150            @Override
151            public List<TrashEntry> findByGroupId(long groupId, int start, int end,
152                    OrderByComparator<TrashEntry> orderByComparator) {
153                    boolean pagination = true;
154                    FinderPath finderPath = null;
155                    Object[] finderArgs = null;
156    
157                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
158                                    (orderByComparator == null)) {
159                            pagination = false;
160                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
161                            finderArgs = new Object[] { groupId };
162                    }
163                    else {
164                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
165                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
166                    }
167    
168                    List<TrashEntry> list = (List<TrashEntry>)FinderCacheUtil.getResult(finderPath,
169                                    finderArgs, this);
170    
171                    if ((list != null) && !list.isEmpty()) {
172                            for (TrashEntry trashEntry : list) {
173                                    if ((groupId != trashEntry.getGroupId())) {
174                                            list = null;
175    
176                                            break;
177                                    }
178                            }
179                    }
180    
181                    if (list == null) {
182                            StringBundler query = null;
183    
184                            if (orderByComparator != null) {
185                                    query = new StringBundler(3 +
186                                                    (orderByComparator.getOrderByFields().length * 3));
187                            }
188                            else {
189                                    query = new StringBundler(3);
190                            }
191    
192                            query.append(_SQL_SELECT_TRASHENTRY_WHERE);
193    
194                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
195    
196                            if (orderByComparator != null) {
197                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
198                                            orderByComparator);
199                            }
200                            else
201                             if (pagination) {
202                                    query.append(TrashEntryModelImpl.ORDER_BY_JPQL);
203                            }
204    
205                            String sql = query.toString();
206    
207                            Session session = null;
208    
209                            try {
210                                    session = openSession();
211    
212                                    Query q = session.createQuery(sql);
213    
214                                    QueryPos qPos = QueryPos.getInstance(q);
215    
216                                    qPos.add(groupId);
217    
218                                    if (!pagination) {
219                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
220                                                            start, end, false);
221    
222                                            Collections.sort(list);
223    
224                                            list = Collections.unmodifiableList(list);
225                                    }
226                                    else {
227                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
228                                                            start, end);
229                                    }
230    
231                                    cacheResult(list);
232    
233                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
234                            }
235                            catch (Exception e) {
236                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
237    
238                                    throw processException(e);
239                            }
240                            finally {
241                                    closeSession(session);
242                            }
243                    }
244    
245                    return list;
246            }
247    
248            /**
249             * Returns the first trash entry in the ordered set where groupId = &#63;.
250             *
251             * @param groupId the group ID
252             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
253             * @return the first matching trash entry
254             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
255             */
256            @Override
257            public TrashEntry findByGroupId_First(long groupId,
258                    OrderByComparator<TrashEntry> orderByComparator)
259                    throws NoSuchEntryException {
260                    TrashEntry trashEntry = fetchByGroupId_First(groupId, orderByComparator);
261    
262                    if (trashEntry != null) {
263                            return trashEntry;
264                    }
265    
266                    StringBundler msg = new StringBundler(4);
267    
268                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
269    
270                    msg.append("groupId=");
271                    msg.append(groupId);
272    
273                    msg.append(StringPool.CLOSE_CURLY_BRACE);
274    
275                    throw new NoSuchEntryException(msg.toString());
276            }
277    
278            /**
279             * Returns the first trash entry in the ordered set where groupId = &#63;.
280             *
281             * @param groupId the group ID
282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
283             * @return the first matching trash entry, or <code>null</code> if a matching trash entry could not be found
284             */
285            @Override
286            public TrashEntry fetchByGroupId_First(long groupId,
287                    OrderByComparator<TrashEntry> orderByComparator) {
288                    List<TrashEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
289    
290                    if (!list.isEmpty()) {
291                            return list.get(0);
292                    }
293    
294                    return null;
295            }
296    
297            /**
298             * Returns the last trash entry in the ordered set where groupId = &#63;.
299             *
300             * @param groupId the group ID
301             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
302             * @return the last matching trash entry
303             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
304             */
305            @Override
306            public TrashEntry findByGroupId_Last(long groupId,
307                    OrderByComparator<TrashEntry> orderByComparator)
308                    throws NoSuchEntryException {
309                    TrashEntry trashEntry = fetchByGroupId_Last(groupId, orderByComparator);
310    
311                    if (trashEntry != null) {
312                            return trashEntry;
313                    }
314    
315                    StringBundler msg = new StringBundler(4);
316    
317                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
318    
319                    msg.append("groupId=");
320                    msg.append(groupId);
321    
322                    msg.append(StringPool.CLOSE_CURLY_BRACE);
323    
324                    throw new NoSuchEntryException(msg.toString());
325            }
326    
327            /**
328             * Returns the last trash entry in the ordered set where groupId = &#63;.
329             *
330             * @param groupId the group ID
331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
332             * @return the last matching trash entry, or <code>null</code> if a matching trash entry could not be found
333             */
334            @Override
335            public TrashEntry fetchByGroupId_Last(long groupId,
336                    OrderByComparator<TrashEntry> orderByComparator) {
337                    int count = countByGroupId(groupId);
338    
339                    if (count == 0) {
340                            return null;
341                    }
342    
343                    List<TrashEntry> list = findByGroupId(groupId, count - 1, count,
344                                    orderByComparator);
345    
346                    if (!list.isEmpty()) {
347                            return list.get(0);
348                    }
349    
350                    return null;
351            }
352    
353            /**
354             * Returns the trash entries before and after the current trash entry in the ordered set where groupId = &#63;.
355             *
356             * @param entryId the primary key of the current trash entry
357             * @param groupId the group ID
358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
359             * @return the previous, current, and next trash entry
360             * @throws com.liferay.portlet.trash.NoSuchEntryException if a trash entry with the primary key could not be found
361             */
362            @Override
363            public TrashEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
364                    OrderByComparator<TrashEntry> orderByComparator)
365                    throws NoSuchEntryException {
366                    TrashEntry trashEntry = findByPrimaryKey(entryId);
367    
368                    Session session = null;
369    
370                    try {
371                            session = openSession();
372    
373                            TrashEntry[] array = new TrashEntryImpl[3];
374    
375                            array[0] = getByGroupId_PrevAndNext(session, trashEntry, groupId,
376                                            orderByComparator, true);
377    
378                            array[1] = trashEntry;
379    
380                            array[2] = getByGroupId_PrevAndNext(session, trashEntry, groupId,
381                                            orderByComparator, false);
382    
383                            return array;
384                    }
385                    catch (Exception e) {
386                            throw processException(e);
387                    }
388                    finally {
389                            closeSession(session);
390                    }
391            }
392    
393            protected TrashEntry getByGroupId_PrevAndNext(Session session,
394                    TrashEntry trashEntry, long groupId,
395                    OrderByComparator<TrashEntry> orderByComparator, boolean previous) {
396                    StringBundler query = null;
397    
398                    if (orderByComparator != null) {
399                            query = new StringBundler(6 +
400                                            (orderByComparator.getOrderByFields().length * 6));
401                    }
402                    else {
403                            query = new StringBundler(3);
404                    }
405    
406                    query.append(_SQL_SELECT_TRASHENTRY_WHERE);
407    
408                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
409    
410                    if (orderByComparator != null) {
411                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
412    
413                            if (orderByConditionFields.length > 0) {
414                                    query.append(WHERE_AND);
415                            }
416    
417                            for (int i = 0; i < orderByConditionFields.length; i++) {
418                                    query.append(_ORDER_BY_ENTITY_ALIAS);
419                                    query.append(orderByConditionFields[i]);
420    
421                                    if ((i + 1) < orderByConditionFields.length) {
422                                            if (orderByComparator.isAscending() ^ previous) {
423                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
424                                            }
425                                            else {
426                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
427                                            }
428                                    }
429                                    else {
430                                            if (orderByComparator.isAscending() ^ previous) {
431                                                    query.append(WHERE_GREATER_THAN);
432                                            }
433                                            else {
434                                                    query.append(WHERE_LESSER_THAN);
435                                            }
436                                    }
437                            }
438    
439                            query.append(ORDER_BY_CLAUSE);
440    
441                            String[] orderByFields = orderByComparator.getOrderByFields();
442    
443                            for (int i = 0; i < orderByFields.length; i++) {
444                                    query.append(_ORDER_BY_ENTITY_ALIAS);
445                                    query.append(orderByFields[i]);
446    
447                                    if ((i + 1) < orderByFields.length) {
448                                            if (orderByComparator.isAscending() ^ previous) {
449                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
450                                            }
451                                            else {
452                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
453                                            }
454                                    }
455                                    else {
456                                            if (orderByComparator.isAscending() ^ previous) {
457                                                    query.append(ORDER_BY_ASC);
458                                            }
459                                            else {
460                                                    query.append(ORDER_BY_DESC);
461                                            }
462                                    }
463                            }
464                    }
465                    else {
466                            query.append(TrashEntryModelImpl.ORDER_BY_JPQL);
467                    }
468    
469                    String sql = query.toString();
470    
471                    Query q = session.createQuery(sql);
472    
473                    q.setFirstResult(0);
474                    q.setMaxResults(2);
475    
476                    QueryPos qPos = QueryPos.getInstance(q);
477    
478                    qPos.add(groupId);
479    
480                    if (orderByComparator != null) {
481                            Object[] values = orderByComparator.getOrderByConditionValues(trashEntry);
482    
483                            for (Object value : values) {
484                                    qPos.add(value);
485                            }
486                    }
487    
488                    List<TrashEntry> list = q.list();
489    
490                    if (list.size() == 2) {
491                            return list.get(1);
492                    }
493                    else {
494                            return null;
495                    }
496            }
497    
498            /**
499             * Removes all the trash entries where groupId = &#63; from the database.
500             *
501             * @param groupId the group ID
502             */
503            @Override
504            public void removeByGroupId(long groupId) {
505                    for (TrashEntry trashEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
506                                    QueryUtil.ALL_POS, null)) {
507                            remove(trashEntry);
508                    }
509            }
510    
511            /**
512             * Returns the number of trash entries where groupId = &#63;.
513             *
514             * @param groupId the group ID
515             * @return the number of matching trash entries
516             */
517            @Override
518            public int countByGroupId(long groupId) {
519                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
520    
521                    Object[] finderArgs = new Object[] { groupId };
522    
523                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
524                                    this);
525    
526                    if (count == null) {
527                            StringBundler query = new StringBundler(2);
528    
529                            query.append(_SQL_COUNT_TRASHENTRY_WHERE);
530    
531                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
532    
533                            String sql = query.toString();
534    
535                            Session session = null;
536    
537                            try {
538                                    session = openSession();
539    
540                                    Query q = session.createQuery(sql);
541    
542                                    QueryPos qPos = QueryPos.getInstance(q);
543    
544                                    qPos.add(groupId);
545    
546                                    count = (Long)q.uniqueResult();
547    
548                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
549                            }
550                            catch (Exception e) {
551                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
552    
553                                    throw processException(e);
554                            }
555                            finally {
556                                    closeSession(session);
557                            }
558                    }
559    
560                    return count.intValue();
561            }
562    
563            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "trashEntry.groupId = ?";
564            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
565                    new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
566                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
567                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
568                            new String[] {
569                                    Long.class.getName(),
570                                    
571                            Integer.class.getName(), Integer.class.getName(),
572                                    OrderByComparator.class.getName()
573                            });
574            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
575                    new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
576                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
577                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
578                            new String[] { Long.class.getName() },
579                            TrashEntryModelImpl.COMPANYID_COLUMN_BITMASK |
580                            TrashEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
581            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
582                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
583                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
584                            new String[] { Long.class.getName() });
585    
586            /**
587             * Returns all the trash entries where companyId = &#63;.
588             *
589             * @param companyId the company ID
590             * @return the matching trash entries
591             */
592            @Override
593            public List<TrashEntry> findByCompanyId(long companyId) {
594                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
595                            null);
596            }
597    
598            /**
599             * Returns a range of all the trash entries where companyId = &#63;.
600             *
601             * <p>
602             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
603             * </p>
604             *
605             * @param companyId the company ID
606             * @param start the lower bound of the range of trash entries
607             * @param end the upper bound of the range of trash entries (not inclusive)
608             * @return the range of matching trash entries
609             */
610            @Override
611            public List<TrashEntry> findByCompanyId(long companyId, int start, int end) {
612                    return findByCompanyId(companyId, start, end, null);
613            }
614    
615            /**
616             * Returns an ordered range of all the trash entries where companyId = &#63;.
617             *
618             * <p>
619             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
620             * </p>
621             *
622             * @param companyId the company ID
623             * @param start the lower bound of the range of trash entries
624             * @param end the upper bound of the range of trash entries (not inclusive)
625             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
626             * @return the ordered range of matching trash entries
627             */
628            @Override
629            public List<TrashEntry> findByCompanyId(long companyId, int start, int end,
630                    OrderByComparator<TrashEntry> orderByComparator) {
631                    boolean pagination = true;
632                    FinderPath finderPath = null;
633                    Object[] finderArgs = null;
634    
635                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
636                                    (orderByComparator == null)) {
637                            pagination = false;
638                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
639                            finderArgs = new Object[] { companyId };
640                    }
641                    else {
642                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
643                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
644                    }
645    
646                    List<TrashEntry> list = (List<TrashEntry>)FinderCacheUtil.getResult(finderPath,
647                                    finderArgs, this);
648    
649                    if ((list != null) && !list.isEmpty()) {
650                            for (TrashEntry trashEntry : list) {
651                                    if ((companyId != trashEntry.getCompanyId())) {
652                                            list = null;
653    
654                                            break;
655                                    }
656                            }
657                    }
658    
659                    if (list == null) {
660                            StringBundler query = null;
661    
662                            if (orderByComparator != null) {
663                                    query = new StringBundler(3 +
664                                                    (orderByComparator.getOrderByFields().length * 3));
665                            }
666                            else {
667                                    query = new StringBundler(3);
668                            }
669    
670                            query.append(_SQL_SELECT_TRASHENTRY_WHERE);
671    
672                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
673    
674                            if (orderByComparator != null) {
675                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
676                                            orderByComparator);
677                            }
678                            else
679                             if (pagination) {
680                                    query.append(TrashEntryModelImpl.ORDER_BY_JPQL);
681                            }
682    
683                            String sql = query.toString();
684    
685                            Session session = null;
686    
687                            try {
688                                    session = openSession();
689    
690                                    Query q = session.createQuery(sql);
691    
692                                    QueryPos qPos = QueryPos.getInstance(q);
693    
694                                    qPos.add(companyId);
695    
696                                    if (!pagination) {
697                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
698                                                            start, end, false);
699    
700                                            Collections.sort(list);
701    
702                                            list = Collections.unmodifiableList(list);
703                                    }
704                                    else {
705                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
706                                                            start, end);
707                                    }
708    
709                                    cacheResult(list);
710    
711                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
712                            }
713                            catch (Exception e) {
714                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
715    
716                                    throw processException(e);
717                            }
718                            finally {
719                                    closeSession(session);
720                            }
721                    }
722    
723                    return list;
724            }
725    
726            /**
727             * Returns the first trash entry in the ordered set where companyId = &#63;.
728             *
729             * @param companyId the company ID
730             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
731             * @return the first matching trash entry
732             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
733             */
734            @Override
735            public TrashEntry findByCompanyId_First(long companyId,
736                    OrderByComparator<TrashEntry> orderByComparator)
737                    throws NoSuchEntryException {
738                    TrashEntry trashEntry = fetchByCompanyId_First(companyId,
739                                    orderByComparator);
740    
741                    if (trashEntry != null) {
742                            return trashEntry;
743                    }
744    
745                    StringBundler msg = new StringBundler(4);
746    
747                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
748    
749                    msg.append("companyId=");
750                    msg.append(companyId);
751    
752                    msg.append(StringPool.CLOSE_CURLY_BRACE);
753    
754                    throw new NoSuchEntryException(msg.toString());
755            }
756    
757            /**
758             * Returns the first trash entry in the ordered set where companyId = &#63;.
759             *
760             * @param companyId the company ID
761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
762             * @return the first matching trash entry, or <code>null</code> if a matching trash entry could not be found
763             */
764            @Override
765            public TrashEntry fetchByCompanyId_First(long companyId,
766                    OrderByComparator<TrashEntry> orderByComparator) {
767                    List<TrashEntry> list = findByCompanyId(companyId, 0, 1,
768                                    orderByComparator);
769    
770                    if (!list.isEmpty()) {
771                            return list.get(0);
772                    }
773    
774                    return null;
775            }
776    
777            /**
778             * Returns the last trash entry in the ordered set where companyId = &#63;.
779             *
780             * @param companyId the company ID
781             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
782             * @return the last matching trash entry
783             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
784             */
785            @Override
786            public TrashEntry findByCompanyId_Last(long companyId,
787                    OrderByComparator<TrashEntry> orderByComparator)
788                    throws NoSuchEntryException {
789                    TrashEntry trashEntry = fetchByCompanyId_Last(companyId,
790                                    orderByComparator);
791    
792                    if (trashEntry != null) {
793                            return trashEntry;
794                    }
795    
796                    StringBundler msg = new StringBundler(4);
797    
798                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
799    
800                    msg.append("companyId=");
801                    msg.append(companyId);
802    
803                    msg.append(StringPool.CLOSE_CURLY_BRACE);
804    
805                    throw new NoSuchEntryException(msg.toString());
806            }
807    
808            /**
809             * Returns the last trash entry in the ordered set where companyId = &#63;.
810             *
811             * @param companyId the company ID
812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
813             * @return the last matching trash entry, or <code>null</code> if a matching trash entry could not be found
814             */
815            @Override
816            public TrashEntry fetchByCompanyId_Last(long companyId,
817                    OrderByComparator<TrashEntry> orderByComparator) {
818                    int count = countByCompanyId(companyId);
819    
820                    if (count == 0) {
821                            return null;
822                    }
823    
824                    List<TrashEntry> list = findByCompanyId(companyId, count - 1, count,
825                                    orderByComparator);
826    
827                    if (!list.isEmpty()) {
828                            return list.get(0);
829                    }
830    
831                    return null;
832            }
833    
834            /**
835             * Returns the trash entries before and after the current trash entry in the ordered set where companyId = &#63;.
836             *
837             * @param entryId the primary key of the current trash entry
838             * @param companyId the company ID
839             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
840             * @return the previous, current, and next trash entry
841             * @throws com.liferay.portlet.trash.NoSuchEntryException if a trash entry with the primary key could not be found
842             */
843            @Override
844            public TrashEntry[] findByCompanyId_PrevAndNext(long entryId,
845                    long companyId, OrderByComparator<TrashEntry> orderByComparator)
846                    throws NoSuchEntryException {
847                    TrashEntry trashEntry = findByPrimaryKey(entryId);
848    
849                    Session session = null;
850    
851                    try {
852                            session = openSession();
853    
854                            TrashEntry[] array = new TrashEntryImpl[3];
855    
856                            array[0] = getByCompanyId_PrevAndNext(session, trashEntry,
857                                            companyId, orderByComparator, true);
858    
859                            array[1] = trashEntry;
860    
861                            array[2] = getByCompanyId_PrevAndNext(session, trashEntry,
862                                            companyId, orderByComparator, false);
863    
864                            return array;
865                    }
866                    catch (Exception e) {
867                            throw processException(e);
868                    }
869                    finally {
870                            closeSession(session);
871                    }
872            }
873    
874            protected TrashEntry getByCompanyId_PrevAndNext(Session session,
875                    TrashEntry trashEntry, long companyId,
876                    OrderByComparator<TrashEntry> orderByComparator, boolean previous) {
877                    StringBundler query = null;
878    
879                    if (orderByComparator != null) {
880                            query = new StringBundler(6 +
881                                            (orderByComparator.getOrderByFields().length * 6));
882                    }
883                    else {
884                            query = new StringBundler(3);
885                    }
886    
887                    query.append(_SQL_SELECT_TRASHENTRY_WHERE);
888    
889                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
890    
891                    if (orderByComparator != null) {
892                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
893    
894                            if (orderByConditionFields.length > 0) {
895                                    query.append(WHERE_AND);
896                            }
897    
898                            for (int i = 0; i < orderByConditionFields.length; i++) {
899                                    query.append(_ORDER_BY_ENTITY_ALIAS);
900                                    query.append(orderByConditionFields[i]);
901    
902                                    if ((i + 1) < orderByConditionFields.length) {
903                                            if (orderByComparator.isAscending() ^ previous) {
904                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
905                                            }
906                                            else {
907                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
908                                            }
909                                    }
910                                    else {
911                                            if (orderByComparator.isAscending() ^ previous) {
912                                                    query.append(WHERE_GREATER_THAN);
913                                            }
914                                            else {
915                                                    query.append(WHERE_LESSER_THAN);
916                                            }
917                                    }
918                            }
919    
920                            query.append(ORDER_BY_CLAUSE);
921    
922                            String[] orderByFields = orderByComparator.getOrderByFields();
923    
924                            for (int i = 0; i < orderByFields.length; i++) {
925                                    query.append(_ORDER_BY_ENTITY_ALIAS);
926                                    query.append(orderByFields[i]);
927    
928                                    if ((i + 1) < orderByFields.length) {
929                                            if (orderByComparator.isAscending() ^ previous) {
930                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
931                                            }
932                                            else {
933                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
934                                            }
935                                    }
936                                    else {
937                                            if (orderByComparator.isAscending() ^ previous) {
938                                                    query.append(ORDER_BY_ASC);
939                                            }
940                                            else {
941                                                    query.append(ORDER_BY_DESC);
942                                            }
943                                    }
944                            }
945                    }
946                    else {
947                            query.append(TrashEntryModelImpl.ORDER_BY_JPQL);
948                    }
949    
950                    String sql = query.toString();
951    
952                    Query q = session.createQuery(sql);
953    
954                    q.setFirstResult(0);
955                    q.setMaxResults(2);
956    
957                    QueryPos qPos = QueryPos.getInstance(q);
958    
959                    qPos.add(companyId);
960    
961                    if (orderByComparator != null) {
962                            Object[] values = orderByComparator.getOrderByConditionValues(trashEntry);
963    
964                            for (Object value : values) {
965                                    qPos.add(value);
966                            }
967                    }
968    
969                    List<TrashEntry> list = q.list();
970    
971                    if (list.size() == 2) {
972                            return list.get(1);
973                    }
974                    else {
975                            return null;
976                    }
977            }
978    
979            /**
980             * Removes all the trash entries where companyId = &#63; from the database.
981             *
982             * @param companyId the company ID
983             */
984            @Override
985            public void removeByCompanyId(long companyId) {
986                    for (TrashEntry trashEntry : findByCompanyId(companyId,
987                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
988                            remove(trashEntry);
989                    }
990            }
991    
992            /**
993             * Returns the number of trash entries where companyId = &#63;.
994             *
995             * @param companyId the company ID
996             * @return the number of matching trash entries
997             */
998            @Override
999            public int countByCompanyId(long companyId) {
1000                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1001    
1002                    Object[] finderArgs = new Object[] { companyId };
1003    
1004                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1005                                    this);
1006    
1007                    if (count == null) {
1008                            StringBundler query = new StringBundler(2);
1009    
1010                            query.append(_SQL_COUNT_TRASHENTRY_WHERE);
1011    
1012                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1013    
1014                            String sql = query.toString();
1015    
1016                            Session session = null;
1017    
1018                            try {
1019                                    session = openSession();
1020    
1021                                    Query q = session.createQuery(sql);
1022    
1023                                    QueryPos qPos = QueryPos.getInstance(q);
1024    
1025                                    qPos.add(companyId);
1026    
1027                                    count = (Long)q.uniqueResult();
1028    
1029                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1030                            }
1031                            catch (Exception e) {
1032                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1033    
1034                                    throw processException(e);
1035                            }
1036                            finally {
1037                                    closeSession(session);
1038                            }
1039                    }
1040    
1041                    return count.intValue();
1042            }
1043    
1044            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "trashEntry.companyId = ?";
1045            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTCD = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
1046                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
1047                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtCD",
1048                            new String[] {
1049                                    Long.class.getName(), Date.class.getName(),
1050                                    
1051                            Integer.class.getName(), Integer.class.getName(),
1052                                    OrderByComparator.class.getName()
1053                            });
1054            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTCD = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
1055                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1056                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtCD",
1057                            new String[] { Long.class.getName(), Date.class.getName() });
1058    
1059            /**
1060             * Returns all the trash entries where groupId = &#63; and createDate &lt; &#63;.
1061             *
1062             * @param groupId the group ID
1063             * @param createDate the create date
1064             * @return the matching trash entries
1065             */
1066            @Override
1067            public List<TrashEntry> findByG_LtCD(long groupId, Date createDate) {
1068                    return findByG_LtCD(groupId, createDate, QueryUtil.ALL_POS,
1069                            QueryUtil.ALL_POS, null);
1070            }
1071    
1072            /**
1073             * Returns a range of all the trash entries where groupId = &#63; and createDate &lt; &#63;.
1074             *
1075             * <p>
1076             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
1077             * </p>
1078             *
1079             * @param groupId the group ID
1080             * @param createDate the create date
1081             * @param start the lower bound of the range of trash entries
1082             * @param end the upper bound of the range of trash entries (not inclusive)
1083             * @return the range of matching trash entries
1084             */
1085            @Override
1086            public List<TrashEntry> findByG_LtCD(long groupId, Date createDate,
1087                    int start, int end) {
1088                    return findByG_LtCD(groupId, createDate, start, end, null);
1089            }
1090    
1091            /**
1092             * Returns an ordered range of all the trash entries where groupId = &#63; and createDate &lt; &#63;.
1093             *
1094             * <p>
1095             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
1096             * </p>
1097             *
1098             * @param groupId the group ID
1099             * @param createDate the create date
1100             * @param start the lower bound of the range of trash entries
1101             * @param end the upper bound of the range of trash entries (not inclusive)
1102             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1103             * @return the ordered range of matching trash entries
1104             */
1105            @Override
1106            public List<TrashEntry> findByG_LtCD(long groupId, Date createDate,
1107                    int start, int end, OrderByComparator<TrashEntry> orderByComparator) {
1108                    boolean pagination = true;
1109                    FinderPath finderPath = null;
1110                    Object[] finderArgs = null;
1111    
1112                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTCD;
1113                    finderArgs = new Object[] {
1114                                    groupId, createDate,
1115                                    
1116                                    start, end, orderByComparator
1117                            };
1118    
1119                    List<TrashEntry> list = (List<TrashEntry>)FinderCacheUtil.getResult(finderPath,
1120                                    finderArgs, this);
1121    
1122                    if ((list != null) && !list.isEmpty()) {
1123                            for (TrashEntry trashEntry : list) {
1124                                    if ((groupId != trashEntry.getGroupId()) ||
1125                                                    (createDate.getTime() <= trashEntry.getCreateDate()
1126                                                                                                                               .getTime())) {
1127                                            list = null;
1128    
1129                                            break;
1130                                    }
1131                            }
1132                    }
1133    
1134                    if (list == null) {
1135                            StringBundler query = null;
1136    
1137                            if (orderByComparator != null) {
1138                                    query = new StringBundler(4 +
1139                                                    (orderByComparator.getOrderByFields().length * 3));
1140                            }
1141                            else {
1142                                    query = new StringBundler(4);
1143                            }
1144    
1145                            query.append(_SQL_SELECT_TRASHENTRY_WHERE);
1146    
1147                            query.append(_FINDER_COLUMN_G_LTCD_GROUPID_2);
1148    
1149                            boolean bindCreateDate = false;
1150    
1151                            if (createDate == null) {
1152                                    query.append(_FINDER_COLUMN_G_LTCD_CREATEDATE_1);
1153                            }
1154                            else {
1155                                    bindCreateDate = true;
1156    
1157                                    query.append(_FINDER_COLUMN_G_LTCD_CREATEDATE_2);
1158                            }
1159    
1160                            if (orderByComparator != null) {
1161                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1162                                            orderByComparator);
1163                            }
1164                            else
1165                             if (pagination) {
1166                                    query.append(TrashEntryModelImpl.ORDER_BY_JPQL);
1167                            }
1168    
1169                            String sql = query.toString();
1170    
1171                            Session session = null;
1172    
1173                            try {
1174                                    session = openSession();
1175    
1176                                    Query q = session.createQuery(sql);
1177    
1178                                    QueryPos qPos = QueryPos.getInstance(q);
1179    
1180                                    qPos.add(groupId);
1181    
1182                                    if (bindCreateDate) {
1183                                            qPos.add(new Timestamp(createDate.getTime()));
1184                                    }
1185    
1186                                    if (!pagination) {
1187                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
1188                                                            start, end, false);
1189    
1190                                            Collections.sort(list);
1191    
1192                                            list = Collections.unmodifiableList(list);
1193                                    }
1194                                    else {
1195                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
1196                                                            start, end);
1197                                    }
1198    
1199                                    cacheResult(list);
1200    
1201                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1202                            }
1203                            catch (Exception e) {
1204                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1205    
1206                                    throw processException(e);
1207                            }
1208                            finally {
1209                                    closeSession(session);
1210                            }
1211                    }
1212    
1213                    return list;
1214            }
1215    
1216            /**
1217             * Returns the first trash entry in the ordered set where groupId = &#63; and createDate &lt; &#63;.
1218             *
1219             * @param groupId the group ID
1220             * @param createDate the create date
1221             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1222             * @return the first matching trash entry
1223             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
1224             */
1225            @Override
1226            public TrashEntry findByG_LtCD_First(long groupId, Date createDate,
1227                    OrderByComparator<TrashEntry> orderByComparator)
1228                    throws NoSuchEntryException {
1229                    TrashEntry trashEntry = fetchByG_LtCD_First(groupId, createDate,
1230                                    orderByComparator);
1231    
1232                    if (trashEntry != null) {
1233                            return trashEntry;
1234                    }
1235    
1236                    StringBundler msg = new StringBundler(6);
1237    
1238                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1239    
1240                    msg.append("groupId=");
1241                    msg.append(groupId);
1242    
1243                    msg.append(", createDate=");
1244                    msg.append(createDate);
1245    
1246                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1247    
1248                    throw new NoSuchEntryException(msg.toString());
1249            }
1250    
1251            /**
1252             * Returns the first trash entry in the ordered set where groupId = &#63; and createDate &lt; &#63;.
1253             *
1254             * @param groupId the group ID
1255             * @param createDate the create date
1256             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1257             * @return the first matching trash entry, or <code>null</code> if a matching trash entry could not be found
1258             */
1259            @Override
1260            public TrashEntry fetchByG_LtCD_First(long groupId, Date createDate,
1261                    OrderByComparator<TrashEntry> orderByComparator) {
1262                    List<TrashEntry> list = findByG_LtCD(groupId, createDate, 0, 1,
1263                                    orderByComparator);
1264    
1265                    if (!list.isEmpty()) {
1266                            return list.get(0);
1267                    }
1268    
1269                    return null;
1270            }
1271    
1272            /**
1273             * Returns the last trash entry in the ordered set where groupId = &#63; and createDate &lt; &#63;.
1274             *
1275             * @param groupId the group ID
1276             * @param createDate the create date
1277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1278             * @return the last matching trash entry
1279             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
1280             */
1281            @Override
1282            public TrashEntry findByG_LtCD_Last(long groupId, Date createDate,
1283                    OrderByComparator<TrashEntry> orderByComparator)
1284                    throws NoSuchEntryException {
1285                    TrashEntry trashEntry = fetchByG_LtCD_Last(groupId, createDate,
1286                                    orderByComparator);
1287    
1288                    if (trashEntry != null) {
1289                            return trashEntry;
1290                    }
1291    
1292                    StringBundler msg = new StringBundler(6);
1293    
1294                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1295    
1296                    msg.append("groupId=");
1297                    msg.append(groupId);
1298    
1299                    msg.append(", createDate=");
1300                    msg.append(createDate);
1301    
1302                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1303    
1304                    throw new NoSuchEntryException(msg.toString());
1305            }
1306    
1307            /**
1308             * Returns the last trash entry in the ordered set where groupId = &#63; and createDate &lt; &#63;.
1309             *
1310             * @param groupId the group ID
1311             * @param createDate the create date
1312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1313             * @return the last matching trash entry, or <code>null</code> if a matching trash entry could not be found
1314             */
1315            @Override
1316            public TrashEntry fetchByG_LtCD_Last(long groupId, Date createDate,
1317                    OrderByComparator<TrashEntry> orderByComparator) {
1318                    int count = countByG_LtCD(groupId, createDate);
1319    
1320                    if (count == 0) {
1321                            return null;
1322                    }
1323    
1324                    List<TrashEntry> list = findByG_LtCD(groupId, createDate, count - 1,
1325                                    count, orderByComparator);
1326    
1327                    if (!list.isEmpty()) {
1328                            return list.get(0);
1329                    }
1330    
1331                    return null;
1332            }
1333    
1334            /**
1335             * Returns the trash entries before and after the current trash entry in the ordered set where groupId = &#63; and createDate &lt; &#63;.
1336             *
1337             * @param entryId the primary key of the current trash entry
1338             * @param groupId the group ID
1339             * @param createDate the create date
1340             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1341             * @return the previous, current, and next trash entry
1342             * @throws com.liferay.portlet.trash.NoSuchEntryException if a trash entry with the primary key could not be found
1343             */
1344            @Override
1345            public TrashEntry[] findByG_LtCD_PrevAndNext(long entryId, long groupId,
1346                    Date createDate, OrderByComparator<TrashEntry> orderByComparator)
1347                    throws NoSuchEntryException {
1348                    TrashEntry trashEntry = findByPrimaryKey(entryId);
1349    
1350                    Session session = null;
1351    
1352                    try {
1353                            session = openSession();
1354    
1355                            TrashEntry[] array = new TrashEntryImpl[3];
1356    
1357                            array[0] = getByG_LtCD_PrevAndNext(session, trashEntry, groupId,
1358                                            createDate, orderByComparator, true);
1359    
1360                            array[1] = trashEntry;
1361    
1362                            array[2] = getByG_LtCD_PrevAndNext(session, trashEntry, groupId,
1363                                            createDate, orderByComparator, false);
1364    
1365                            return array;
1366                    }
1367                    catch (Exception e) {
1368                            throw processException(e);
1369                    }
1370                    finally {
1371                            closeSession(session);
1372                    }
1373            }
1374    
1375            protected TrashEntry getByG_LtCD_PrevAndNext(Session session,
1376                    TrashEntry trashEntry, long groupId, Date createDate,
1377                    OrderByComparator<TrashEntry> orderByComparator, boolean previous) {
1378                    StringBundler query = null;
1379    
1380                    if (orderByComparator != null) {
1381                            query = new StringBundler(6 +
1382                                            (orderByComparator.getOrderByFields().length * 6));
1383                    }
1384                    else {
1385                            query = new StringBundler(3);
1386                    }
1387    
1388                    query.append(_SQL_SELECT_TRASHENTRY_WHERE);
1389    
1390                    query.append(_FINDER_COLUMN_G_LTCD_GROUPID_2);
1391    
1392                    boolean bindCreateDate = false;
1393    
1394                    if (createDate == null) {
1395                            query.append(_FINDER_COLUMN_G_LTCD_CREATEDATE_1);
1396                    }
1397                    else {
1398                            bindCreateDate = true;
1399    
1400                            query.append(_FINDER_COLUMN_G_LTCD_CREATEDATE_2);
1401                    }
1402    
1403                    if (orderByComparator != null) {
1404                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1405    
1406                            if (orderByConditionFields.length > 0) {
1407                                    query.append(WHERE_AND);
1408                            }
1409    
1410                            for (int i = 0; i < orderByConditionFields.length; i++) {
1411                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1412                                    query.append(orderByConditionFields[i]);
1413    
1414                                    if ((i + 1) < orderByConditionFields.length) {
1415                                            if (orderByComparator.isAscending() ^ previous) {
1416                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1417                                            }
1418                                            else {
1419                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1420                                            }
1421                                    }
1422                                    else {
1423                                            if (orderByComparator.isAscending() ^ previous) {
1424                                                    query.append(WHERE_GREATER_THAN);
1425                                            }
1426                                            else {
1427                                                    query.append(WHERE_LESSER_THAN);
1428                                            }
1429                                    }
1430                            }
1431    
1432                            query.append(ORDER_BY_CLAUSE);
1433    
1434                            String[] orderByFields = orderByComparator.getOrderByFields();
1435    
1436                            for (int i = 0; i < orderByFields.length; i++) {
1437                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1438                                    query.append(orderByFields[i]);
1439    
1440                                    if ((i + 1) < orderByFields.length) {
1441                                            if (orderByComparator.isAscending() ^ previous) {
1442                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1443                                            }
1444                                            else {
1445                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1446                                            }
1447                                    }
1448                                    else {
1449                                            if (orderByComparator.isAscending() ^ previous) {
1450                                                    query.append(ORDER_BY_ASC);
1451                                            }
1452                                            else {
1453                                                    query.append(ORDER_BY_DESC);
1454                                            }
1455                                    }
1456                            }
1457                    }
1458                    else {
1459                            query.append(TrashEntryModelImpl.ORDER_BY_JPQL);
1460                    }
1461    
1462                    String sql = query.toString();
1463    
1464                    Query q = session.createQuery(sql);
1465    
1466                    q.setFirstResult(0);
1467                    q.setMaxResults(2);
1468    
1469                    QueryPos qPos = QueryPos.getInstance(q);
1470    
1471                    qPos.add(groupId);
1472    
1473                    if (bindCreateDate) {
1474                            qPos.add(new Timestamp(createDate.getTime()));
1475                    }
1476    
1477                    if (orderByComparator != null) {
1478                            Object[] values = orderByComparator.getOrderByConditionValues(trashEntry);
1479    
1480                            for (Object value : values) {
1481                                    qPos.add(value);
1482                            }
1483                    }
1484    
1485                    List<TrashEntry> list = q.list();
1486    
1487                    if (list.size() == 2) {
1488                            return list.get(1);
1489                    }
1490                    else {
1491                            return null;
1492                    }
1493            }
1494    
1495            /**
1496             * Removes all the trash entries where groupId = &#63; and createDate &lt; &#63; from the database.
1497             *
1498             * @param groupId the group ID
1499             * @param createDate the create date
1500             */
1501            @Override
1502            public void removeByG_LtCD(long groupId, Date createDate) {
1503                    for (TrashEntry trashEntry : findByG_LtCD(groupId, createDate,
1504                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1505                            remove(trashEntry);
1506                    }
1507            }
1508    
1509            /**
1510             * Returns the number of trash entries where groupId = &#63; and createDate &lt; &#63;.
1511             *
1512             * @param groupId the group ID
1513             * @param createDate the create date
1514             * @return the number of matching trash entries
1515             */
1516            @Override
1517            public int countByG_LtCD(long groupId, Date createDate) {
1518                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTCD;
1519    
1520                    Object[] finderArgs = new Object[] { groupId, createDate };
1521    
1522                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1523                                    this);
1524    
1525                    if (count == null) {
1526                            StringBundler query = new StringBundler(3);
1527    
1528                            query.append(_SQL_COUNT_TRASHENTRY_WHERE);
1529    
1530                            query.append(_FINDER_COLUMN_G_LTCD_GROUPID_2);
1531    
1532                            boolean bindCreateDate = false;
1533    
1534                            if (createDate == null) {
1535                                    query.append(_FINDER_COLUMN_G_LTCD_CREATEDATE_1);
1536                            }
1537                            else {
1538                                    bindCreateDate = true;
1539    
1540                                    query.append(_FINDER_COLUMN_G_LTCD_CREATEDATE_2);
1541                            }
1542    
1543                            String sql = query.toString();
1544    
1545                            Session session = null;
1546    
1547                            try {
1548                                    session = openSession();
1549    
1550                                    Query q = session.createQuery(sql);
1551    
1552                                    QueryPos qPos = QueryPos.getInstance(q);
1553    
1554                                    qPos.add(groupId);
1555    
1556                                    if (bindCreateDate) {
1557                                            qPos.add(new Timestamp(createDate.getTime()));
1558                                    }
1559    
1560                                    count = (Long)q.uniqueResult();
1561    
1562                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1563                            }
1564                            catch (Exception e) {
1565                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1566    
1567                                    throw processException(e);
1568                            }
1569                            finally {
1570                                    closeSession(session);
1571                            }
1572                    }
1573    
1574                    return count.intValue();
1575            }
1576    
1577            private static final String _FINDER_COLUMN_G_LTCD_GROUPID_2 = "trashEntry.groupId = ? AND ";
1578            private static final String _FINDER_COLUMN_G_LTCD_CREATEDATE_1 = "trashEntry.createDate < NULL";
1579            private static final String _FINDER_COLUMN_G_LTCD_CREATEDATE_2 = "trashEntry.createDate < ?";
1580            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
1581                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
1582                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C",
1583                            new String[] {
1584                                    Long.class.getName(), Long.class.getName(),
1585                                    
1586                            Integer.class.getName(), Integer.class.getName(),
1587                                    OrderByComparator.class.getName()
1588                            });
1589            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
1590                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
1591                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C",
1592                            new String[] { Long.class.getName(), Long.class.getName() },
1593                            TrashEntryModelImpl.GROUPID_COLUMN_BITMASK |
1594                            TrashEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
1595                            TrashEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1596            public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
1597                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1598                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
1599                            new String[] { Long.class.getName(), Long.class.getName() });
1600    
1601            /**
1602             * Returns all the trash entries where groupId = &#63; and classNameId = &#63;.
1603             *
1604             * @param groupId the group ID
1605             * @param classNameId the class name ID
1606             * @return the matching trash entries
1607             */
1608            @Override
1609            public List<TrashEntry> findByG_C(long groupId, long classNameId) {
1610                    return findByG_C(groupId, classNameId, QueryUtil.ALL_POS,
1611                            QueryUtil.ALL_POS, null);
1612            }
1613    
1614            /**
1615             * Returns a range of all the trash entries where groupId = &#63; and classNameId = &#63;.
1616             *
1617             * <p>
1618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
1619             * </p>
1620             *
1621             * @param groupId the group ID
1622             * @param classNameId the class name ID
1623             * @param start the lower bound of the range of trash entries
1624             * @param end the upper bound of the range of trash entries (not inclusive)
1625             * @return the range of matching trash entries
1626             */
1627            @Override
1628            public List<TrashEntry> findByG_C(long groupId, long classNameId,
1629                    int start, int end) {
1630                    return findByG_C(groupId, classNameId, start, end, null);
1631            }
1632    
1633            /**
1634             * Returns an ordered range of all the trash entries where groupId = &#63; and classNameId = &#63;.
1635             *
1636             * <p>
1637             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
1638             * </p>
1639             *
1640             * @param groupId the group ID
1641             * @param classNameId the class name ID
1642             * @param start the lower bound of the range of trash entries
1643             * @param end the upper bound of the range of trash entries (not inclusive)
1644             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1645             * @return the ordered range of matching trash entries
1646             */
1647            @Override
1648            public List<TrashEntry> findByG_C(long groupId, long classNameId,
1649                    int start, int end, OrderByComparator<TrashEntry> orderByComparator) {
1650                    boolean pagination = true;
1651                    FinderPath finderPath = null;
1652                    Object[] finderArgs = null;
1653    
1654                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1655                                    (orderByComparator == null)) {
1656                            pagination = false;
1657                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C;
1658                            finderArgs = new Object[] { groupId, classNameId };
1659                    }
1660                    else {
1661                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
1662                            finderArgs = new Object[] {
1663                                            groupId, classNameId,
1664                                            
1665                                            start, end, orderByComparator
1666                                    };
1667                    }
1668    
1669                    List<TrashEntry> list = (List<TrashEntry>)FinderCacheUtil.getResult(finderPath,
1670                                    finderArgs, this);
1671    
1672                    if ((list != null) && !list.isEmpty()) {
1673                            for (TrashEntry trashEntry : list) {
1674                                    if ((groupId != trashEntry.getGroupId()) ||
1675                                                    (classNameId != trashEntry.getClassNameId())) {
1676                                            list = null;
1677    
1678                                            break;
1679                                    }
1680                            }
1681                    }
1682    
1683                    if (list == null) {
1684                            StringBundler query = null;
1685    
1686                            if (orderByComparator != null) {
1687                                    query = new StringBundler(4 +
1688                                                    (orderByComparator.getOrderByFields().length * 3));
1689                            }
1690                            else {
1691                                    query = new StringBundler(4);
1692                            }
1693    
1694                            query.append(_SQL_SELECT_TRASHENTRY_WHERE);
1695    
1696                            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1697    
1698                            query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
1699    
1700                            if (orderByComparator != null) {
1701                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1702                                            orderByComparator);
1703                            }
1704                            else
1705                             if (pagination) {
1706                                    query.append(TrashEntryModelImpl.ORDER_BY_JPQL);
1707                            }
1708    
1709                            String sql = query.toString();
1710    
1711                            Session session = null;
1712    
1713                            try {
1714                                    session = openSession();
1715    
1716                                    Query q = session.createQuery(sql);
1717    
1718                                    QueryPos qPos = QueryPos.getInstance(q);
1719    
1720                                    qPos.add(groupId);
1721    
1722                                    qPos.add(classNameId);
1723    
1724                                    if (!pagination) {
1725                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
1726                                                            start, end, false);
1727    
1728                                            Collections.sort(list);
1729    
1730                                            list = Collections.unmodifiableList(list);
1731                                    }
1732                                    else {
1733                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
1734                                                            start, end);
1735                                    }
1736    
1737                                    cacheResult(list);
1738    
1739                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1740                            }
1741                            catch (Exception e) {
1742                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1743    
1744                                    throw processException(e);
1745                            }
1746                            finally {
1747                                    closeSession(session);
1748                            }
1749                    }
1750    
1751                    return list;
1752            }
1753    
1754            /**
1755             * Returns the first trash entry in the ordered set where groupId = &#63; and classNameId = &#63;.
1756             *
1757             * @param groupId the group ID
1758             * @param classNameId the class name ID
1759             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1760             * @return the first matching trash entry
1761             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
1762             */
1763            @Override
1764            public TrashEntry findByG_C_First(long groupId, long classNameId,
1765                    OrderByComparator<TrashEntry> orderByComparator)
1766                    throws NoSuchEntryException {
1767                    TrashEntry trashEntry = fetchByG_C_First(groupId, classNameId,
1768                                    orderByComparator);
1769    
1770                    if (trashEntry != null) {
1771                            return trashEntry;
1772                    }
1773    
1774                    StringBundler msg = new StringBundler(6);
1775    
1776                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1777    
1778                    msg.append("groupId=");
1779                    msg.append(groupId);
1780    
1781                    msg.append(", classNameId=");
1782                    msg.append(classNameId);
1783    
1784                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1785    
1786                    throw new NoSuchEntryException(msg.toString());
1787            }
1788    
1789            /**
1790             * Returns the first trash entry in the ordered set where groupId = &#63; and classNameId = &#63;.
1791             *
1792             * @param groupId the group ID
1793             * @param classNameId the class name ID
1794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1795             * @return the first matching trash entry, or <code>null</code> if a matching trash entry could not be found
1796             */
1797            @Override
1798            public TrashEntry fetchByG_C_First(long groupId, long classNameId,
1799                    OrderByComparator<TrashEntry> orderByComparator) {
1800                    List<TrashEntry> list = findByG_C(groupId, classNameId, 0, 1,
1801                                    orderByComparator);
1802    
1803                    if (!list.isEmpty()) {
1804                            return list.get(0);
1805                    }
1806    
1807                    return null;
1808            }
1809    
1810            /**
1811             * Returns the last trash entry in the ordered set where groupId = &#63; and classNameId = &#63;.
1812             *
1813             * @param groupId the group ID
1814             * @param classNameId the class name ID
1815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1816             * @return the last matching trash entry
1817             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
1818             */
1819            @Override
1820            public TrashEntry findByG_C_Last(long groupId, long classNameId,
1821                    OrderByComparator<TrashEntry> orderByComparator)
1822                    throws NoSuchEntryException {
1823                    TrashEntry trashEntry = fetchByG_C_Last(groupId, classNameId,
1824                                    orderByComparator);
1825    
1826                    if (trashEntry != null) {
1827                            return trashEntry;
1828                    }
1829    
1830                    StringBundler msg = new StringBundler(6);
1831    
1832                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1833    
1834                    msg.append("groupId=");
1835                    msg.append(groupId);
1836    
1837                    msg.append(", classNameId=");
1838                    msg.append(classNameId);
1839    
1840                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1841    
1842                    throw new NoSuchEntryException(msg.toString());
1843            }
1844    
1845            /**
1846             * Returns the last trash entry in the ordered set where groupId = &#63; and classNameId = &#63;.
1847             *
1848             * @param groupId the group ID
1849             * @param classNameId the class name ID
1850             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1851             * @return the last matching trash entry, or <code>null</code> if a matching trash entry could not be found
1852             */
1853            @Override
1854            public TrashEntry fetchByG_C_Last(long groupId, long classNameId,
1855                    OrderByComparator<TrashEntry> orderByComparator) {
1856                    int count = countByG_C(groupId, classNameId);
1857    
1858                    if (count == 0) {
1859                            return null;
1860                    }
1861    
1862                    List<TrashEntry> list = findByG_C(groupId, classNameId, count - 1,
1863                                    count, orderByComparator);
1864    
1865                    if (!list.isEmpty()) {
1866                            return list.get(0);
1867                    }
1868    
1869                    return null;
1870            }
1871    
1872            /**
1873             * Returns the trash entries before and after the current trash entry in the ordered set where groupId = &#63; and classNameId = &#63;.
1874             *
1875             * @param entryId the primary key of the current trash entry
1876             * @param groupId the group ID
1877             * @param classNameId the class name ID
1878             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1879             * @return the previous, current, and next trash entry
1880             * @throws com.liferay.portlet.trash.NoSuchEntryException if a trash entry with the primary key could not be found
1881             */
1882            @Override
1883            public TrashEntry[] findByG_C_PrevAndNext(long entryId, long groupId,
1884                    long classNameId, OrderByComparator<TrashEntry> orderByComparator)
1885                    throws NoSuchEntryException {
1886                    TrashEntry trashEntry = findByPrimaryKey(entryId);
1887    
1888                    Session session = null;
1889    
1890                    try {
1891                            session = openSession();
1892    
1893                            TrashEntry[] array = new TrashEntryImpl[3];
1894    
1895                            array[0] = getByG_C_PrevAndNext(session, trashEntry, groupId,
1896                                            classNameId, orderByComparator, true);
1897    
1898                            array[1] = trashEntry;
1899    
1900                            array[2] = getByG_C_PrevAndNext(session, trashEntry, groupId,
1901                                            classNameId, orderByComparator, false);
1902    
1903                            return array;
1904                    }
1905                    catch (Exception e) {
1906                            throw processException(e);
1907                    }
1908                    finally {
1909                            closeSession(session);
1910                    }
1911            }
1912    
1913            protected TrashEntry getByG_C_PrevAndNext(Session session,
1914                    TrashEntry trashEntry, long groupId, long classNameId,
1915                    OrderByComparator<TrashEntry> orderByComparator, boolean previous) {
1916                    StringBundler query = null;
1917    
1918                    if (orderByComparator != null) {
1919                            query = new StringBundler(6 +
1920                                            (orderByComparator.getOrderByFields().length * 6));
1921                    }
1922                    else {
1923                            query = new StringBundler(3);
1924                    }
1925    
1926                    query.append(_SQL_SELECT_TRASHENTRY_WHERE);
1927    
1928                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1929    
1930                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
1931    
1932                    if (orderByComparator != null) {
1933                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1934    
1935                            if (orderByConditionFields.length > 0) {
1936                                    query.append(WHERE_AND);
1937                            }
1938    
1939                            for (int i = 0; i < orderByConditionFields.length; i++) {
1940                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1941                                    query.append(orderByConditionFields[i]);
1942    
1943                                    if ((i + 1) < orderByConditionFields.length) {
1944                                            if (orderByComparator.isAscending() ^ previous) {
1945                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1946                                            }
1947                                            else {
1948                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1949                                            }
1950                                    }
1951                                    else {
1952                                            if (orderByComparator.isAscending() ^ previous) {
1953                                                    query.append(WHERE_GREATER_THAN);
1954                                            }
1955                                            else {
1956                                                    query.append(WHERE_LESSER_THAN);
1957                                            }
1958                                    }
1959                            }
1960    
1961                            query.append(ORDER_BY_CLAUSE);
1962    
1963                            String[] orderByFields = orderByComparator.getOrderByFields();
1964    
1965                            for (int i = 0; i < orderByFields.length; i++) {
1966                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1967                                    query.append(orderByFields[i]);
1968    
1969                                    if ((i + 1) < orderByFields.length) {
1970                                            if (orderByComparator.isAscending() ^ previous) {
1971                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1972                                            }
1973                                            else {
1974                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1975                                            }
1976                                    }
1977                                    else {
1978                                            if (orderByComparator.isAscending() ^ previous) {
1979                                                    query.append(ORDER_BY_ASC);
1980                                            }
1981                                            else {
1982                                                    query.append(ORDER_BY_DESC);
1983                                            }
1984                                    }
1985                            }
1986                    }
1987                    else {
1988                            query.append(TrashEntryModelImpl.ORDER_BY_JPQL);
1989                    }
1990    
1991                    String sql = query.toString();
1992    
1993                    Query q = session.createQuery(sql);
1994    
1995                    q.setFirstResult(0);
1996                    q.setMaxResults(2);
1997    
1998                    QueryPos qPos = QueryPos.getInstance(q);
1999    
2000                    qPos.add(groupId);
2001    
2002                    qPos.add(classNameId);
2003    
2004                    if (orderByComparator != null) {
2005                            Object[] values = orderByComparator.getOrderByConditionValues(trashEntry);
2006    
2007                            for (Object value : values) {
2008                                    qPos.add(value);
2009                            }
2010                    }
2011    
2012                    List<TrashEntry> list = q.list();
2013    
2014                    if (list.size() == 2) {
2015                            return list.get(1);
2016                    }
2017                    else {
2018                            return null;
2019                    }
2020            }
2021    
2022            /**
2023             * Removes all the trash entries where groupId = &#63; and classNameId = &#63; from the database.
2024             *
2025             * @param groupId the group ID
2026             * @param classNameId the class name ID
2027             */
2028            @Override
2029            public void removeByG_C(long groupId, long classNameId) {
2030                    for (TrashEntry trashEntry : findByG_C(groupId, classNameId,
2031                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2032                            remove(trashEntry);
2033                    }
2034            }
2035    
2036            /**
2037             * Returns the number of trash entries where groupId = &#63; and classNameId = &#63;.
2038             *
2039             * @param groupId the group ID
2040             * @param classNameId the class name ID
2041             * @return the number of matching trash entries
2042             */
2043            @Override
2044            public int countByG_C(long groupId, long classNameId) {
2045                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_C;
2046    
2047                    Object[] finderArgs = new Object[] { groupId, classNameId };
2048    
2049                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2050                                    this);
2051    
2052                    if (count == null) {
2053                            StringBundler query = new StringBundler(3);
2054    
2055                            query.append(_SQL_COUNT_TRASHENTRY_WHERE);
2056    
2057                            query.append(_FINDER_COLUMN_G_C_GROUPID_2);
2058    
2059                            query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
2060    
2061                            String sql = query.toString();
2062    
2063                            Session session = null;
2064    
2065                            try {
2066                                    session = openSession();
2067    
2068                                    Query q = session.createQuery(sql);
2069    
2070                                    QueryPos qPos = QueryPos.getInstance(q);
2071    
2072                                    qPos.add(groupId);
2073    
2074                                    qPos.add(classNameId);
2075    
2076                                    count = (Long)q.uniqueResult();
2077    
2078                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2079                            }
2080                            catch (Exception e) {
2081                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2082    
2083                                    throw processException(e);
2084                            }
2085                            finally {
2086                                    closeSession(session);
2087                            }
2088                    }
2089    
2090                    return count.intValue();
2091            }
2092    
2093            private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "trashEntry.groupId = ? AND ";
2094            private static final String _FINDER_COLUMN_G_C_CLASSNAMEID_2 = "trashEntry.classNameId = ?";
2095            public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2096                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, TrashEntryImpl.class,
2097                            FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
2098                            new String[] { Long.class.getName(), Long.class.getName() },
2099                            TrashEntryModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2100                            TrashEntryModelImpl.CLASSPK_COLUMN_BITMASK);
2101            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2102                            TrashEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
2104                            new String[] { Long.class.getName(), Long.class.getName() });
2105    
2106            /**
2107             * Returns the trash entry where classNameId = &#63; and classPK = &#63; or throws a {@link com.liferay.portlet.trash.NoSuchEntryException} if it could not be found.
2108             *
2109             * @param classNameId the class name ID
2110             * @param classPK the class p k
2111             * @return the matching trash entry
2112             * @throws com.liferay.portlet.trash.NoSuchEntryException if a matching trash entry could not be found
2113             */
2114            @Override
2115            public TrashEntry findByC_C(long classNameId, long classPK)
2116                    throws NoSuchEntryException {
2117                    TrashEntry trashEntry = fetchByC_C(classNameId, classPK);
2118    
2119                    if (trashEntry == null) {
2120                            StringBundler msg = new StringBundler(6);
2121    
2122                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2123    
2124                            msg.append("classNameId=");
2125                            msg.append(classNameId);
2126    
2127                            msg.append(", classPK=");
2128                            msg.append(classPK);
2129    
2130                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2131    
2132                            if (_log.isWarnEnabled()) {
2133                                    _log.warn(msg.toString());
2134                            }
2135    
2136                            throw new NoSuchEntryException(msg.toString());
2137                    }
2138    
2139                    return trashEntry;
2140            }
2141    
2142            /**
2143             * Returns the trash entry where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2144             *
2145             * @param classNameId the class name ID
2146             * @param classPK the class p k
2147             * @return the matching trash entry, or <code>null</code> if a matching trash entry could not be found
2148             */
2149            @Override
2150            public TrashEntry fetchByC_C(long classNameId, long classPK) {
2151                    return fetchByC_C(classNameId, classPK, true);
2152            }
2153    
2154            /**
2155             * Returns the trash entry where classNameId = &#63; and classPK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2156             *
2157             * @param classNameId the class name ID
2158             * @param classPK the class p k
2159             * @param retrieveFromCache whether to use the finder cache
2160             * @return the matching trash entry, or <code>null</code> if a matching trash entry could not be found
2161             */
2162            @Override
2163            public TrashEntry fetchByC_C(long classNameId, long classPK,
2164                    boolean retrieveFromCache) {
2165                    Object[] finderArgs = new Object[] { classNameId, classPK };
2166    
2167                    Object result = null;
2168    
2169                    if (retrieveFromCache) {
2170                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
2171                                            finderArgs, this);
2172                    }
2173    
2174                    if (result instanceof TrashEntry) {
2175                            TrashEntry trashEntry = (TrashEntry)result;
2176    
2177                            if ((classNameId != trashEntry.getClassNameId()) ||
2178                                            (classPK != trashEntry.getClassPK())) {
2179                                    result = null;
2180                            }
2181                    }
2182    
2183                    if (result == null) {
2184                            StringBundler query = new StringBundler(4);
2185    
2186                            query.append(_SQL_SELECT_TRASHENTRY_WHERE);
2187    
2188                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2189    
2190                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2191    
2192                            String sql = query.toString();
2193    
2194                            Session session = null;
2195    
2196                            try {
2197                                    session = openSession();
2198    
2199                                    Query q = session.createQuery(sql);
2200    
2201                                    QueryPos qPos = QueryPos.getInstance(q);
2202    
2203                                    qPos.add(classNameId);
2204    
2205                                    qPos.add(classPK);
2206    
2207                                    List<TrashEntry> list = q.list();
2208    
2209                                    if (list.isEmpty()) {
2210                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2211                                                    finderArgs, list);
2212                                    }
2213                                    else {
2214                                            TrashEntry trashEntry = list.get(0);
2215    
2216                                            result = trashEntry;
2217    
2218                                            cacheResult(trashEntry);
2219    
2220                                            if ((trashEntry.getClassNameId() != classNameId) ||
2221                                                            (trashEntry.getClassPK() != classPK)) {
2222                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2223                                                            finderArgs, trashEntry);
2224                                            }
2225                                    }
2226                            }
2227                            catch (Exception e) {
2228                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
2229                                            finderArgs);
2230    
2231                                    throw processException(e);
2232                            }
2233                            finally {
2234                                    closeSession(session);
2235                            }
2236                    }
2237    
2238                    if (result instanceof List<?>) {
2239                            return null;
2240                    }
2241                    else {
2242                            return (TrashEntry)result;
2243                    }
2244            }
2245    
2246            /**
2247             * Removes the trash entry where classNameId = &#63; and classPK = &#63; from the database.
2248             *
2249             * @param classNameId the class name ID
2250             * @param classPK the class p k
2251             * @return the trash entry that was removed
2252             */
2253            @Override
2254            public TrashEntry removeByC_C(long classNameId, long classPK)
2255                    throws NoSuchEntryException {
2256                    TrashEntry trashEntry = findByC_C(classNameId, classPK);
2257    
2258                    return remove(trashEntry);
2259            }
2260    
2261            /**
2262             * Returns the number of trash entries where classNameId = &#63; and classPK = &#63;.
2263             *
2264             * @param classNameId the class name ID
2265             * @param classPK the class p k
2266             * @return the number of matching trash entries
2267             */
2268            @Override
2269            public int countByC_C(long classNameId, long classPK) {
2270                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C;
2271    
2272                    Object[] finderArgs = new Object[] { classNameId, classPK };
2273    
2274                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2275                                    this);
2276    
2277                    if (count == null) {
2278                            StringBundler query = new StringBundler(3);
2279    
2280                            query.append(_SQL_COUNT_TRASHENTRY_WHERE);
2281    
2282                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2283    
2284                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2285    
2286                            String sql = query.toString();
2287    
2288                            Session session = null;
2289    
2290                            try {
2291                                    session = openSession();
2292    
2293                                    Query q = session.createQuery(sql);
2294    
2295                                    QueryPos qPos = QueryPos.getInstance(q);
2296    
2297                                    qPos.add(classNameId);
2298    
2299                                    qPos.add(classPK);
2300    
2301                                    count = (Long)q.uniqueResult();
2302    
2303                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2304                            }
2305                            catch (Exception e) {
2306                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2307    
2308                                    throw processException(e);
2309                            }
2310                            finally {
2311                                    closeSession(session);
2312                            }
2313                    }
2314    
2315                    return count.intValue();
2316            }
2317    
2318            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "trashEntry.classNameId = ? AND ";
2319            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "trashEntry.classPK = ?";
2320    
2321            public TrashEntryPersistenceImpl() {
2322                    setModelClass(TrashEntry.class);
2323            }
2324    
2325            /**
2326             * Caches the trash entry in the entity cache if it is enabled.
2327             *
2328             * @param trashEntry the trash entry
2329             */
2330            @Override
2331            public void cacheResult(TrashEntry trashEntry) {
2332                    EntityCacheUtil.putResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2333                            TrashEntryImpl.class, trashEntry.getPrimaryKey(), trashEntry);
2334    
2335                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
2336                            new Object[] { trashEntry.getClassNameId(), trashEntry.getClassPK() },
2337                            trashEntry);
2338    
2339                    trashEntry.resetOriginalValues();
2340            }
2341    
2342            /**
2343             * Caches the trash entries in the entity cache if it is enabled.
2344             *
2345             * @param trashEntries the trash entries
2346             */
2347            @Override
2348            public void cacheResult(List<TrashEntry> trashEntries) {
2349                    for (TrashEntry trashEntry : trashEntries) {
2350                            if (EntityCacheUtil.getResult(
2351                                                    TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2352                                                    TrashEntryImpl.class, trashEntry.getPrimaryKey()) == null) {
2353                                    cacheResult(trashEntry);
2354                            }
2355                            else {
2356                                    trashEntry.resetOriginalValues();
2357                            }
2358                    }
2359            }
2360    
2361            /**
2362             * Clears the cache for all trash entries.
2363             *
2364             * <p>
2365             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2366             * </p>
2367             */
2368            @Override
2369            public void clearCache() {
2370                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2371                            CacheRegistryUtil.clear(TrashEntryImpl.class.getName());
2372                    }
2373    
2374                    EntityCacheUtil.clearCache(TrashEntryImpl.class);
2375    
2376                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2377                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2378                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2379            }
2380    
2381            /**
2382             * Clears the cache for the trash entry.
2383             *
2384             * <p>
2385             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2386             * </p>
2387             */
2388            @Override
2389            public void clearCache(TrashEntry trashEntry) {
2390                    EntityCacheUtil.removeResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2391                            TrashEntryImpl.class, trashEntry.getPrimaryKey());
2392    
2393                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2394                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2395    
2396                    clearUniqueFindersCache(trashEntry);
2397            }
2398    
2399            @Override
2400            public void clearCache(List<TrashEntry> trashEntries) {
2401                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2402                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2403    
2404                    for (TrashEntry trashEntry : trashEntries) {
2405                            EntityCacheUtil.removeResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2406                                    TrashEntryImpl.class, trashEntry.getPrimaryKey());
2407    
2408                            clearUniqueFindersCache(trashEntry);
2409                    }
2410            }
2411    
2412            protected void cacheUniqueFindersCache(TrashEntry trashEntry) {
2413                    if (trashEntry.isNew()) {
2414                            Object[] args = new Object[] {
2415                                            trashEntry.getClassNameId(), trashEntry.getClassPK()
2416                                    };
2417    
2418                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
2419                                    Long.valueOf(1));
2420                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args, trashEntry);
2421                    }
2422                    else {
2423                            TrashEntryModelImpl trashEntryModelImpl = (TrashEntryModelImpl)trashEntry;
2424    
2425                            if ((trashEntryModelImpl.getColumnBitmask() &
2426                                            FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
2427                                    Object[] args = new Object[] {
2428                                                    trashEntry.getClassNameId(), trashEntry.getClassPK()
2429                                            };
2430    
2431                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, args,
2432                                            Long.valueOf(1));
2433                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C, args,
2434                                            trashEntry);
2435                            }
2436                    }
2437            }
2438    
2439            protected void clearUniqueFindersCache(TrashEntry trashEntry) {
2440                    TrashEntryModelImpl trashEntryModelImpl = (TrashEntryModelImpl)trashEntry;
2441    
2442                    Object[] args = new Object[] {
2443                                    trashEntry.getClassNameId(), trashEntry.getClassPK()
2444                            };
2445    
2446                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
2447                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
2448    
2449                    if ((trashEntryModelImpl.getColumnBitmask() &
2450                                    FINDER_PATH_FETCH_BY_C_C.getColumnBitmask()) != 0) {
2451                            args = new Object[] {
2452                                            trashEntryModelImpl.getOriginalClassNameId(),
2453                                            trashEntryModelImpl.getOriginalClassPK()
2454                                    };
2455    
2456                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
2457                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C, args);
2458                    }
2459            }
2460    
2461            /**
2462             * Creates a new trash entry with the primary key. Does not add the trash entry to the database.
2463             *
2464             * @param entryId the primary key for the new trash entry
2465             * @return the new trash entry
2466             */
2467            @Override
2468            public TrashEntry create(long entryId) {
2469                    TrashEntry trashEntry = new TrashEntryImpl();
2470    
2471                    trashEntry.setNew(true);
2472                    trashEntry.setPrimaryKey(entryId);
2473    
2474                    return trashEntry;
2475            }
2476    
2477            /**
2478             * Removes the trash entry with the primary key from the database. Also notifies the appropriate model listeners.
2479             *
2480             * @param entryId the primary key of the trash entry
2481             * @return the trash entry that was removed
2482             * @throws com.liferay.portlet.trash.NoSuchEntryException if a trash entry with the primary key could not be found
2483             */
2484            @Override
2485            public TrashEntry remove(long entryId) throws NoSuchEntryException {
2486                    return remove((Serializable)entryId);
2487            }
2488    
2489            /**
2490             * Removes the trash entry with the primary key from the database. Also notifies the appropriate model listeners.
2491             *
2492             * @param primaryKey the primary key of the trash entry
2493             * @return the trash entry that was removed
2494             * @throws com.liferay.portlet.trash.NoSuchEntryException if a trash entry with the primary key could not be found
2495             */
2496            @Override
2497            public TrashEntry remove(Serializable primaryKey)
2498                    throws NoSuchEntryException {
2499                    Session session = null;
2500    
2501                    try {
2502                            session = openSession();
2503    
2504                            TrashEntry trashEntry = (TrashEntry)session.get(TrashEntryImpl.class,
2505                                            primaryKey);
2506    
2507                            if (trashEntry == null) {
2508                                    if (_log.isWarnEnabled()) {
2509                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2510                                    }
2511    
2512                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2513                                            primaryKey);
2514                            }
2515    
2516                            return remove(trashEntry);
2517                    }
2518                    catch (NoSuchEntryException nsee) {
2519                            throw nsee;
2520                    }
2521                    catch (Exception e) {
2522                            throw processException(e);
2523                    }
2524                    finally {
2525                            closeSession(session);
2526                    }
2527            }
2528    
2529            @Override
2530            protected TrashEntry removeImpl(TrashEntry trashEntry) {
2531                    trashEntry = toUnwrappedModel(trashEntry);
2532    
2533                    Session session = null;
2534    
2535                    try {
2536                            session = openSession();
2537    
2538                            if (!session.contains(trashEntry)) {
2539                                    trashEntry = (TrashEntry)session.get(TrashEntryImpl.class,
2540                                                    trashEntry.getPrimaryKeyObj());
2541                            }
2542    
2543                            if (trashEntry != null) {
2544                                    session.delete(trashEntry);
2545                            }
2546                    }
2547                    catch (Exception e) {
2548                            throw processException(e);
2549                    }
2550                    finally {
2551                            closeSession(session);
2552                    }
2553    
2554                    if (trashEntry != null) {
2555                            clearCache(trashEntry);
2556                    }
2557    
2558                    return trashEntry;
2559            }
2560    
2561            @Override
2562            public TrashEntry updateImpl(
2563                    com.liferay.portlet.trash.model.TrashEntry trashEntry) {
2564                    trashEntry = toUnwrappedModel(trashEntry);
2565    
2566                    boolean isNew = trashEntry.isNew();
2567    
2568                    TrashEntryModelImpl trashEntryModelImpl = (TrashEntryModelImpl)trashEntry;
2569    
2570                    Session session = null;
2571    
2572                    try {
2573                            session = openSession();
2574    
2575                            if (trashEntry.isNew()) {
2576                                    session.save(trashEntry);
2577    
2578                                    trashEntry.setNew(false);
2579                            }
2580                            else {
2581                                    session.merge(trashEntry);
2582                            }
2583                    }
2584                    catch (Exception e) {
2585                            throw processException(e);
2586                    }
2587                    finally {
2588                            closeSession(session);
2589                    }
2590    
2591                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2592    
2593                    if (isNew || !TrashEntryModelImpl.COLUMN_BITMASK_ENABLED) {
2594                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2595                    }
2596    
2597                    else {
2598                            if ((trashEntryModelImpl.getColumnBitmask() &
2599                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2600                                    Object[] args = new Object[] {
2601                                                    trashEntryModelImpl.getOriginalGroupId()
2602                                            };
2603    
2604                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2605                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2606                                            args);
2607    
2608                                    args = new Object[] { trashEntryModelImpl.getGroupId() };
2609    
2610                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2611                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2612                                            args);
2613                            }
2614    
2615                            if ((trashEntryModelImpl.getColumnBitmask() &
2616                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
2617                                    Object[] args = new Object[] {
2618                                                    trashEntryModelImpl.getOriginalCompanyId()
2619                                            };
2620    
2621                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2622                                            args);
2623                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2624                                            args);
2625    
2626                                    args = new Object[] { trashEntryModelImpl.getCompanyId() };
2627    
2628                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2629                                            args);
2630                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2631                                            args);
2632                            }
2633    
2634                            if ((trashEntryModelImpl.getColumnBitmask() &
2635                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) {
2636                                    Object[] args = new Object[] {
2637                                                    trashEntryModelImpl.getOriginalGroupId(),
2638                                                    trashEntryModelImpl.getOriginalClassNameId()
2639                                            };
2640    
2641                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
2642                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
2643                                            args);
2644    
2645                                    args = new Object[] {
2646                                                    trashEntryModelImpl.getGroupId(),
2647                                                    trashEntryModelImpl.getClassNameId()
2648                                            };
2649    
2650                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
2651                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
2652                                            args);
2653                            }
2654                    }
2655    
2656                    EntityCacheUtil.putResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2657                            TrashEntryImpl.class, trashEntry.getPrimaryKey(), trashEntry, false);
2658    
2659                    clearUniqueFindersCache(trashEntry);
2660                    cacheUniqueFindersCache(trashEntry);
2661    
2662                    trashEntry.resetOriginalValues();
2663    
2664                    return trashEntry;
2665            }
2666    
2667            protected TrashEntry toUnwrappedModel(TrashEntry trashEntry) {
2668                    if (trashEntry instanceof TrashEntryImpl) {
2669                            return trashEntry;
2670                    }
2671    
2672                    TrashEntryImpl trashEntryImpl = new TrashEntryImpl();
2673    
2674                    trashEntryImpl.setNew(trashEntry.isNew());
2675                    trashEntryImpl.setPrimaryKey(trashEntry.getPrimaryKey());
2676    
2677                    trashEntryImpl.setEntryId(trashEntry.getEntryId());
2678                    trashEntryImpl.setGroupId(trashEntry.getGroupId());
2679                    trashEntryImpl.setCompanyId(trashEntry.getCompanyId());
2680                    trashEntryImpl.setUserId(trashEntry.getUserId());
2681                    trashEntryImpl.setUserName(trashEntry.getUserName());
2682                    trashEntryImpl.setCreateDate(trashEntry.getCreateDate());
2683                    trashEntryImpl.setClassNameId(trashEntry.getClassNameId());
2684                    trashEntryImpl.setClassPK(trashEntry.getClassPK());
2685                    trashEntryImpl.setSystemEventSetKey(trashEntry.getSystemEventSetKey());
2686                    trashEntryImpl.setTypeSettings(trashEntry.getTypeSettings());
2687                    trashEntryImpl.setStatus(trashEntry.getStatus());
2688    
2689                    return trashEntryImpl;
2690            }
2691    
2692            /**
2693             * Returns the trash entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2694             *
2695             * @param primaryKey the primary key of the trash entry
2696             * @return the trash entry
2697             * @throws com.liferay.portlet.trash.NoSuchEntryException if a trash entry with the primary key could not be found
2698             */
2699            @Override
2700            public TrashEntry findByPrimaryKey(Serializable primaryKey)
2701                    throws NoSuchEntryException {
2702                    TrashEntry trashEntry = fetchByPrimaryKey(primaryKey);
2703    
2704                    if (trashEntry == null) {
2705                            if (_log.isWarnEnabled()) {
2706                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2707                            }
2708    
2709                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2710                                    primaryKey);
2711                    }
2712    
2713                    return trashEntry;
2714            }
2715    
2716            /**
2717             * Returns the trash entry with the primary key or throws a {@link com.liferay.portlet.trash.NoSuchEntryException} if it could not be found.
2718             *
2719             * @param entryId the primary key of the trash entry
2720             * @return the trash entry
2721             * @throws com.liferay.portlet.trash.NoSuchEntryException if a trash entry with the primary key could not be found
2722             */
2723            @Override
2724            public TrashEntry findByPrimaryKey(long entryId)
2725                    throws NoSuchEntryException {
2726                    return findByPrimaryKey((Serializable)entryId);
2727            }
2728    
2729            /**
2730             * Returns the trash entry with the primary key or returns <code>null</code> if it could not be found.
2731             *
2732             * @param primaryKey the primary key of the trash entry
2733             * @return the trash entry, or <code>null</code> if a trash entry with the primary key could not be found
2734             */
2735            @Override
2736            public TrashEntry fetchByPrimaryKey(Serializable primaryKey) {
2737                    TrashEntry trashEntry = (TrashEntry)EntityCacheUtil.getResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2738                                    TrashEntryImpl.class, primaryKey);
2739    
2740                    if (trashEntry == _nullTrashEntry) {
2741                            return null;
2742                    }
2743    
2744                    if (trashEntry == null) {
2745                            Session session = null;
2746    
2747                            try {
2748                                    session = openSession();
2749    
2750                                    trashEntry = (TrashEntry)session.get(TrashEntryImpl.class,
2751                                                    primaryKey);
2752    
2753                                    if (trashEntry != null) {
2754                                            cacheResult(trashEntry);
2755                                    }
2756                                    else {
2757                                            EntityCacheUtil.putResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2758                                                    TrashEntryImpl.class, primaryKey, _nullTrashEntry);
2759                                    }
2760                            }
2761                            catch (Exception e) {
2762                                    EntityCacheUtil.removeResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2763                                            TrashEntryImpl.class, primaryKey);
2764    
2765                                    throw processException(e);
2766                            }
2767                            finally {
2768                                    closeSession(session);
2769                            }
2770                    }
2771    
2772                    return trashEntry;
2773            }
2774    
2775            /**
2776             * Returns the trash entry with the primary key or returns <code>null</code> if it could not be found.
2777             *
2778             * @param entryId the primary key of the trash entry
2779             * @return the trash entry, or <code>null</code> if a trash entry with the primary key could not be found
2780             */
2781            @Override
2782            public TrashEntry fetchByPrimaryKey(long entryId) {
2783                    return fetchByPrimaryKey((Serializable)entryId);
2784            }
2785    
2786            @Override
2787            public Map<Serializable, TrashEntry> fetchByPrimaryKeys(
2788                    Set<Serializable> primaryKeys) {
2789                    if (primaryKeys.isEmpty()) {
2790                            return Collections.emptyMap();
2791                    }
2792    
2793                    Map<Serializable, TrashEntry> map = new HashMap<Serializable, TrashEntry>();
2794    
2795                    if (primaryKeys.size() == 1) {
2796                            Iterator<Serializable> iterator = primaryKeys.iterator();
2797    
2798                            Serializable primaryKey = iterator.next();
2799    
2800                            TrashEntry trashEntry = fetchByPrimaryKey(primaryKey);
2801    
2802                            if (trashEntry != null) {
2803                                    map.put(primaryKey, trashEntry);
2804                            }
2805    
2806                            return map;
2807                    }
2808    
2809                    Set<Serializable> uncachedPrimaryKeys = null;
2810    
2811                    for (Serializable primaryKey : primaryKeys) {
2812                            TrashEntry trashEntry = (TrashEntry)EntityCacheUtil.getResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2813                                            TrashEntryImpl.class, primaryKey);
2814    
2815                            if (trashEntry == null) {
2816                                    if (uncachedPrimaryKeys == null) {
2817                                            uncachedPrimaryKeys = new HashSet<Serializable>();
2818                                    }
2819    
2820                                    uncachedPrimaryKeys.add(primaryKey);
2821                            }
2822                            else {
2823                                    map.put(primaryKey, trashEntry);
2824                            }
2825                    }
2826    
2827                    if (uncachedPrimaryKeys == null) {
2828                            return map;
2829                    }
2830    
2831                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2832                                    1);
2833    
2834                    query.append(_SQL_SELECT_TRASHENTRY_WHERE_PKS_IN);
2835    
2836                    for (Serializable primaryKey : uncachedPrimaryKeys) {
2837                            query.append(String.valueOf(primaryKey));
2838    
2839                            query.append(StringPool.COMMA);
2840                    }
2841    
2842                    query.setIndex(query.index() - 1);
2843    
2844                    query.append(StringPool.CLOSE_PARENTHESIS);
2845    
2846                    String sql = query.toString();
2847    
2848                    Session session = null;
2849    
2850                    try {
2851                            session = openSession();
2852    
2853                            Query q = session.createQuery(sql);
2854    
2855                            for (TrashEntry trashEntry : (List<TrashEntry>)q.list()) {
2856                                    map.put(trashEntry.getPrimaryKeyObj(), trashEntry);
2857    
2858                                    cacheResult(trashEntry);
2859    
2860                                    uncachedPrimaryKeys.remove(trashEntry.getPrimaryKeyObj());
2861                            }
2862    
2863                            for (Serializable primaryKey : uncachedPrimaryKeys) {
2864                                    EntityCacheUtil.putResult(TrashEntryModelImpl.ENTITY_CACHE_ENABLED,
2865                                            TrashEntryImpl.class, primaryKey, _nullTrashEntry);
2866                            }
2867                    }
2868                    catch (Exception e) {
2869                            throw processException(e);
2870                    }
2871                    finally {
2872                            closeSession(session);
2873                    }
2874    
2875                    return map;
2876            }
2877    
2878            /**
2879             * Returns all the trash entries.
2880             *
2881             * @return the trash entries
2882             */
2883            @Override
2884            public List<TrashEntry> findAll() {
2885                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2886            }
2887    
2888            /**
2889             * Returns a range of all the trash entries.
2890             *
2891             * <p>
2892             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
2893             * </p>
2894             *
2895             * @param start the lower bound of the range of trash entries
2896             * @param end the upper bound of the range of trash entries (not inclusive)
2897             * @return the range of trash entries
2898             */
2899            @Override
2900            public List<TrashEntry> findAll(int start, int end) {
2901                    return findAll(start, end, null);
2902            }
2903    
2904            /**
2905             * Returns an ordered range of all the trash entries.
2906             *
2907             * <p>
2908             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.trash.model.impl.TrashEntryModelImpl}. 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.
2909             * </p>
2910             *
2911             * @param start the lower bound of the range of trash entries
2912             * @param end the upper bound of the range of trash entries (not inclusive)
2913             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2914             * @return the ordered range of trash entries
2915             */
2916            @Override
2917            public List<TrashEntry> findAll(int start, int end,
2918                    OrderByComparator<TrashEntry> orderByComparator) {
2919                    boolean pagination = true;
2920                    FinderPath finderPath = null;
2921                    Object[] finderArgs = null;
2922    
2923                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2924                                    (orderByComparator == null)) {
2925                            pagination = false;
2926                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2927                            finderArgs = FINDER_ARGS_EMPTY;
2928                    }
2929                    else {
2930                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2931                            finderArgs = new Object[] { start, end, orderByComparator };
2932                    }
2933    
2934                    List<TrashEntry> list = (List<TrashEntry>)FinderCacheUtil.getResult(finderPath,
2935                                    finderArgs, this);
2936    
2937                    if (list == null) {
2938                            StringBundler query = null;
2939                            String sql = null;
2940    
2941                            if (orderByComparator != null) {
2942                                    query = new StringBundler(2 +
2943                                                    (orderByComparator.getOrderByFields().length * 3));
2944    
2945                                    query.append(_SQL_SELECT_TRASHENTRY);
2946    
2947                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2948                                            orderByComparator);
2949    
2950                                    sql = query.toString();
2951                            }
2952                            else {
2953                                    sql = _SQL_SELECT_TRASHENTRY;
2954    
2955                                    if (pagination) {
2956                                            sql = sql.concat(TrashEntryModelImpl.ORDER_BY_JPQL);
2957                                    }
2958                            }
2959    
2960                            Session session = null;
2961    
2962                            try {
2963                                    session = openSession();
2964    
2965                                    Query q = session.createQuery(sql);
2966    
2967                                    if (!pagination) {
2968                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
2969                                                            start, end, false);
2970    
2971                                            Collections.sort(list);
2972    
2973                                            list = Collections.unmodifiableList(list);
2974                                    }
2975                                    else {
2976                                            list = (List<TrashEntry>)QueryUtil.list(q, getDialect(),
2977                                                            start, end);
2978                                    }
2979    
2980                                    cacheResult(list);
2981    
2982                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2983                            }
2984                            catch (Exception e) {
2985                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2986    
2987                                    throw processException(e);
2988                            }
2989                            finally {
2990                                    closeSession(session);
2991                            }
2992                    }
2993    
2994                    return list;
2995            }
2996    
2997            /**
2998             * Removes all the trash entries from the database.
2999             *
3000             */
3001            @Override
3002            public void removeAll() {
3003                    for (TrashEntry trashEntry : findAll()) {
3004                            remove(trashEntry);
3005                    }
3006            }
3007    
3008            /**
3009             * Returns the number of trash entries.
3010             *
3011             * @return the number of trash entries
3012             */
3013            @Override
3014            public int countAll() {
3015                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3016                                    FINDER_ARGS_EMPTY, this);
3017    
3018                    if (count == null) {
3019                            Session session = null;
3020    
3021                            try {
3022                                    session = openSession();
3023    
3024                                    Query q = session.createQuery(_SQL_COUNT_TRASHENTRY);
3025    
3026                                    count = (Long)q.uniqueResult();
3027    
3028                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3029                                            FINDER_ARGS_EMPTY, count);
3030                            }
3031                            catch (Exception e) {
3032                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3033                                            FINDER_ARGS_EMPTY);
3034    
3035                                    throw processException(e);
3036                            }
3037                            finally {
3038                                    closeSession(session);
3039                            }
3040                    }
3041    
3042                    return count.intValue();
3043            }
3044    
3045            /**
3046             * Initializes the trash entry persistence.
3047             */
3048            public void afterPropertiesSet() {
3049            }
3050    
3051            public void destroy() {
3052                    EntityCacheUtil.removeCache(TrashEntryImpl.class.getName());
3053                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3054                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3055                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3056            }
3057    
3058            private static final String _SQL_SELECT_TRASHENTRY = "SELECT trashEntry FROM TrashEntry trashEntry";
3059            private static final String _SQL_SELECT_TRASHENTRY_WHERE_PKS_IN = "SELECT trashEntry FROM TrashEntry trashEntry WHERE entryId IN (";
3060            private static final String _SQL_SELECT_TRASHENTRY_WHERE = "SELECT trashEntry FROM TrashEntry trashEntry WHERE ";
3061            private static final String _SQL_COUNT_TRASHENTRY = "SELECT COUNT(trashEntry) FROM TrashEntry trashEntry";
3062            private static final String _SQL_COUNT_TRASHENTRY_WHERE = "SELECT COUNT(trashEntry) FROM TrashEntry trashEntry WHERE ";
3063            private static final String _ORDER_BY_ENTITY_ALIAS = "trashEntry.";
3064            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No TrashEntry exists with the primary key ";
3065            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No TrashEntry exists with the key {";
3066            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3067            private static final Log _log = LogFactoryUtil.getLog(TrashEntryPersistenceImpl.class);
3068            private static final TrashEntry _nullTrashEntry = new TrashEntryImpl() {
3069                            @Override
3070                            public Object clone() {
3071                                    return this;
3072                            }
3073    
3074                            @Override
3075                            public CacheModel<TrashEntry> toCacheModel() {
3076                                    return _nullTrashEntryCacheModel;
3077                            }
3078                    };
3079    
3080            private static final CacheModel<TrashEntry> _nullTrashEntryCacheModel = new CacheModel<TrashEntry>() {
3081                            @Override
3082                            public TrashEntry toEntityModel() {
3083                                    return _nullTrashEntry;
3084                            }
3085                    };
3086    }