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.documentlibrary.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.SQLQuery;
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.ArrayUtil;
030    import com.liferay.portal.kernel.util.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.Validator;
036    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
039    import com.liferay.portal.service.ServiceContext;
040    import com.liferay.portal.service.ServiceContextThreadLocal;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
044    import com.liferay.portlet.documentlibrary.model.DLFileEntry;
045    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
046    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryModelImpl;
047    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
048    
049    import java.io.Serializable;
050    
051    import java.util.Collections;
052    import java.util.Date;
053    import java.util.HashMap;
054    import java.util.HashSet;
055    import java.util.Iterator;
056    import java.util.List;
057    import java.util.Map;
058    import java.util.Set;
059    
060    /**
061     * The persistence implementation for the document library file entry service.
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Brian Wing Shun Chan
068     * @see DLFileEntryPersistence
069     * @see com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryUtil
070     * @generated
071     */
072    @ProviderType
073    public class DLFileEntryPersistenceImpl extends BasePersistenceImpl<DLFileEntry>
074            implements DLFileEntryPersistence {
075            /*
076             * NOTE FOR DEVELOPERS:
077             *
078             * Never modify or reference this class directly. Always use {@link DLFileEntryUtil} to access the document library file entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
079             */
080            public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryImpl.class.getName();
081            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List1";
083            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List2";
085            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
086                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
089                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
092                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
093                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
095                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
097                            new String[] {
098                                    String.class.getName(),
099                                    
100                            Integer.class.getName(), Integer.class.getName(),
101                                    OrderByComparator.class.getName()
102                            });
103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
106                            new String[] { String.class.getName() },
107                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK |
108                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
109                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
110            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
111                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
113                            new String[] { String.class.getName() });
114    
115            /**
116             * Returns all the document library file entries where uuid = &#63;.
117             *
118             * @param uuid the uuid
119             * @return the matching document library file entries
120             */
121            @Override
122            public List<DLFileEntry> findByUuid(String uuid) {
123                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
124            }
125    
126            /**
127             * Returns a range of all the document library file entries where uuid = &#63;.
128             *
129             * <p>
130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
131             * </p>
132             *
133             * @param uuid the uuid
134             * @param start the lower bound of the range of document library file entries
135             * @param end the upper bound of the range of document library file entries (not inclusive)
136             * @return the range of matching document library file entries
137             */
138            @Override
139            public List<DLFileEntry> findByUuid(String uuid, int start, int end) {
140                    return findByUuid(uuid, start, end, null);
141            }
142    
143            /**
144             * Returns an ordered range of all the document library file entries where uuid = &#63;.
145             *
146             * <p>
147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
148             * </p>
149             *
150             * @param uuid the uuid
151             * @param start the lower bound of the range of document library file entries
152             * @param end the upper bound of the range of document library file entries (not inclusive)
153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
154             * @return the ordered range of matching document library file entries
155             */
156            @Override
157            public List<DLFileEntry> findByUuid(String uuid, int start, int end,
158                    OrderByComparator<DLFileEntry> orderByComparator) {
159                    boolean pagination = true;
160                    FinderPath finderPath = null;
161                    Object[] finderArgs = null;
162    
163                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164                                    (orderByComparator == null)) {
165                            pagination = false;
166                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
167                            finderArgs = new Object[] { uuid };
168                    }
169                    else {
170                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
171                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
172                    }
173    
174                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
175                                    finderArgs, this);
176    
177                    if ((list != null) && !list.isEmpty()) {
178                            for (DLFileEntry dlFileEntry : list) {
179                                    if (!Validator.equals(uuid, dlFileEntry.getUuid())) {
180                                            list = null;
181    
182                                            break;
183                                    }
184                            }
185                    }
186    
187                    if (list == null) {
188                            StringBundler query = null;
189    
190                            if (orderByComparator != null) {
191                                    query = new StringBundler(3 +
192                                                    (orderByComparator.getOrderByFields().length * 3));
193                            }
194                            else {
195                                    query = new StringBundler(3);
196                            }
197    
198                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
199    
200                            boolean bindUuid = false;
201    
202                            if (uuid == null) {
203                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
204                            }
205                            else if (uuid.equals(StringPool.BLANK)) {
206                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
207                            }
208                            else {
209                                    bindUuid = true;
210    
211                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
212                            }
213    
214                            if (orderByComparator != null) {
215                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216                                            orderByComparator);
217                            }
218                            else
219                             if (pagination) {
220                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
221                            }
222    
223                            String sql = query.toString();
224    
225                            Session session = null;
226    
227                            try {
228                                    session = openSession();
229    
230                                    Query q = session.createQuery(sql);
231    
232                                    QueryPos qPos = QueryPos.getInstance(q);
233    
234                                    if (bindUuid) {
235                                            qPos.add(uuid);
236                                    }
237    
238                                    if (!pagination) {
239                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
240                                                            start, end, false);
241    
242                                            Collections.sort(list);
243    
244                                            list = Collections.unmodifiableList(list);
245                                    }
246                                    else {
247                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
248                                                            start, end);
249                                    }
250    
251                                    cacheResult(list);
252    
253                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
254                            }
255                            catch (Exception e) {
256                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
257    
258                                    throw processException(e);
259                            }
260                            finally {
261                                    closeSession(session);
262                            }
263                    }
264    
265                    return list;
266            }
267    
268            /**
269             * Returns the first document library file entry in the ordered set where uuid = &#63;.
270             *
271             * @param uuid the uuid
272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
273             * @return the first matching document library file entry
274             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
275             */
276            @Override
277            public DLFileEntry findByUuid_First(String uuid,
278                    OrderByComparator<DLFileEntry> orderByComparator)
279                    throws NoSuchFileEntryException {
280                    DLFileEntry dlFileEntry = fetchByUuid_First(uuid, orderByComparator);
281    
282                    if (dlFileEntry != null) {
283                            return dlFileEntry;
284                    }
285    
286                    StringBundler msg = new StringBundler(4);
287    
288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289    
290                    msg.append("uuid=");
291                    msg.append(uuid);
292    
293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
294    
295                    throw new NoSuchFileEntryException(msg.toString());
296            }
297    
298            /**
299             * Returns the first document library file entry in the ordered set where uuid = &#63;.
300             *
301             * @param uuid the uuid
302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
303             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
304             */
305            @Override
306            public DLFileEntry fetchByUuid_First(String uuid,
307                    OrderByComparator<DLFileEntry> orderByComparator) {
308                    List<DLFileEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
309    
310                    if (!list.isEmpty()) {
311                            return list.get(0);
312                    }
313    
314                    return null;
315            }
316    
317            /**
318             * Returns the last document library file entry in the ordered set where uuid = &#63;.
319             *
320             * @param uuid the uuid
321             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
322             * @return the last matching document library file entry
323             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
324             */
325            @Override
326            public DLFileEntry findByUuid_Last(String uuid,
327                    OrderByComparator<DLFileEntry> orderByComparator)
328                    throws NoSuchFileEntryException {
329                    DLFileEntry dlFileEntry = fetchByUuid_Last(uuid, orderByComparator);
330    
331                    if (dlFileEntry != null) {
332                            return dlFileEntry;
333                    }
334    
335                    StringBundler msg = new StringBundler(4);
336    
337                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
338    
339                    msg.append("uuid=");
340                    msg.append(uuid);
341    
342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
343    
344                    throw new NoSuchFileEntryException(msg.toString());
345            }
346    
347            /**
348             * Returns the last document library file entry in the ordered set where uuid = &#63;.
349             *
350             * @param uuid the uuid
351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
352             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
353             */
354            @Override
355            public DLFileEntry fetchByUuid_Last(String uuid,
356                    OrderByComparator<DLFileEntry> orderByComparator) {
357                    int count = countByUuid(uuid);
358    
359                    if (count == 0) {
360                            return null;
361                    }
362    
363                    List<DLFileEntry> list = findByUuid(uuid, count - 1, count,
364                                    orderByComparator);
365    
366                    if (!list.isEmpty()) {
367                            return list.get(0);
368                    }
369    
370                    return null;
371            }
372    
373            /**
374             * Returns the document library file entries before and after the current document library file entry in the ordered set where uuid = &#63;.
375             *
376             * @param fileEntryId the primary key of the current document library file entry
377             * @param uuid the uuid
378             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
379             * @return the previous, current, and next document library file entry
380             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
381             */
382            @Override
383            public DLFileEntry[] findByUuid_PrevAndNext(long fileEntryId, String uuid,
384                    OrderByComparator<DLFileEntry> orderByComparator)
385                    throws NoSuchFileEntryException {
386                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
387    
388                    Session session = null;
389    
390                    try {
391                            session = openSession();
392    
393                            DLFileEntry[] array = new DLFileEntryImpl[3];
394    
395                            array[0] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
396                                            orderByComparator, true);
397    
398                            array[1] = dlFileEntry;
399    
400                            array[2] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
401                                            orderByComparator, false);
402    
403                            return array;
404                    }
405                    catch (Exception e) {
406                            throw processException(e);
407                    }
408                    finally {
409                            closeSession(session);
410                    }
411            }
412    
413            protected DLFileEntry getByUuid_PrevAndNext(Session session,
414                    DLFileEntry dlFileEntry, String uuid,
415                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
416                    StringBundler query = null;
417    
418                    if (orderByComparator != null) {
419                            query = new StringBundler(6 +
420                                            (orderByComparator.getOrderByFields().length * 6));
421                    }
422                    else {
423                            query = new StringBundler(3);
424                    }
425    
426                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
427    
428                    boolean bindUuid = false;
429    
430                    if (uuid == null) {
431                            query.append(_FINDER_COLUMN_UUID_UUID_1);
432                    }
433                    else if (uuid.equals(StringPool.BLANK)) {
434                            query.append(_FINDER_COLUMN_UUID_UUID_3);
435                    }
436                    else {
437                            bindUuid = true;
438    
439                            query.append(_FINDER_COLUMN_UUID_UUID_2);
440                    }
441    
442                    if (orderByComparator != null) {
443                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
444    
445                            if (orderByConditionFields.length > 0) {
446                                    query.append(WHERE_AND);
447                            }
448    
449                            for (int i = 0; i < orderByConditionFields.length; i++) {
450                                    query.append(_ORDER_BY_ENTITY_ALIAS);
451                                    query.append(orderByConditionFields[i]);
452    
453                                    if ((i + 1) < orderByConditionFields.length) {
454                                            if (orderByComparator.isAscending() ^ previous) {
455                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
456                                            }
457                                            else {
458                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
459                                            }
460                                    }
461                                    else {
462                                            if (orderByComparator.isAscending() ^ previous) {
463                                                    query.append(WHERE_GREATER_THAN);
464                                            }
465                                            else {
466                                                    query.append(WHERE_LESSER_THAN);
467                                            }
468                                    }
469                            }
470    
471                            query.append(ORDER_BY_CLAUSE);
472    
473                            String[] orderByFields = orderByComparator.getOrderByFields();
474    
475                            for (int i = 0; i < orderByFields.length; i++) {
476                                    query.append(_ORDER_BY_ENTITY_ALIAS);
477                                    query.append(orderByFields[i]);
478    
479                                    if ((i + 1) < orderByFields.length) {
480                                            if (orderByComparator.isAscending() ^ previous) {
481                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
482                                            }
483                                            else {
484                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
485                                            }
486                                    }
487                                    else {
488                                            if (orderByComparator.isAscending() ^ previous) {
489                                                    query.append(ORDER_BY_ASC);
490                                            }
491                                            else {
492                                                    query.append(ORDER_BY_DESC);
493                                            }
494                                    }
495                            }
496                    }
497                    else {
498                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
499                    }
500    
501                    String sql = query.toString();
502    
503                    Query q = session.createQuery(sql);
504    
505                    q.setFirstResult(0);
506                    q.setMaxResults(2);
507    
508                    QueryPos qPos = QueryPos.getInstance(q);
509    
510                    if (bindUuid) {
511                            qPos.add(uuid);
512                    }
513    
514                    if (orderByComparator != null) {
515                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
516    
517                            for (Object value : values) {
518                                    qPos.add(value);
519                            }
520                    }
521    
522                    List<DLFileEntry> list = q.list();
523    
524                    if (list.size() == 2) {
525                            return list.get(1);
526                    }
527                    else {
528                            return null;
529                    }
530            }
531    
532            /**
533             * Removes all the document library file entries where uuid = &#63; from the database.
534             *
535             * @param uuid the uuid
536             */
537            @Override
538            public void removeByUuid(String uuid) {
539                    for (DLFileEntry dlFileEntry : findByUuid(uuid, QueryUtil.ALL_POS,
540                                    QueryUtil.ALL_POS, null)) {
541                            remove(dlFileEntry);
542                    }
543            }
544    
545            /**
546             * Returns the number of document library file entries where uuid = &#63;.
547             *
548             * @param uuid the uuid
549             * @return the number of matching document library file entries
550             */
551            @Override
552            public int countByUuid(String uuid) {
553                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
554    
555                    Object[] finderArgs = new Object[] { uuid };
556    
557                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
558                                    this);
559    
560                    if (count == null) {
561                            StringBundler query = new StringBundler(2);
562    
563                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
564    
565                            boolean bindUuid = false;
566    
567                            if (uuid == null) {
568                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
569                            }
570                            else if (uuid.equals(StringPool.BLANK)) {
571                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
572                            }
573                            else {
574                                    bindUuid = true;
575    
576                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
577                            }
578    
579                            String sql = query.toString();
580    
581                            Session session = null;
582    
583                            try {
584                                    session = openSession();
585    
586                                    Query q = session.createQuery(sql);
587    
588                                    QueryPos qPos = QueryPos.getInstance(q);
589    
590                                    if (bindUuid) {
591                                            qPos.add(uuid);
592                                    }
593    
594                                    count = (Long)q.uniqueResult();
595    
596                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
597                            }
598                            catch (Exception e) {
599                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
600    
601                                    throw processException(e);
602                            }
603                            finally {
604                                    closeSession(session);
605                            }
606                    }
607    
608                    return count.intValue();
609            }
610    
611            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntry.uuid IS NULL";
612            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntry.uuid = ?";
613            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = '')";
614            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
615                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
616                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
617                            new String[] { String.class.getName(), Long.class.getName() },
618                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK |
619                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK);
620            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
621                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
622                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
623                            new String[] { String.class.getName(), Long.class.getName() });
624    
625            /**
626             * Returns the document library file entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchFileEntryException} if it could not be found.
627             *
628             * @param uuid the uuid
629             * @param groupId the group ID
630             * @return the matching document library file entry
631             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
632             */
633            @Override
634            public DLFileEntry findByUUID_G(String uuid, long groupId)
635                    throws NoSuchFileEntryException {
636                    DLFileEntry dlFileEntry = fetchByUUID_G(uuid, groupId);
637    
638                    if (dlFileEntry == null) {
639                            StringBundler msg = new StringBundler(6);
640    
641                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
642    
643                            msg.append("uuid=");
644                            msg.append(uuid);
645    
646                            msg.append(", groupId=");
647                            msg.append(groupId);
648    
649                            msg.append(StringPool.CLOSE_CURLY_BRACE);
650    
651                            if (_log.isWarnEnabled()) {
652                                    _log.warn(msg.toString());
653                            }
654    
655                            throw new NoSuchFileEntryException(msg.toString());
656                    }
657    
658                    return dlFileEntry;
659            }
660    
661            /**
662             * Returns the document library file entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
663             *
664             * @param uuid the uuid
665             * @param groupId the group ID
666             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
667             */
668            @Override
669            public DLFileEntry fetchByUUID_G(String uuid, long groupId) {
670                    return fetchByUUID_G(uuid, groupId, true);
671            }
672    
673            /**
674             * Returns the document library file entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
675             *
676             * @param uuid the uuid
677             * @param groupId the group ID
678             * @param retrieveFromCache whether to use the finder cache
679             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
680             */
681            @Override
682            public DLFileEntry fetchByUUID_G(String uuid, long groupId,
683                    boolean retrieveFromCache) {
684                    Object[] finderArgs = new Object[] { uuid, groupId };
685    
686                    Object result = null;
687    
688                    if (retrieveFromCache) {
689                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
690                                            finderArgs, this);
691                    }
692    
693                    if (result instanceof DLFileEntry) {
694                            DLFileEntry dlFileEntry = (DLFileEntry)result;
695    
696                            if (!Validator.equals(uuid, dlFileEntry.getUuid()) ||
697                                            (groupId != dlFileEntry.getGroupId())) {
698                                    result = null;
699                            }
700                    }
701    
702                    if (result == null) {
703                            StringBundler query = new StringBundler(4);
704    
705                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
706    
707                            boolean bindUuid = false;
708    
709                            if (uuid == null) {
710                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
711                            }
712                            else if (uuid.equals(StringPool.BLANK)) {
713                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
714                            }
715                            else {
716                                    bindUuid = true;
717    
718                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
719                            }
720    
721                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
722    
723                            String sql = query.toString();
724    
725                            Session session = null;
726    
727                            try {
728                                    session = openSession();
729    
730                                    Query q = session.createQuery(sql);
731    
732                                    QueryPos qPos = QueryPos.getInstance(q);
733    
734                                    if (bindUuid) {
735                                            qPos.add(uuid);
736                                    }
737    
738                                    qPos.add(groupId);
739    
740                                    List<DLFileEntry> list = q.list();
741    
742                                    if (list.isEmpty()) {
743                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
744                                                    finderArgs, list);
745                                    }
746                                    else {
747                                            DLFileEntry dlFileEntry = list.get(0);
748    
749                                            result = dlFileEntry;
750    
751                                            cacheResult(dlFileEntry);
752    
753                                            if ((dlFileEntry.getUuid() == null) ||
754                                                            !dlFileEntry.getUuid().equals(uuid) ||
755                                                            (dlFileEntry.getGroupId() != groupId)) {
756                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
757                                                            finderArgs, dlFileEntry);
758                                            }
759                                    }
760                            }
761                            catch (Exception e) {
762                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
763                                            finderArgs);
764    
765                                    throw processException(e);
766                            }
767                            finally {
768                                    closeSession(session);
769                            }
770                    }
771    
772                    if (result instanceof List<?>) {
773                            return null;
774                    }
775                    else {
776                            return (DLFileEntry)result;
777                    }
778            }
779    
780            /**
781             * Removes the document library file entry where uuid = &#63; and groupId = &#63; from the database.
782             *
783             * @param uuid the uuid
784             * @param groupId the group ID
785             * @return the document library file entry that was removed
786             */
787            @Override
788            public DLFileEntry removeByUUID_G(String uuid, long groupId)
789                    throws NoSuchFileEntryException {
790                    DLFileEntry dlFileEntry = findByUUID_G(uuid, groupId);
791    
792                    return remove(dlFileEntry);
793            }
794    
795            /**
796             * Returns the number of document library file entries where uuid = &#63; and groupId = &#63;.
797             *
798             * @param uuid the uuid
799             * @param groupId the group ID
800             * @return the number of matching document library file entries
801             */
802            @Override
803            public int countByUUID_G(String uuid, long groupId) {
804                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
805    
806                    Object[] finderArgs = new Object[] { uuid, groupId };
807    
808                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
809                                    this);
810    
811                    if (count == null) {
812                            StringBundler query = new StringBundler(3);
813    
814                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
815    
816                            boolean bindUuid = false;
817    
818                            if (uuid == null) {
819                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
820                            }
821                            else if (uuid.equals(StringPool.BLANK)) {
822                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
823                            }
824                            else {
825                                    bindUuid = true;
826    
827                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
828                            }
829    
830                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
831    
832                            String sql = query.toString();
833    
834                            Session session = null;
835    
836                            try {
837                                    session = openSession();
838    
839                                    Query q = session.createQuery(sql);
840    
841                                    QueryPos qPos = QueryPos.getInstance(q);
842    
843                                    if (bindUuid) {
844                                            qPos.add(uuid);
845                                    }
846    
847                                    qPos.add(groupId);
848    
849                                    count = (Long)q.uniqueResult();
850    
851                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
852                            }
853                            catch (Exception e) {
854                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
855    
856                                    throw processException(e);
857                            }
858                            finally {
859                                    closeSession(session);
860                            }
861                    }
862    
863                    return count.intValue();
864            }
865    
866            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntry.uuid IS NULL AND ";
867            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntry.uuid = ? AND ";
868            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = '') AND ";
869            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntry.groupId = ?";
870            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
871                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
872                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
873                            new String[] {
874                                    String.class.getName(), Long.class.getName(),
875                                    
876                            Integer.class.getName(), Integer.class.getName(),
877                                    OrderByComparator.class.getName()
878                            });
879            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
880                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
881                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
882                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
883                            new String[] { String.class.getName(), Long.class.getName() },
884                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK |
885                            DLFileEntryModelImpl.COMPANYID_COLUMN_BITMASK |
886                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
887                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
888            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
889                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
890                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
891                            new String[] { String.class.getName(), Long.class.getName() });
892    
893            /**
894             * Returns all the document library file entries where uuid = &#63; and companyId = &#63;.
895             *
896             * @param uuid the uuid
897             * @param companyId the company ID
898             * @return the matching document library file entries
899             */
900            @Override
901            public List<DLFileEntry> findByUuid_C(String uuid, long companyId) {
902                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
903                            QueryUtil.ALL_POS, null);
904            }
905    
906            /**
907             * Returns a range of all the document library file entries where uuid = &#63; and companyId = &#63;.
908             *
909             * <p>
910             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
911             * </p>
912             *
913             * @param uuid the uuid
914             * @param companyId the company ID
915             * @param start the lower bound of the range of document library file entries
916             * @param end the upper bound of the range of document library file entries (not inclusive)
917             * @return the range of matching document library file entries
918             */
919            @Override
920            public List<DLFileEntry> findByUuid_C(String uuid, long companyId,
921                    int start, int end) {
922                    return findByUuid_C(uuid, companyId, start, end, null);
923            }
924    
925            /**
926             * Returns an ordered range of all the document library file entries where uuid = &#63; and companyId = &#63;.
927             *
928             * <p>
929             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
930             * </p>
931             *
932             * @param uuid the uuid
933             * @param companyId the company ID
934             * @param start the lower bound of the range of document library file entries
935             * @param end the upper bound of the range of document library file entries (not inclusive)
936             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
937             * @return the ordered range of matching document library file entries
938             */
939            @Override
940            public List<DLFileEntry> findByUuid_C(String uuid, long companyId,
941                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
942                    boolean pagination = true;
943                    FinderPath finderPath = null;
944                    Object[] finderArgs = null;
945    
946                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
947                                    (orderByComparator == null)) {
948                            pagination = false;
949                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
950                            finderArgs = new Object[] { uuid, companyId };
951                    }
952                    else {
953                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
954                            finderArgs = new Object[] {
955                                            uuid, companyId,
956                                            
957                                            start, end, orderByComparator
958                                    };
959                    }
960    
961                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
962                                    finderArgs, this);
963    
964                    if ((list != null) && !list.isEmpty()) {
965                            for (DLFileEntry dlFileEntry : list) {
966                                    if (!Validator.equals(uuid, dlFileEntry.getUuid()) ||
967                                                    (companyId != dlFileEntry.getCompanyId())) {
968                                            list = null;
969    
970                                            break;
971                                    }
972                            }
973                    }
974    
975                    if (list == null) {
976                            StringBundler query = null;
977    
978                            if (orderByComparator != null) {
979                                    query = new StringBundler(4 +
980                                                    (orderByComparator.getOrderByFields().length * 3));
981                            }
982                            else {
983                                    query = new StringBundler(4);
984                            }
985    
986                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
987    
988                            boolean bindUuid = false;
989    
990                            if (uuid == null) {
991                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
992                            }
993                            else if (uuid.equals(StringPool.BLANK)) {
994                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
995                            }
996                            else {
997                                    bindUuid = true;
998    
999                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1000                            }
1001    
1002                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1003    
1004                            if (orderByComparator != null) {
1005                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1006                                            orderByComparator);
1007                            }
1008                            else
1009                             if (pagination) {
1010                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1011                            }
1012    
1013                            String sql = query.toString();
1014    
1015                            Session session = null;
1016    
1017                            try {
1018                                    session = openSession();
1019    
1020                                    Query q = session.createQuery(sql);
1021    
1022                                    QueryPos qPos = QueryPos.getInstance(q);
1023    
1024                                    if (bindUuid) {
1025                                            qPos.add(uuid);
1026                                    }
1027    
1028                                    qPos.add(companyId);
1029    
1030                                    if (!pagination) {
1031                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1032                                                            start, end, false);
1033    
1034                                            Collections.sort(list);
1035    
1036                                            list = Collections.unmodifiableList(list);
1037                                    }
1038                                    else {
1039                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1040                                                            start, end);
1041                                    }
1042    
1043                                    cacheResult(list);
1044    
1045                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1046                            }
1047                            catch (Exception e) {
1048                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1049    
1050                                    throw processException(e);
1051                            }
1052                            finally {
1053                                    closeSession(session);
1054                            }
1055                    }
1056    
1057                    return list;
1058            }
1059    
1060            /**
1061             * Returns the first document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1062             *
1063             * @param uuid the uuid
1064             * @param companyId the company ID
1065             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1066             * @return the first matching document library file entry
1067             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
1068             */
1069            @Override
1070            public DLFileEntry findByUuid_C_First(String uuid, long companyId,
1071                    OrderByComparator<DLFileEntry> orderByComparator)
1072                    throws NoSuchFileEntryException {
1073                    DLFileEntry dlFileEntry = fetchByUuid_C_First(uuid, companyId,
1074                                    orderByComparator);
1075    
1076                    if (dlFileEntry != null) {
1077                            return dlFileEntry;
1078                    }
1079    
1080                    StringBundler msg = new StringBundler(6);
1081    
1082                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1083    
1084                    msg.append("uuid=");
1085                    msg.append(uuid);
1086    
1087                    msg.append(", companyId=");
1088                    msg.append(companyId);
1089    
1090                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1091    
1092                    throw new NoSuchFileEntryException(msg.toString());
1093            }
1094    
1095            /**
1096             * Returns the first document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1097             *
1098             * @param uuid the uuid
1099             * @param companyId the company ID
1100             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1101             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1102             */
1103            @Override
1104            public DLFileEntry fetchByUuid_C_First(String uuid, long companyId,
1105                    OrderByComparator<DLFileEntry> orderByComparator) {
1106                    List<DLFileEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1107                                    orderByComparator);
1108    
1109                    if (!list.isEmpty()) {
1110                            return list.get(0);
1111                    }
1112    
1113                    return null;
1114            }
1115    
1116            /**
1117             * Returns the last document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1118             *
1119             * @param uuid the uuid
1120             * @param companyId the company ID
1121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1122             * @return the last matching document library file entry
1123             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
1124             */
1125            @Override
1126            public DLFileEntry findByUuid_C_Last(String uuid, long companyId,
1127                    OrderByComparator<DLFileEntry> orderByComparator)
1128                    throws NoSuchFileEntryException {
1129                    DLFileEntry dlFileEntry = fetchByUuid_C_Last(uuid, companyId,
1130                                    orderByComparator);
1131    
1132                    if (dlFileEntry != null) {
1133                            return dlFileEntry;
1134                    }
1135    
1136                    StringBundler msg = new StringBundler(6);
1137    
1138                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1139    
1140                    msg.append("uuid=");
1141                    msg.append(uuid);
1142    
1143                    msg.append(", companyId=");
1144                    msg.append(companyId);
1145    
1146                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1147    
1148                    throw new NoSuchFileEntryException(msg.toString());
1149            }
1150    
1151            /**
1152             * Returns the last document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1153             *
1154             * @param uuid the uuid
1155             * @param companyId the company ID
1156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1157             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1158             */
1159            @Override
1160            public DLFileEntry fetchByUuid_C_Last(String uuid, long companyId,
1161                    OrderByComparator<DLFileEntry> orderByComparator) {
1162                    int count = countByUuid_C(uuid, companyId);
1163    
1164                    if (count == 0) {
1165                            return null;
1166                    }
1167    
1168                    List<DLFileEntry> list = findByUuid_C(uuid, companyId, count - 1,
1169                                    count, orderByComparator);
1170    
1171                    if (!list.isEmpty()) {
1172                            return list.get(0);
1173                    }
1174    
1175                    return null;
1176            }
1177    
1178            /**
1179             * Returns the document library file entries before and after the current document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1180             *
1181             * @param fileEntryId the primary key of the current document library file entry
1182             * @param uuid the uuid
1183             * @param companyId the company ID
1184             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1185             * @return the previous, current, and next document library file entry
1186             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
1187             */
1188            @Override
1189            public DLFileEntry[] findByUuid_C_PrevAndNext(long fileEntryId,
1190                    String uuid, long companyId,
1191                    OrderByComparator<DLFileEntry> orderByComparator)
1192                    throws NoSuchFileEntryException {
1193                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1194    
1195                    Session session = null;
1196    
1197                    try {
1198                            session = openSession();
1199    
1200                            DLFileEntry[] array = new DLFileEntryImpl[3];
1201    
1202                            array[0] = getByUuid_C_PrevAndNext(session, dlFileEntry, uuid,
1203                                            companyId, orderByComparator, true);
1204    
1205                            array[1] = dlFileEntry;
1206    
1207                            array[2] = getByUuid_C_PrevAndNext(session, dlFileEntry, uuid,
1208                                            companyId, orderByComparator, false);
1209    
1210                            return array;
1211                    }
1212                    catch (Exception e) {
1213                            throw processException(e);
1214                    }
1215                    finally {
1216                            closeSession(session);
1217                    }
1218            }
1219    
1220            protected DLFileEntry getByUuid_C_PrevAndNext(Session session,
1221                    DLFileEntry dlFileEntry, String uuid, long companyId,
1222                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
1223                    StringBundler query = null;
1224    
1225                    if (orderByComparator != null) {
1226                            query = new StringBundler(6 +
1227                                            (orderByComparator.getOrderByFields().length * 6));
1228                    }
1229                    else {
1230                            query = new StringBundler(3);
1231                    }
1232    
1233                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1234    
1235                    boolean bindUuid = false;
1236    
1237                    if (uuid == null) {
1238                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1239                    }
1240                    else if (uuid.equals(StringPool.BLANK)) {
1241                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1242                    }
1243                    else {
1244                            bindUuid = true;
1245    
1246                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1247                    }
1248    
1249                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1250    
1251                    if (orderByComparator != null) {
1252                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1253    
1254                            if (orderByConditionFields.length > 0) {
1255                                    query.append(WHERE_AND);
1256                            }
1257    
1258                            for (int i = 0; i < orderByConditionFields.length; i++) {
1259                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1260                                    query.append(orderByConditionFields[i]);
1261    
1262                                    if ((i + 1) < orderByConditionFields.length) {
1263                                            if (orderByComparator.isAscending() ^ previous) {
1264                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1265                                            }
1266                                            else {
1267                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1268                                            }
1269                                    }
1270                                    else {
1271                                            if (orderByComparator.isAscending() ^ previous) {
1272                                                    query.append(WHERE_GREATER_THAN);
1273                                            }
1274                                            else {
1275                                                    query.append(WHERE_LESSER_THAN);
1276                                            }
1277                                    }
1278                            }
1279    
1280                            query.append(ORDER_BY_CLAUSE);
1281    
1282                            String[] orderByFields = orderByComparator.getOrderByFields();
1283    
1284                            for (int i = 0; i < orderByFields.length; i++) {
1285                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1286                                    query.append(orderByFields[i]);
1287    
1288                                    if ((i + 1) < orderByFields.length) {
1289                                            if (orderByComparator.isAscending() ^ previous) {
1290                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1291                                            }
1292                                            else {
1293                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1294                                            }
1295                                    }
1296                                    else {
1297                                            if (orderByComparator.isAscending() ^ previous) {
1298                                                    query.append(ORDER_BY_ASC);
1299                                            }
1300                                            else {
1301                                                    query.append(ORDER_BY_DESC);
1302                                            }
1303                                    }
1304                            }
1305                    }
1306                    else {
1307                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1308                    }
1309    
1310                    String sql = query.toString();
1311    
1312                    Query q = session.createQuery(sql);
1313    
1314                    q.setFirstResult(0);
1315                    q.setMaxResults(2);
1316    
1317                    QueryPos qPos = QueryPos.getInstance(q);
1318    
1319                    if (bindUuid) {
1320                            qPos.add(uuid);
1321                    }
1322    
1323                    qPos.add(companyId);
1324    
1325                    if (orderByComparator != null) {
1326                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
1327    
1328                            for (Object value : values) {
1329                                    qPos.add(value);
1330                            }
1331                    }
1332    
1333                    List<DLFileEntry> list = q.list();
1334    
1335                    if (list.size() == 2) {
1336                            return list.get(1);
1337                    }
1338                    else {
1339                            return null;
1340                    }
1341            }
1342    
1343            /**
1344             * Removes all the document library file entries where uuid = &#63; and companyId = &#63; from the database.
1345             *
1346             * @param uuid the uuid
1347             * @param companyId the company ID
1348             */
1349            @Override
1350            public void removeByUuid_C(String uuid, long companyId) {
1351                    for (DLFileEntry dlFileEntry : findByUuid_C(uuid, companyId,
1352                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1353                            remove(dlFileEntry);
1354                    }
1355            }
1356    
1357            /**
1358             * Returns the number of document library file entries where uuid = &#63; and companyId = &#63;.
1359             *
1360             * @param uuid the uuid
1361             * @param companyId the company ID
1362             * @return the number of matching document library file entries
1363             */
1364            @Override
1365            public int countByUuid_C(String uuid, long companyId) {
1366                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1367    
1368                    Object[] finderArgs = new Object[] { uuid, companyId };
1369    
1370                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1371                                    this);
1372    
1373                    if (count == null) {
1374                            StringBundler query = new StringBundler(3);
1375    
1376                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
1377    
1378                            boolean bindUuid = false;
1379    
1380                            if (uuid == null) {
1381                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1382                            }
1383                            else if (uuid.equals(StringPool.BLANK)) {
1384                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1385                            }
1386                            else {
1387                                    bindUuid = true;
1388    
1389                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1390                            }
1391    
1392                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1393    
1394                            String sql = query.toString();
1395    
1396                            Session session = null;
1397    
1398                            try {
1399                                    session = openSession();
1400    
1401                                    Query q = session.createQuery(sql);
1402    
1403                                    QueryPos qPos = QueryPos.getInstance(q);
1404    
1405                                    if (bindUuid) {
1406                                            qPos.add(uuid);
1407                                    }
1408    
1409                                    qPos.add(companyId);
1410    
1411                                    count = (Long)q.uniqueResult();
1412    
1413                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1414                            }
1415                            catch (Exception e) {
1416                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1417    
1418                                    throw processException(e);
1419                            }
1420                            finally {
1421                                    closeSession(session);
1422                            }
1423                    }
1424    
1425                    return count.intValue();
1426            }
1427    
1428            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "dlFileEntry.uuid IS NULL AND ";
1429            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dlFileEntry.uuid = ? AND ";
1430            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = '') AND ";
1431            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dlFileEntry.companyId = ?";
1432            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
1433                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
1434                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1435                            new String[] {
1436                                    Long.class.getName(),
1437                                    
1438                            Integer.class.getName(), Integer.class.getName(),
1439                                    OrderByComparator.class.getName()
1440                            });
1441            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1442                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
1443                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
1444                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1445                            new String[] { Long.class.getName() },
1446                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
1447                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
1448                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
1449            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
1450                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1451                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1452                            new String[] { Long.class.getName() });
1453    
1454            /**
1455             * Returns all the document library file entries where groupId = &#63;.
1456             *
1457             * @param groupId the group ID
1458             * @return the matching document library file entries
1459             */
1460            @Override
1461            public List<DLFileEntry> findByGroupId(long groupId) {
1462                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1463            }
1464    
1465            /**
1466             * Returns a range of all the document library file entries where groupId = &#63;.
1467             *
1468             * <p>
1469             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
1470             * </p>
1471             *
1472             * @param groupId the group ID
1473             * @param start the lower bound of the range of document library file entries
1474             * @param end the upper bound of the range of document library file entries (not inclusive)
1475             * @return the range of matching document library file entries
1476             */
1477            @Override
1478            public List<DLFileEntry> findByGroupId(long groupId, int start, int end) {
1479                    return findByGroupId(groupId, start, end, null);
1480            }
1481    
1482            /**
1483             * Returns an ordered range of all the document library file entries where groupId = &#63;.
1484             *
1485             * <p>
1486             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
1487             * </p>
1488             *
1489             * @param groupId the group ID
1490             * @param start the lower bound of the range of document library file entries
1491             * @param end the upper bound of the range of document library file entries (not inclusive)
1492             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1493             * @return the ordered range of matching document library file entries
1494             */
1495            @Override
1496            public List<DLFileEntry> findByGroupId(long groupId, int start, int end,
1497                    OrderByComparator<DLFileEntry> orderByComparator) {
1498                    boolean pagination = true;
1499                    FinderPath finderPath = null;
1500                    Object[] finderArgs = null;
1501    
1502                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1503                                    (orderByComparator == null)) {
1504                            pagination = false;
1505                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1506                            finderArgs = new Object[] { groupId };
1507                    }
1508                    else {
1509                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1510                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1511                    }
1512    
1513                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
1514                                    finderArgs, this);
1515    
1516                    if ((list != null) && !list.isEmpty()) {
1517                            for (DLFileEntry dlFileEntry : list) {
1518                                    if ((groupId != dlFileEntry.getGroupId())) {
1519                                            list = null;
1520    
1521                                            break;
1522                                    }
1523                            }
1524                    }
1525    
1526                    if (list == null) {
1527                            StringBundler query = null;
1528    
1529                            if (orderByComparator != null) {
1530                                    query = new StringBundler(3 +
1531                                                    (orderByComparator.getOrderByFields().length * 3));
1532                            }
1533                            else {
1534                                    query = new StringBundler(3);
1535                            }
1536    
1537                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1538    
1539                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1540    
1541                            if (orderByComparator != null) {
1542                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1543                                            orderByComparator);
1544                            }
1545                            else
1546                             if (pagination) {
1547                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1548                            }
1549    
1550                            String sql = query.toString();
1551    
1552                            Session session = null;
1553    
1554                            try {
1555                                    session = openSession();
1556    
1557                                    Query q = session.createQuery(sql);
1558    
1559                                    QueryPos qPos = QueryPos.getInstance(q);
1560    
1561                                    qPos.add(groupId);
1562    
1563                                    if (!pagination) {
1564                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1565                                                            start, end, false);
1566    
1567                                            Collections.sort(list);
1568    
1569                                            list = Collections.unmodifiableList(list);
1570                                    }
1571                                    else {
1572                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1573                                                            start, end);
1574                                    }
1575    
1576                                    cacheResult(list);
1577    
1578                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1579                            }
1580                            catch (Exception e) {
1581                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1582    
1583                                    throw processException(e);
1584                            }
1585                            finally {
1586                                    closeSession(session);
1587                            }
1588                    }
1589    
1590                    return list;
1591            }
1592    
1593            /**
1594             * Returns the first document library file entry in the ordered set where groupId = &#63;.
1595             *
1596             * @param groupId the group ID
1597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1598             * @return the first matching document library file entry
1599             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
1600             */
1601            @Override
1602            public DLFileEntry findByGroupId_First(long groupId,
1603                    OrderByComparator<DLFileEntry> orderByComparator)
1604                    throws NoSuchFileEntryException {
1605                    DLFileEntry dlFileEntry = fetchByGroupId_First(groupId,
1606                                    orderByComparator);
1607    
1608                    if (dlFileEntry != null) {
1609                            return dlFileEntry;
1610                    }
1611    
1612                    StringBundler msg = new StringBundler(4);
1613    
1614                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1615    
1616                    msg.append("groupId=");
1617                    msg.append(groupId);
1618    
1619                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1620    
1621                    throw new NoSuchFileEntryException(msg.toString());
1622            }
1623    
1624            /**
1625             * Returns the first document library file entry in the ordered set where groupId = &#63;.
1626             *
1627             * @param groupId the group ID
1628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1629             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1630             */
1631            @Override
1632            public DLFileEntry fetchByGroupId_First(long groupId,
1633                    OrderByComparator<DLFileEntry> orderByComparator) {
1634                    List<DLFileEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1635    
1636                    if (!list.isEmpty()) {
1637                            return list.get(0);
1638                    }
1639    
1640                    return null;
1641            }
1642    
1643            /**
1644             * Returns the last document library file entry in the ordered set where groupId = &#63;.
1645             *
1646             * @param groupId the group ID
1647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1648             * @return the last matching document library file entry
1649             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
1650             */
1651            @Override
1652            public DLFileEntry findByGroupId_Last(long groupId,
1653                    OrderByComparator<DLFileEntry> orderByComparator)
1654                    throws NoSuchFileEntryException {
1655                    DLFileEntry dlFileEntry = fetchByGroupId_Last(groupId, orderByComparator);
1656    
1657                    if (dlFileEntry != null) {
1658                            return dlFileEntry;
1659                    }
1660    
1661                    StringBundler msg = new StringBundler(4);
1662    
1663                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1664    
1665                    msg.append("groupId=");
1666                    msg.append(groupId);
1667    
1668                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1669    
1670                    throw new NoSuchFileEntryException(msg.toString());
1671            }
1672    
1673            /**
1674             * Returns the last document library file entry in the ordered set where groupId = &#63;.
1675             *
1676             * @param groupId the group ID
1677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1678             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1679             */
1680            @Override
1681            public DLFileEntry fetchByGroupId_Last(long groupId,
1682                    OrderByComparator<DLFileEntry> orderByComparator) {
1683                    int count = countByGroupId(groupId);
1684    
1685                    if (count == 0) {
1686                            return null;
1687                    }
1688    
1689                    List<DLFileEntry> list = findByGroupId(groupId, count - 1, count,
1690                                    orderByComparator);
1691    
1692                    if (!list.isEmpty()) {
1693                            return list.get(0);
1694                    }
1695    
1696                    return null;
1697            }
1698    
1699            /**
1700             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63;.
1701             *
1702             * @param fileEntryId the primary key of the current document library file entry
1703             * @param groupId the group ID
1704             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1705             * @return the previous, current, and next document library file entry
1706             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
1707             */
1708            @Override
1709            public DLFileEntry[] findByGroupId_PrevAndNext(long fileEntryId,
1710                    long groupId, OrderByComparator<DLFileEntry> orderByComparator)
1711                    throws NoSuchFileEntryException {
1712                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1713    
1714                    Session session = null;
1715    
1716                    try {
1717                            session = openSession();
1718    
1719                            DLFileEntry[] array = new DLFileEntryImpl[3];
1720    
1721                            array[0] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1722                                            orderByComparator, true);
1723    
1724                            array[1] = dlFileEntry;
1725    
1726                            array[2] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1727                                            orderByComparator, false);
1728    
1729                            return array;
1730                    }
1731                    catch (Exception e) {
1732                            throw processException(e);
1733                    }
1734                    finally {
1735                            closeSession(session);
1736                    }
1737            }
1738    
1739            protected DLFileEntry getByGroupId_PrevAndNext(Session session,
1740                    DLFileEntry dlFileEntry, long groupId,
1741                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
1742                    StringBundler query = null;
1743    
1744                    if (orderByComparator != null) {
1745                            query = new StringBundler(6 +
1746                                            (orderByComparator.getOrderByFields().length * 6));
1747                    }
1748                    else {
1749                            query = new StringBundler(3);
1750                    }
1751    
1752                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1753    
1754                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1755    
1756                    if (orderByComparator != null) {
1757                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1758    
1759                            if (orderByConditionFields.length > 0) {
1760                                    query.append(WHERE_AND);
1761                            }
1762    
1763                            for (int i = 0; i < orderByConditionFields.length; i++) {
1764                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1765                                    query.append(orderByConditionFields[i]);
1766    
1767                                    if ((i + 1) < orderByConditionFields.length) {
1768                                            if (orderByComparator.isAscending() ^ previous) {
1769                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1770                                            }
1771                                            else {
1772                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1773                                            }
1774                                    }
1775                                    else {
1776                                            if (orderByComparator.isAscending() ^ previous) {
1777                                                    query.append(WHERE_GREATER_THAN);
1778                                            }
1779                                            else {
1780                                                    query.append(WHERE_LESSER_THAN);
1781                                            }
1782                                    }
1783                            }
1784    
1785                            query.append(ORDER_BY_CLAUSE);
1786    
1787                            String[] orderByFields = orderByComparator.getOrderByFields();
1788    
1789                            for (int i = 0; i < orderByFields.length; i++) {
1790                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1791                                    query.append(orderByFields[i]);
1792    
1793                                    if ((i + 1) < orderByFields.length) {
1794                                            if (orderByComparator.isAscending() ^ previous) {
1795                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1796                                            }
1797                                            else {
1798                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1799                                            }
1800                                    }
1801                                    else {
1802                                            if (orderByComparator.isAscending() ^ previous) {
1803                                                    query.append(ORDER_BY_ASC);
1804                                            }
1805                                            else {
1806                                                    query.append(ORDER_BY_DESC);
1807                                            }
1808                                    }
1809                            }
1810                    }
1811                    else {
1812                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1813                    }
1814    
1815                    String sql = query.toString();
1816    
1817                    Query q = session.createQuery(sql);
1818    
1819                    q.setFirstResult(0);
1820                    q.setMaxResults(2);
1821    
1822                    QueryPos qPos = QueryPos.getInstance(q);
1823    
1824                    qPos.add(groupId);
1825    
1826                    if (orderByComparator != null) {
1827                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
1828    
1829                            for (Object value : values) {
1830                                    qPos.add(value);
1831                            }
1832                    }
1833    
1834                    List<DLFileEntry> list = q.list();
1835    
1836                    if (list.size() == 2) {
1837                            return list.get(1);
1838                    }
1839                    else {
1840                            return null;
1841                    }
1842            }
1843    
1844            /**
1845             * Returns all the document library file entries that the user has permission to view where groupId = &#63;.
1846             *
1847             * @param groupId the group ID
1848             * @return the matching document library file entries that the user has permission to view
1849             */
1850            @Override
1851            public List<DLFileEntry> filterFindByGroupId(long groupId) {
1852                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1853                            QueryUtil.ALL_POS, null);
1854            }
1855    
1856            /**
1857             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63;.
1858             *
1859             * <p>
1860             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
1861             * </p>
1862             *
1863             * @param groupId the group ID
1864             * @param start the lower bound of the range of document library file entries
1865             * @param end the upper bound of the range of document library file entries (not inclusive)
1866             * @return the range of matching document library file entries that the user has permission to view
1867             */
1868            @Override
1869            public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1870                    int end) {
1871                    return filterFindByGroupId(groupId, start, end, null);
1872            }
1873    
1874            /**
1875             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63;.
1876             *
1877             * <p>
1878             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
1879             * </p>
1880             *
1881             * @param groupId the group ID
1882             * @param start the lower bound of the range of document library file entries
1883             * @param end the upper bound of the range of document library file entries (not inclusive)
1884             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1885             * @return the ordered range of matching document library file entries that the user has permission to view
1886             */
1887            @Override
1888            public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1889                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
1890                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1891                            return findByGroupId(groupId, start, end, orderByComparator);
1892                    }
1893    
1894                    StringBundler query = null;
1895    
1896                    if (orderByComparator != null) {
1897                            query = new StringBundler(3 +
1898                                            (orderByComparator.getOrderByFields().length * 3));
1899                    }
1900                    else {
1901                            query = new StringBundler(3);
1902                    }
1903    
1904                    if (getDB().isSupportsInlineDistinct()) {
1905                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
1906                    }
1907                    else {
1908                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
1909                    }
1910    
1911                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1912    
1913                    if (!getDB().isSupportsInlineDistinct()) {
1914                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
1915                    }
1916    
1917                    if (orderByComparator != null) {
1918                            if (getDB().isSupportsInlineDistinct()) {
1919                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1920                                            orderByComparator, true);
1921                            }
1922                            else {
1923                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1924                                            orderByComparator, true);
1925                            }
1926                    }
1927                    else {
1928                            if (getDB().isSupportsInlineDistinct()) {
1929                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1930                            }
1931                            else {
1932                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
1933                            }
1934                    }
1935    
1936                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1937                                    DLFileEntry.class.getName(),
1938                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1939    
1940                    Session session = null;
1941    
1942                    try {
1943                            session = openSession();
1944    
1945                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1946    
1947                            if (getDB().isSupportsInlineDistinct()) {
1948                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
1949                            }
1950                            else {
1951                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
1952                            }
1953    
1954                            QueryPos qPos = QueryPos.getInstance(q);
1955    
1956                            qPos.add(groupId);
1957    
1958                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
1959                    }
1960                    catch (Exception e) {
1961                            throw processException(e);
1962                    }
1963                    finally {
1964                            closeSession(session);
1965                    }
1966            }
1967    
1968            /**
1969             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63;.
1970             *
1971             * @param fileEntryId the primary key of the current document library file entry
1972             * @param groupId the group ID
1973             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1974             * @return the previous, current, and next document library file entry
1975             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
1976             */
1977            @Override
1978            public DLFileEntry[] filterFindByGroupId_PrevAndNext(long fileEntryId,
1979                    long groupId, OrderByComparator<DLFileEntry> orderByComparator)
1980                    throws NoSuchFileEntryException {
1981                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1982                            return findByGroupId_PrevAndNext(fileEntryId, groupId,
1983                                    orderByComparator);
1984                    }
1985    
1986                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1987    
1988                    Session session = null;
1989    
1990                    try {
1991                            session = openSession();
1992    
1993                            DLFileEntry[] array = new DLFileEntryImpl[3];
1994    
1995                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFileEntry,
1996                                            groupId, orderByComparator, true);
1997    
1998                            array[1] = dlFileEntry;
1999    
2000                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFileEntry,
2001                                            groupId, orderByComparator, false);
2002    
2003                            return array;
2004                    }
2005                    catch (Exception e) {
2006                            throw processException(e);
2007                    }
2008                    finally {
2009                            closeSession(session);
2010                    }
2011            }
2012    
2013            protected DLFileEntry filterGetByGroupId_PrevAndNext(Session session,
2014                    DLFileEntry dlFileEntry, long groupId,
2015                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
2016                    StringBundler query = null;
2017    
2018                    if (orderByComparator != null) {
2019                            query = new StringBundler(6 +
2020                                            (orderByComparator.getOrderByFields().length * 6));
2021                    }
2022                    else {
2023                            query = new StringBundler(3);
2024                    }
2025    
2026                    if (getDB().isSupportsInlineDistinct()) {
2027                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
2028                    }
2029                    else {
2030                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
2031                    }
2032    
2033                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2034    
2035                    if (!getDB().isSupportsInlineDistinct()) {
2036                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
2037                    }
2038    
2039                    if (orderByComparator != null) {
2040                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2041    
2042                            if (orderByConditionFields.length > 0) {
2043                                    query.append(WHERE_AND);
2044                            }
2045    
2046                            for (int i = 0; i < orderByConditionFields.length; i++) {
2047                                    if (getDB().isSupportsInlineDistinct()) {
2048                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2049                                    }
2050                                    else {
2051                                            query.append(_ORDER_BY_ENTITY_TABLE);
2052                                    }
2053    
2054                                    query.append(orderByConditionFields[i]);
2055    
2056                                    if ((i + 1) < orderByConditionFields.length) {
2057                                            if (orderByComparator.isAscending() ^ previous) {
2058                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2059                                            }
2060                                            else {
2061                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2062                                            }
2063                                    }
2064                                    else {
2065                                            if (orderByComparator.isAscending() ^ previous) {
2066                                                    query.append(WHERE_GREATER_THAN);
2067                                            }
2068                                            else {
2069                                                    query.append(WHERE_LESSER_THAN);
2070                                            }
2071                                    }
2072                            }
2073    
2074                            query.append(ORDER_BY_CLAUSE);
2075    
2076                            String[] orderByFields = orderByComparator.getOrderByFields();
2077    
2078                            for (int i = 0; i < orderByFields.length; i++) {
2079                                    if (getDB().isSupportsInlineDistinct()) {
2080                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2081                                    }
2082                                    else {
2083                                            query.append(_ORDER_BY_ENTITY_TABLE);
2084                                    }
2085    
2086                                    query.append(orderByFields[i]);
2087    
2088                                    if ((i + 1) < orderByFields.length) {
2089                                            if (orderByComparator.isAscending() ^ previous) {
2090                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2091                                            }
2092                                            else {
2093                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2094                                            }
2095                                    }
2096                                    else {
2097                                            if (orderByComparator.isAscending() ^ previous) {
2098                                                    query.append(ORDER_BY_ASC);
2099                                            }
2100                                            else {
2101                                                    query.append(ORDER_BY_DESC);
2102                                            }
2103                                    }
2104                            }
2105                    }
2106                    else {
2107                            if (getDB().isSupportsInlineDistinct()) {
2108                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2109                            }
2110                            else {
2111                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
2112                            }
2113                    }
2114    
2115                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2116                                    DLFileEntry.class.getName(),
2117                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2118    
2119                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2120    
2121                    q.setFirstResult(0);
2122                    q.setMaxResults(2);
2123    
2124                    if (getDB().isSupportsInlineDistinct()) {
2125                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
2126                    }
2127                    else {
2128                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
2129                    }
2130    
2131                    QueryPos qPos = QueryPos.getInstance(q);
2132    
2133                    qPos.add(groupId);
2134    
2135                    if (orderByComparator != null) {
2136                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2137    
2138                            for (Object value : values) {
2139                                    qPos.add(value);
2140                            }
2141                    }
2142    
2143                    List<DLFileEntry> list = q.list();
2144    
2145                    if (list.size() == 2) {
2146                            return list.get(1);
2147                    }
2148                    else {
2149                            return null;
2150                    }
2151            }
2152    
2153            /**
2154             * Removes all the document library file entries where groupId = &#63; from the database.
2155             *
2156             * @param groupId the group ID
2157             */
2158            @Override
2159            public void removeByGroupId(long groupId) {
2160                    for (DLFileEntry dlFileEntry : findByGroupId(groupId,
2161                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2162                            remove(dlFileEntry);
2163                    }
2164            }
2165    
2166            /**
2167             * Returns the number of document library file entries where groupId = &#63;.
2168             *
2169             * @param groupId the group ID
2170             * @return the number of matching document library file entries
2171             */
2172            @Override
2173            public int countByGroupId(long groupId) {
2174                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2175    
2176                    Object[] finderArgs = new Object[] { groupId };
2177    
2178                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2179                                    this);
2180    
2181                    if (count == null) {
2182                            StringBundler query = new StringBundler(2);
2183    
2184                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
2185    
2186                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2187    
2188                            String sql = query.toString();
2189    
2190                            Session session = null;
2191    
2192                            try {
2193                                    session = openSession();
2194    
2195                                    Query q = session.createQuery(sql);
2196    
2197                                    QueryPos qPos = QueryPos.getInstance(q);
2198    
2199                                    qPos.add(groupId);
2200    
2201                                    count = (Long)q.uniqueResult();
2202    
2203                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2204                            }
2205                            catch (Exception e) {
2206                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2207    
2208                                    throw processException(e);
2209                            }
2210                            finally {
2211                                    closeSession(session);
2212                            }
2213                    }
2214    
2215                    return count.intValue();
2216            }
2217    
2218            /**
2219             * Returns the number of document library file entries that the user has permission to view where groupId = &#63;.
2220             *
2221             * @param groupId the group ID
2222             * @return the number of matching document library file entries that the user has permission to view
2223             */
2224            @Override
2225            public int filterCountByGroupId(long groupId) {
2226                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2227                            return countByGroupId(groupId);
2228                    }
2229    
2230                    StringBundler query = new StringBundler(2);
2231    
2232                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
2233    
2234                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2235    
2236                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2237                                    DLFileEntry.class.getName(),
2238                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2239    
2240                    Session session = null;
2241    
2242                    try {
2243                            session = openSession();
2244    
2245                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2246    
2247                            q.addScalar(COUNT_COLUMN_NAME,
2248                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2249    
2250                            QueryPos qPos = QueryPos.getInstance(q);
2251    
2252                            qPos.add(groupId);
2253    
2254                            Long count = (Long)q.uniqueResult();
2255    
2256                            return count.intValue();
2257                    }
2258                    catch (Exception e) {
2259                            throw processException(e);
2260                    }
2261                    finally {
2262                            closeSession(session);
2263                    }
2264            }
2265    
2266            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntry.groupId = ?";
2267            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2268                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2269                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
2270                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2271                            new String[] {
2272                                    Long.class.getName(),
2273                                    
2274                            Integer.class.getName(), Integer.class.getName(),
2275                                    OrderByComparator.class.getName()
2276                            });
2277            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2278                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2279                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
2280                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2281                            new String[] { Long.class.getName() },
2282                            DLFileEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2283                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
2284                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
2285            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2286                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2287                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2288                            new String[] { Long.class.getName() });
2289    
2290            /**
2291             * Returns all the document library file entries where companyId = &#63;.
2292             *
2293             * @param companyId the company ID
2294             * @return the matching document library file entries
2295             */
2296            @Override
2297            public List<DLFileEntry> findByCompanyId(long companyId) {
2298                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2299                            null);
2300            }
2301    
2302            /**
2303             * Returns a range of all the document library file entries where companyId = &#63;.
2304             *
2305             * <p>
2306             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
2307             * </p>
2308             *
2309             * @param companyId the company ID
2310             * @param start the lower bound of the range of document library file entries
2311             * @param end the upper bound of the range of document library file entries (not inclusive)
2312             * @return the range of matching document library file entries
2313             */
2314            @Override
2315            public List<DLFileEntry> findByCompanyId(long companyId, int start, int end) {
2316                    return findByCompanyId(companyId, start, end, null);
2317            }
2318    
2319            /**
2320             * Returns an ordered range of all the document library file entries where companyId = &#63;.
2321             *
2322             * <p>
2323             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
2324             * </p>
2325             *
2326             * @param companyId the company ID
2327             * @param start the lower bound of the range of document library file entries
2328             * @param end the upper bound of the range of document library file entries (not inclusive)
2329             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2330             * @return the ordered range of matching document library file entries
2331             */
2332            @Override
2333            public List<DLFileEntry> findByCompanyId(long companyId, int start,
2334                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
2335                    boolean pagination = true;
2336                    FinderPath finderPath = null;
2337                    Object[] finderArgs = null;
2338    
2339                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2340                                    (orderByComparator == null)) {
2341                            pagination = false;
2342                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2343                            finderArgs = new Object[] { companyId };
2344                    }
2345                    else {
2346                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2347                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2348                    }
2349    
2350                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
2351                                    finderArgs, this);
2352    
2353                    if ((list != null) && !list.isEmpty()) {
2354                            for (DLFileEntry dlFileEntry : list) {
2355                                    if ((companyId != dlFileEntry.getCompanyId())) {
2356                                            list = null;
2357    
2358                                            break;
2359                                    }
2360                            }
2361                    }
2362    
2363                    if (list == null) {
2364                            StringBundler query = null;
2365    
2366                            if (orderByComparator != null) {
2367                                    query = new StringBundler(3 +
2368                                                    (orderByComparator.getOrderByFields().length * 3));
2369                            }
2370                            else {
2371                                    query = new StringBundler(3);
2372                            }
2373    
2374                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2375    
2376                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2377    
2378                            if (orderByComparator != null) {
2379                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2380                                            orderByComparator);
2381                            }
2382                            else
2383                             if (pagination) {
2384                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2385                            }
2386    
2387                            String sql = query.toString();
2388    
2389                            Session session = null;
2390    
2391                            try {
2392                                    session = openSession();
2393    
2394                                    Query q = session.createQuery(sql);
2395    
2396                                    QueryPos qPos = QueryPos.getInstance(q);
2397    
2398                                    qPos.add(companyId);
2399    
2400                                    if (!pagination) {
2401                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2402                                                            start, end, false);
2403    
2404                                            Collections.sort(list);
2405    
2406                                            list = Collections.unmodifiableList(list);
2407                                    }
2408                                    else {
2409                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2410                                                            start, end);
2411                                    }
2412    
2413                                    cacheResult(list);
2414    
2415                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2416                            }
2417                            catch (Exception e) {
2418                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2419    
2420                                    throw processException(e);
2421                            }
2422                            finally {
2423                                    closeSession(session);
2424                            }
2425                    }
2426    
2427                    return list;
2428            }
2429    
2430            /**
2431             * Returns the first document library file entry in the ordered set where companyId = &#63;.
2432             *
2433             * @param companyId the company ID
2434             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2435             * @return the first matching document library file entry
2436             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
2437             */
2438            @Override
2439            public DLFileEntry findByCompanyId_First(long companyId,
2440                    OrderByComparator<DLFileEntry> orderByComparator)
2441                    throws NoSuchFileEntryException {
2442                    DLFileEntry dlFileEntry = fetchByCompanyId_First(companyId,
2443                                    orderByComparator);
2444    
2445                    if (dlFileEntry != null) {
2446                            return dlFileEntry;
2447                    }
2448    
2449                    StringBundler msg = new StringBundler(4);
2450    
2451                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2452    
2453                    msg.append("companyId=");
2454                    msg.append(companyId);
2455    
2456                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2457    
2458                    throw new NoSuchFileEntryException(msg.toString());
2459            }
2460    
2461            /**
2462             * Returns the first document library file entry in the ordered set where companyId = &#63;.
2463             *
2464             * @param companyId the company ID
2465             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2466             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
2467             */
2468            @Override
2469            public DLFileEntry fetchByCompanyId_First(long companyId,
2470                    OrderByComparator<DLFileEntry> orderByComparator) {
2471                    List<DLFileEntry> list = findByCompanyId(companyId, 0, 1,
2472                                    orderByComparator);
2473    
2474                    if (!list.isEmpty()) {
2475                            return list.get(0);
2476                    }
2477    
2478                    return null;
2479            }
2480    
2481            /**
2482             * Returns the last document library file entry in the ordered set where companyId = &#63;.
2483             *
2484             * @param companyId the company ID
2485             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2486             * @return the last matching document library file entry
2487             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
2488             */
2489            @Override
2490            public DLFileEntry findByCompanyId_Last(long companyId,
2491                    OrderByComparator<DLFileEntry> orderByComparator)
2492                    throws NoSuchFileEntryException {
2493                    DLFileEntry dlFileEntry = fetchByCompanyId_Last(companyId,
2494                                    orderByComparator);
2495    
2496                    if (dlFileEntry != null) {
2497                            return dlFileEntry;
2498                    }
2499    
2500                    StringBundler msg = new StringBundler(4);
2501    
2502                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2503    
2504                    msg.append("companyId=");
2505                    msg.append(companyId);
2506    
2507                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2508    
2509                    throw new NoSuchFileEntryException(msg.toString());
2510            }
2511    
2512            /**
2513             * Returns the last document library file entry in the ordered set where companyId = &#63;.
2514             *
2515             * @param companyId the company ID
2516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2517             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
2518             */
2519            @Override
2520            public DLFileEntry fetchByCompanyId_Last(long companyId,
2521                    OrderByComparator<DLFileEntry> orderByComparator) {
2522                    int count = countByCompanyId(companyId);
2523    
2524                    if (count == 0) {
2525                            return null;
2526                    }
2527    
2528                    List<DLFileEntry> list = findByCompanyId(companyId, count - 1, count,
2529                                    orderByComparator);
2530    
2531                    if (!list.isEmpty()) {
2532                            return list.get(0);
2533                    }
2534    
2535                    return null;
2536            }
2537    
2538            /**
2539             * Returns the document library file entries before and after the current document library file entry in the ordered set where companyId = &#63;.
2540             *
2541             * @param fileEntryId the primary key of the current document library file entry
2542             * @param companyId the company ID
2543             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2544             * @return the previous, current, and next document library file entry
2545             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
2546             */
2547            @Override
2548            public DLFileEntry[] findByCompanyId_PrevAndNext(long fileEntryId,
2549                    long companyId, OrderByComparator<DLFileEntry> orderByComparator)
2550                    throws NoSuchFileEntryException {
2551                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2552    
2553                    Session session = null;
2554    
2555                    try {
2556                            session = openSession();
2557    
2558                            DLFileEntry[] array = new DLFileEntryImpl[3];
2559    
2560                            array[0] = getByCompanyId_PrevAndNext(session, dlFileEntry,
2561                                            companyId, orderByComparator, true);
2562    
2563                            array[1] = dlFileEntry;
2564    
2565                            array[2] = getByCompanyId_PrevAndNext(session, dlFileEntry,
2566                                            companyId, orderByComparator, false);
2567    
2568                            return array;
2569                    }
2570                    catch (Exception e) {
2571                            throw processException(e);
2572                    }
2573                    finally {
2574                            closeSession(session);
2575                    }
2576            }
2577    
2578            protected DLFileEntry getByCompanyId_PrevAndNext(Session session,
2579                    DLFileEntry dlFileEntry, long companyId,
2580                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
2581                    StringBundler query = null;
2582    
2583                    if (orderByComparator != null) {
2584                            query = new StringBundler(6 +
2585                                            (orderByComparator.getOrderByFields().length * 6));
2586                    }
2587                    else {
2588                            query = new StringBundler(3);
2589                    }
2590    
2591                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2592    
2593                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2594    
2595                    if (orderByComparator != null) {
2596                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2597    
2598                            if (orderByConditionFields.length > 0) {
2599                                    query.append(WHERE_AND);
2600                            }
2601    
2602                            for (int i = 0; i < orderByConditionFields.length; i++) {
2603                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2604                                    query.append(orderByConditionFields[i]);
2605    
2606                                    if ((i + 1) < orderByConditionFields.length) {
2607                                            if (orderByComparator.isAscending() ^ previous) {
2608                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2609                                            }
2610                                            else {
2611                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2612                                            }
2613                                    }
2614                                    else {
2615                                            if (orderByComparator.isAscending() ^ previous) {
2616                                                    query.append(WHERE_GREATER_THAN);
2617                                            }
2618                                            else {
2619                                                    query.append(WHERE_LESSER_THAN);
2620                                            }
2621                                    }
2622                            }
2623    
2624                            query.append(ORDER_BY_CLAUSE);
2625    
2626                            String[] orderByFields = orderByComparator.getOrderByFields();
2627    
2628                            for (int i = 0; i < orderByFields.length; i++) {
2629                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2630                                    query.append(orderByFields[i]);
2631    
2632                                    if ((i + 1) < orderByFields.length) {
2633                                            if (orderByComparator.isAscending() ^ previous) {
2634                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2635                                            }
2636                                            else {
2637                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2638                                            }
2639                                    }
2640                                    else {
2641                                            if (orderByComparator.isAscending() ^ previous) {
2642                                                    query.append(ORDER_BY_ASC);
2643                                            }
2644                                            else {
2645                                                    query.append(ORDER_BY_DESC);
2646                                            }
2647                                    }
2648                            }
2649                    }
2650                    else {
2651                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2652                    }
2653    
2654                    String sql = query.toString();
2655    
2656                    Query q = session.createQuery(sql);
2657    
2658                    q.setFirstResult(0);
2659                    q.setMaxResults(2);
2660    
2661                    QueryPos qPos = QueryPos.getInstance(q);
2662    
2663                    qPos.add(companyId);
2664    
2665                    if (orderByComparator != null) {
2666                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2667    
2668                            for (Object value : values) {
2669                                    qPos.add(value);
2670                            }
2671                    }
2672    
2673                    List<DLFileEntry> list = q.list();
2674    
2675                    if (list.size() == 2) {
2676                            return list.get(1);
2677                    }
2678                    else {
2679                            return null;
2680                    }
2681            }
2682    
2683            /**
2684             * Removes all the document library file entries where companyId = &#63; from the database.
2685             *
2686             * @param companyId the company ID
2687             */
2688            @Override
2689            public void removeByCompanyId(long companyId) {
2690                    for (DLFileEntry dlFileEntry : findByCompanyId(companyId,
2691                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2692                            remove(dlFileEntry);
2693                    }
2694            }
2695    
2696            /**
2697             * Returns the number of document library file entries where companyId = &#63;.
2698             *
2699             * @param companyId the company ID
2700             * @return the number of matching document library file entries
2701             */
2702            @Override
2703            public int countByCompanyId(long companyId) {
2704                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2705    
2706                    Object[] finderArgs = new Object[] { companyId };
2707    
2708                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2709                                    this);
2710    
2711                    if (count == null) {
2712                            StringBundler query = new StringBundler(2);
2713    
2714                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
2715    
2716                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2717    
2718                            String sql = query.toString();
2719    
2720                            Session session = null;
2721    
2722                            try {
2723                                    session = openSession();
2724    
2725                                    Query q = session.createQuery(sql);
2726    
2727                                    QueryPos qPos = QueryPos.getInstance(q);
2728    
2729                                    qPos.add(companyId);
2730    
2731                                    count = (Long)q.uniqueResult();
2732    
2733                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2734                            }
2735                            catch (Exception e) {
2736                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2737    
2738                                    throw processException(e);
2739                            }
2740                            finally {
2741                                    closeSession(session);
2742                            }
2743                    }
2744    
2745                    return count.intValue();
2746            }
2747    
2748            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFileEntry.companyId = ?";
2749            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID =
2750                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2751                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
2752                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRepositoryId",
2753                            new String[] {
2754                                    Long.class.getName(),
2755                                    
2756                            Integer.class.getName(), Integer.class.getName(),
2757                                    OrderByComparator.class.getName()
2758                            });
2759            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID =
2760                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2761                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
2762                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRepositoryId",
2763                            new String[] { Long.class.getName() },
2764                            DLFileEntryModelImpl.REPOSITORYID_COLUMN_BITMASK |
2765                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
2766                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
2767            public static final FinderPath FINDER_PATH_COUNT_BY_REPOSITORYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2768                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2769                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRepositoryId",
2770                            new String[] { Long.class.getName() });
2771    
2772            /**
2773             * Returns all the document library file entries where repositoryId = &#63;.
2774             *
2775             * @param repositoryId the repository ID
2776             * @return the matching document library file entries
2777             */
2778            @Override
2779            public List<DLFileEntry> findByRepositoryId(long repositoryId) {
2780                    return findByRepositoryId(repositoryId, QueryUtil.ALL_POS,
2781                            QueryUtil.ALL_POS, null);
2782            }
2783    
2784            /**
2785             * Returns a range of all the document library file entries where repositoryId = &#63;.
2786             *
2787             * <p>
2788             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
2789             * </p>
2790             *
2791             * @param repositoryId the repository ID
2792             * @param start the lower bound of the range of document library file entries
2793             * @param end the upper bound of the range of document library file entries (not inclusive)
2794             * @return the range of matching document library file entries
2795             */
2796            @Override
2797            public List<DLFileEntry> findByRepositoryId(long repositoryId, int start,
2798                    int end) {
2799                    return findByRepositoryId(repositoryId, start, end, null);
2800            }
2801    
2802            /**
2803             * Returns an ordered range of all the document library file entries where repositoryId = &#63;.
2804             *
2805             * <p>
2806             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
2807             * </p>
2808             *
2809             * @param repositoryId the repository ID
2810             * @param start the lower bound of the range of document library file entries
2811             * @param end the upper bound of the range of document library file entries (not inclusive)
2812             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2813             * @return the ordered range of matching document library file entries
2814             */
2815            @Override
2816            public List<DLFileEntry> findByRepositoryId(long repositoryId, int start,
2817                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
2818                    boolean pagination = true;
2819                    FinderPath finderPath = null;
2820                    Object[] finderArgs = null;
2821    
2822                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2823                                    (orderByComparator == null)) {
2824                            pagination = false;
2825                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID;
2826                            finderArgs = new Object[] { repositoryId };
2827                    }
2828                    else {
2829                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID;
2830                            finderArgs = new Object[] {
2831                                            repositoryId,
2832                                            
2833                                            start, end, orderByComparator
2834                                    };
2835                    }
2836    
2837                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
2838                                    finderArgs, this);
2839    
2840                    if ((list != null) && !list.isEmpty()) {
2841                            for (DLFileEntry dlFileEntry : list) {
2842                                    if ((repositoryId != dlFileEntry.getRepositoryId())) {
2843                                            list = null;
2844    
2845                                            break;
2846                                    }
2847                            }
2848                    }
2849    
2850                    if (list == null) {
2851                            StringBundler query = null;
2852    
2853                            if (orderByComparator != null) {
2854                                    query = new StringBundler(3 +
2855                                                    (orderByComparator.getOrderByFields().length * 3));
2856                            }
2857                            else {
2858                                    query = new StringBundler(3);
2859                            }
2860    
2861                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2862    
2863                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
2864    
2865                            if (orderByComparator != null) {
2866                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2867                                            orderByComparator);
2868                            }
2869                            else
2870                             if (pagination) {
2871                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2872                            }
2873    
2874                            String sql = query.toString();
2875    
2876                            Session session = null;
2877    
2878                            try {
2879                                    session = openSession();
2880    
2881                                    Query q = session.createQuery(sql);
2882    
2883                                    QueryPos qPos = QueryPos.getInstance(q);
2884    
2885                                    qPos.add(repositoryId);
2886    
2887                                    if (!pagination) {
2888                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2889                                                            start, end, false);
2890    
2891                                            Collections.sort(list);
2892    
2893                                            list = Collections.unmodifiableList(list);
2894                                    }
2895                                    else {
2896                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2897                                                            start, end);
2898                                    }
2899    
2900                                    cacheResult(list);
2901    
2902                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2903                            }
2904                            catch (Exception e) {
2905                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2906    
2907                                    throw processException(e);
2908                            }
2909                            finally {
2910                                    closeSession(session);
2911                            }
2912                    }
2913    
2914                    return list;
2915            }
2916    
2917            /**
2918             * Returns the first document library file entry in the ordered set where repositoryId = &#63;.
2919             *
2920             * @param repositoryId the repository ID
2921             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2922             * @return the first matching document library file entry
2923             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
2924             */
2925            @Override
2926            public DLFileEntry findByRepositoryId_First(long repositoryId,
2927                    OrderByComparator<DLFileEntry> orderByComparator)
2928                    throws NoSuchFileEntryException {
2929                    DLFileEntry dlFileEntry = fetchByRepositoryId_First(repositoryId,
2930                                    orderByComparator);
2931    
2932                    if (dlFileEntry != null) {
2933                            return dlFileEntry;
2934                    }
2935    
2936                    StringBundler msg = new StringBundler(4);
2937    
2938                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2939    
2940                    msg.append("repositoryId=");
2941                    msg.append(repositoryId);
2942    
2943                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2944    
2945                    throw new NoSuchFileEntryException(msg.toString());
2946            }
2947    
2948            /**
2949             * Returns the first document library file entry in the ordered set where repositoryId = &#63;.
2950             *
2951             * @param repositoryId the repository ID
2952             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2953             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
2954             */
2955            @Override
2956            public DLFileEntry fetchByRepositoryId_First(long repositoryId,
2957                    OrderByComparator<DLFileEntry> orderByComparator) {
2958                    List<DLFileEntry> list = findByRepositoryId(repositoryId, 0, 1,
2959                                    orderByComparator);
2960    
2961                    if (!list.isEmpty()) {
2962                            return list.get(0);
2963                    }
2964    
2965                    return null;
2966            }
2967    
2968            /**
2969             * Returns the last document library file entry in the ordered set where repositoryId = &#63;.
2970             *
2971             * @param repositoryId the repository ID
2972             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2973             * @return the last matching document library file entry
2974             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
2975             */
2976            @Override
2977            public DLFileEntry findByRepositoryId_Last(long repositoryId,
2978                    OrderByComparator<DLFileEntry> orderByComparator)
2979                    throws NoSuchFileEntryException {
2980                    DLFileEntry dlFileEntry = fetchByRepositoryId_Last(repositoryId,
2981                                    orderByComparator);
2982    
2983                    if (dlFileEntry != null) {
2984                            return dlFileEntry;
2985                    }
2986    
2987                    StringBundler msg = new StringBundler(4);
2988    
2989                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2990    
2991                    msg.append("repositoryId=");
2992                    msg.append(repositoryId);
2993    
2994                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2995    
2996                    throw new NoSuchFileEntryException(msg.toString());
2997            }
2998    
2999            /**
3000             * Returns the last document library file entry in the ordered set where repositoryId = &#63;.
3001             *
3002             * @param repositoryId the repository ID
3003             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3004             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
3005             */
3006            @Override
3007            public DLFileEntry fetchByRepositoryId_Last(long repositoryId,
3008                    OrderByComparator<DLFileEntry> orderByComparator) {
3009                    int count = countByRepositoryId(repositoryId);
3010    
3011                    if (count == 0) {
3012                            return null;
3013                    }
3014    
3015                    List<DLFileEntry> list = findByRepositoryId(repositoryId, count - 1,
3016                                    count, orderByComparator);
3017    
3018                    if (!list.isEmpty()) {
3019                            return list.get(0);
3020                    }
3021    
3022                    return null;
3023            }
3024    
3025            /**
3026             * Returns the document library file entries before and after the current document library file entry in the ordered set where repositoryId = &#63;.
3027             *
3028             * @param fileEntryId the primary key of the current document library file entry
3029             * @param repositoryId the repository ID
3030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3031             * @return the previous, current, and next document library file entry
3032             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
3033             */
3034            @Override
3035            public DLFileEntry[] findByRepositoryId_PrevAndNext(long fileEntryId,
3036                    long repositoryId, OrderByComparator<DLFileEntry> orderByComparator)
3037                    throws NoSuchFileEntryException {
3038                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3039    
3040                    Session session = null;
3041    
3042                    try {
3043                            session = openSession();
3044    
3045                            DLFileEntry[] array = new DLFileEntryImpl[3];
3046    
3047                            array[0] = getByRepositoryId_PrevAndNext(session, dlFileEntry,
3048                                            repositoryId, orderByComparator, true);
3049    
3050                            array[1] = dlFileEntry;
3051    
3052                            array[2] = getByRepositoryId_PrevAndNext(session, dlFileEntry,
3053                                            repositoryId, orderByComparator, false);
3054    
3055                            return array;
3056                    }
3057                    catch (Exception e) {
3058                            throw processException(e);
3059                    }
3060                    finally {
3061                            closeSession(session);
3062                    }
3063            }
3064    
3065            protected DLFileEntry getByRepositoryId_PrevAndNext(Session session,
3066                    DLFileEntry dlFileEntry, long repositoryId,
3067                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
3068                    StringBundler query = null;
3069    
3070                    if (orderByComparator != null) {
3071                            query = new StringBundler(6 +
3072                                            (orderByComparator.getOrderByFields().length * 6));
3073                    }
3074                    else {
3075                            query = new StringBundler(3);
3076                    }
3077    
3078                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3079    
3080                    query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
3081    
3082                    if (orderByComparator != null) {
3083                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3084    
3085                            if (orderByConditionFields.length > 0) {
3086                                    query.append(WHERE_AND);
3087                            }
3088    
3089                            for (int i = 0; i < orderByConditionFields.length; i++) {
3090                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3091                                    query.append(orderByConditionFields[i]);
3092    
3093                                    if ((i + 1) < orderByConditionFields.length) {
3094                                            if (orderByComparator.isAscending() ^ previous) {
3095                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3096                                            }
3097                                            else {
3098                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3099                                            }
3100                                    }
3101                                    else {
3102                                            if (orderByComparator.isAscending() ^ previous) {
3103                                                    query.append(WHERE_GREATER_THAN);
3104                                            }
3105                                            else {
3106                                                    query.append(WHERE_LESSER_THAN);
3107                                            }
3108                                    }
3109                            }
3110    
3111                            query.append(ORDER_BY_CLAUSE);
3112    
3113                            String[] orderByFields = orderByComparator.getOrderByFields();
3114    
3115                            for (int i = 0; i < orderByFields.length; i++) {
3116                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3117                                    query.append(orderByFields[i]);
3118    
3119                                    if ((i + 1) < orderByFields.length) {
3120                                            if (orderByComparator.isAscending() ^ previous) {
3121                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3122                                            }
3123                                            else {
3124                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3125                                            }
3126                                    }
3127                                    else {
3128                                            if (orderByComparator.isAscending() ^ previous) {
3129                                                    query.append(ORDER_BY_ASC);
3130                                            }
3131                                            else {
3132                                                    query.append(ORDER_BY_DESC);
3133                                            }
3134                                    }
3135                            }
3136                    }
3137                    else {
3138                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3139                    }
3140    
3141                    String sql = query.toString();
3142    
3143                    Query q = session.createQuery(sql);
3144    
3145                    q.setFirstResult(0);
3146                    q.setMaxResults(2);
3147    
3148                    QueryPos qPos = QueryPos.getInstance(q);
3149    
3150                    qPos.add(repositoryId);
3151    
3152                    if (orderByComparator != null) {
3153                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3154    
3155                            for (Object value : values) {
3156                                    qPos.add(value);
3157                            }
3158                    }
3159    
3160                    List<DLFileEntry> list = q.list();
3161    
3162                    if (list.size() == 2) {
3163                            return list.get(1);
3164                    }
3165                    else {
3166                            return null;
3167                    }
3168            }
3169    
3170            /**
3171             * Removes all the document library file entries where repositoryId = &#63; from the database.
3172             *
3173             * @param repositoryId the repository ID
3174             */
3175            @Override
3176            public void removeByRepositoryId(long repositoryId) {
3177                    for (DLFileEntry dlFileEntry : findByRepositoryId(repositoryId,
3178                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3179                            remove(dlFileEntry);
3180                    }
3181            }
3182    
3183            /**
3184             * Returns the number of document library file entries where repositoryId = &#63;.
3185             *
3186             * @param repositoryId the repository ID
3187             * @return the number of matching document library file entries
3188             */
3189            @Override
3190            public int countByRepositoryId(long repositoryId) {
3191                    FinderPath finderPath = FINDER_PATH_COUNT_BY_REPOSITORYID;
3192    
3193                    Object[] finderArgs = new Object[] { repositoryId };
3194    
3195                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3196                                    this);
3197    
3198                    if (count == null) {
3199                            StringBundler query = new StringBundler(2);
3200    
3201                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
3202    
3203                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
3204    
3205                            String sql = query.toString();
3206    
3207                            Session session = null;
3208    
3209                            try {
3210                                    session = openSession();
3211    
3212                                    Query q = session.createQuery(sql);
3213    
3214                                    QueryPos qPos = QueryPos.getInstance(q);
3215    
3216                                    qPos.add(repositoryId);
3217    
3218                                    count = (Long)q.uniqueResult();
3219    
3220                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3221                            }
3222                            catch (Exception e) {
3223                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3224    
3225                                    throw processException(e);
3226                            }
3227                            finally {
3228                                    closeSession(session);
3229                            }
3230                    }
3231    
3232                    return count.intValue();
3233            }
3234    
3235            private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "dlFileEntry.repositoryId = ?";
3236            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_MIMETYPE = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3237                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
3238                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByMimeType",
3239                            new String[] {
3240                                    String.class.getName(),
3241                                    
3242                            Integer.class.getName(), Integer.class.getName(),
3243                                    OrderByComparator.class.getName()
3244                            });
3245            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE =
3246                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3247                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
3248                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByMimeType",
3249                            new String[] { String.class.getName() },
3250                            DLFileEntryModelImpl.MIMETYPE_COLUMN_BITMASK |
3251                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
3252                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
3253            public static final FinderPath FINDER_PATH_COUNT_BY_MIMETYPE = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3254                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3255                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByMimeType",
3256                            new String[] { String.class.getName() });
3257    
3258            /**
3259             * Returns all the document library file entries where mimeType = &#63;.
3260             *
3261             * @param mimeType the mime type
3262             * @return the matching document library file entries
3263             */
3264            @Override
3265            public List<DLFileEntry> findByMimeType(String mimeType) {
3266                    return findByMimeType(mimeType, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3267                            null);
3268            }
3269    
3270            /**
3271             * Returns a range of all the document library file entries where mimeType = &#63;.
3272             *
3273             * <p>
3274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
3275             * </p>
3276             *
3277             * @param mimeType the mime type
3278             * @param start the lower bound of the range of document library file entries
3279             * @param end the upper bound of the range of document library file entries (not inclusive)
3280             * @return the range of matching document library file entries
3281             */
3282            @Override
3283            public List<DLFileEntry> findByMimeType(String mimeType, int start, int end) {
3284                    return findByMimeType(mimeType, start, end, null);
3285            }
3286    
3287            /**
3288             * Returns an ordered range of all the document library file entries where mimeType = &#63;.
3289             *
3290             * <p>
3291             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
3292             * </p>
3293             *
3294             * @param mimeType the mime type
3295             * @param start the lower bound of the range of document library file entries
3296             * @param end the upper bound of the range of document library file entries (not inclusive)
3297             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3298             * @return the ordered range of matching document library file entries
3299             */
3300            @Override
3301            public List<DLFileEntry> findByMimeType(String mimeType, int start,
3302                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
3303                    boolean pagination = true;
3304                    FinderPath finderPath = null;
3305                    Object[] finderArgs = null;
3306    
3307                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3308                                    (orderByComparator == null)) {
3309                            pagination = false;
3310                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE;
3311                            finderArgs = new Object[] { mimeType };
3312                    }
3313                    else {
3314                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_MIMETYPE;
3315                            finderArgs = new Object[] { mimeType, start, end, orderByComparator };
3316                    }
3317    
3318                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
3319                                    finderArgs, this);
3320    
3321                    if ((list != null) && !list.isEmpty()) {
3322                            for (DLFileEntry dlFileEntry : list) {
3323                                    if (!Validator.equals(mimeType, dlFileEntry.getMimeType())) {
3324                                            list = null;
3325    
3326                                            break;
3327                                    }
3328                            }
3329                    }
3330    
3331                    if (list == null) {
3332                            StringBundler query = null;
3333    
3334                            if (orderByComparator != null) {
3335                                    query = new StringBundler(3 +
3336                                                    (orderByComparator.getOrderByFields().length * 3));
3337                            }
3338                            else {
3339                                    query = new StringBundler(3);
3340                            }
3341    
3342                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3343    
3344                            boolean bindMimeType = false;
3345    
3346                            if (mimeType == null) {
3347                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_1);
3348                            }
3349                            else if (mimeType.equals(StringPool.BLANK)) {
3350                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_3);
3351                            }
3352                            else {
3353                                    bindMimeType = true;
3354    
3355                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_2);
3356                            }
3357    
3358                            if (orderByComparator != null) {
3359                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3360                                            orderByComparator);
3361                            }
3362                            else
3363                             if (pagination) {
3364                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3365                            }
3366    
3367                            String sql = query.toString();
3368    
3369                            Session session = null;
3370    
3371                            try {
3372                                    session = openSession();
3373    
3374                                    Query q = session.createQuery(sql);
3375    
3376                                    QueryPos qPos = QueryPos.getInstance(q);
3377    
3378                                    if (bindMimeType) {
3379                                            qPos.add(mimeType);
3380                                    }
3381    
3382                                    if (!pagination) {
3383                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3384                                                            start, end, false);
3385    
3386                                            Collections.sort(list);
3387    
3388                                            list = Collections.unmodifiableList(list);
3389                                    }
3390                                    else {
3391                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3392                                                            start, end);
3393                                    }
3394    
3395                                    cacheResult(list);
3396    
3397                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3398                            }
3399                            catch (Exception e) {
3400                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3401    
3402                                    throw processException(e);
3403                            }
3404                            finally {
3405                                    closeSession(session);
3406                            }
3407                    }
3408    
3409                    return list;
3410            }
3411    
3412            /**
3413             * Returns the first document library file entry in the ordered set where mimeType = &#63;.
3414             *
3415             * @param mimeType the mime type
3416             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3417             * @return the first matching document library file entry
3418             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
3419             */
3420            @Override
3421            public DLFileEntry findByMimeType_First(String mimeType,
3422                    OrderByComparator<DLFileEntry> orderByComparator)
3423                    throws NoSuchFileEntryException {
3424                    DLFileEntry dlFileEntry = fetchByMimeType_First(mimeType,
3425                                    orderByComparator);
3426    
3427                    if (dlFileEntry != null) {
3428                            return dlFileEntry;
3429                    }
3430    
3431                    StringBundler msg = new StringBundler(4);
3432    
3433                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3434    
3435                    msg.append("mimeType=");
3436                    msg.append(mimeType);
3437    
3438                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3439    
3440                    throw new NoSuchFileEntryException(msg.toString());
3441            }
3442    
3443            /**
3444             * Returns the first document library file entry in the ordered set where mimeType = &#63;.
3445             *
3446             * @param mimeType the mime type
3447             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3448             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
3449             */
3450            @Override
3451            public DLFileEntry fetchByMimeType_First(String mimeType,
3452                    OrderByComparator<DLFileEntry> orderByComparator) {
3453                    List<DLFileEntry> list = findByMimeType(mimeType, 0, 1,
3454                                    orderByComparator);
3455    
3456                    if (!list.isEmpty()) {
3457                            return list.get(0);
3458                    }
3459    
3460                    return null;
3461            }
3462    
3463            /**
3464             * Returns the last document library file entry in the ordered set where mimeType = &#63;.
3465             *
3466             * @param mimeType the mime type
3467             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3468             * @return the last matching document library file entry
3469             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
3470             */
3471            @Override
3472            public DLFileEntry findByMimeType_Last(String mimeType,
3473                    OrderByComparator<DLFileEntry> orderByComparator)
3474                    throws NoSuchFileEntryException {
3475                    DLFileEntry dlFileEntry = fetchByMimeType_Last(mimeType,
3476                                    orderByComparator);
3477    
3478                    if (dlFileEntry != null) {
3479                            return dlFileEntry;
3480                    }
3481    
3482                    StringBundler msg = new StringBundler(4);
3483    
3484                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3485    
3486                    msg.append("mimeType=");
3487                    msg.append(mimeType);
3488    
3489                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3490    
3491                    throw new NoSuchFileEntryException(msg.toString());
3492            }
3493    
3494            /**
3495             * Returns the last document library file entry in the ordered set where mimeType = &#63;.
3496             *
3497             * @param mimeType the mime type
3498             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3499             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
3500             */
3501            @Override
3502            public DLFileEntry fetchByMimeType_Last(String mimeType,
3503                    OrderByComparator<DLFileEntry> orderByComparator) {
3504                    int count = countByMimeType(mimeType);
3505    
3506                    if (count == 0) {
3507                            return null;
3508                    }
3509    
3510                    List<DLFileEntry> list = findByMimeType(mimeType, count - 1, count,
3511                                    orderByComparator);
3512    
3513                    if (!list.isEmpty()) {
3514                            return list.get(0);
3515                    }
3516    
3517                    return null;
3518            }
3519    
3520            /**
3521             * Returns the document library file entries before and after the current document library file entry in the ordered set where mimeType = &#63;.
3522             *
3523             * @param fileEntryId the primary key of the current document library file entry
3524             * @param mimeType the mime type
3525             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3526             * @return the previous, current, and next document library file entry
3527             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
3528             */
3529            @Override
3530            public DLFileEntry[] findByMimeType_PrevAndNext(long fileEntryId,
3531                    String mimeType, OrderByComparator<DLFileEntry> orderByComparator)
3532                    throws NoSuchFileEntryException {
3533                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3534    
3535                    Session session = null;
3536    
3537                    try {
3538                            session = openSession();
3539    
3540                            DLFileEntry[] array = new DLFileEntryImpl[3];
3541    
3542                            array[0] = getByMimeType_PrevAndNext(session, dlFileEntry,
3543                                            mimeType, orderByComparator, true);
3544    
3545                            array[1] = dlFileEntry;
3546    
3547                            array[2] = getByMimeType_PrevAndNext(session, dlFileEntry,
3548                                            mimeType, orderByComparator, false);
3549    
3550                            return array;
3551                    }
3552                    catch (Exception e) {
3553                            throw processException(e);
3554                    }
3555                    finally {
3556                            closeSession(session);
3557                    }
3558            }
3559    
3560            protected DLFileEntry getByMimeType_PrevAndNext(Session session,
3561                    DLFileEntry dlFileEntry, String mimeType,
3562                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
3563                    StringBundler query = null;
3564    
3565                    if (orderByComparator != null) {
3566                            query = new StringBundler(6 +
3567                                            (orderByComparator.getOrderByFields().length * 6));
3568                    }
3569                    else {
3570                            query = new StringBundler(3);
3571                    }
3572    
3573                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3574    
3575                    boolean bindMimeType = false;
3576    
3577                    if (mimeType == null) {
3578                            query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_1);
3579                    }
3580                    else if (mimeType.equals(StringPool.BLANK)) {
3581                            query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_3);
3582                    }
3583                    else {
3584                            bindMimeType = true;
3585    
3586                            query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_2);
3587                    }
3588    
3589                    if (orderByComparator != null) {
3590                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3591    
3592                            if (orderByConditionFields.length > 0) {
3593                                    query.append(WHERE_AND);
3594                            }
3595    
3596                            for (int i = 0; i < orderByConditionFields.length; i++) {
3597                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3598                                    query.append(orderByConditionFields[i]);
3599    
3600                                    if ((i + 1) < orderByConditionFields.length) {
3601                                            if (orderByComparator.isAscending() ^ previous) {
3602                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3603                                            }
3604                                            else {
3605                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3606                                            }
3607                                    }
3608                                    else {
3609                                            if (orderByComparator.isAscending() ^ previous) {
3610                                                    query.append(WHERE_GREATER_THAN);
3611                                            }
3612                                            else {
3613                                                    query.append(WHERE_LESSER_THAN);
3614                                            }
3615                                    }
3616                            }
3617    
3618                            query.append(ORDER_BY_CLAUSE);
3619    
3620                            String[] orderByFields = orderByComparator.getOrderByFields();
3621    
3622                            for (int i = 0; i < orderByFields.length; i++) {
3623                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3624                                    query.append(orderByFields[i]);
3625    
3626                                    if ((i + 1) < orderByFields.length) {
3627                                            if (orderByComparator.isAscending() ^ previous) {
3628                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3629                                            }
3630                                            else {
3631                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3632                                            }
3633                                    }
3634                                    else {
3635                                            if (orderByComparator.isAscending() ^ previous) {
3636                                                    query.append(ORDER_BY_ASC);
3637                                            }
3638                                            else {
3639                                                    query.append(ORDER_BY_DESC);
3640                                            }
3641                                    }
3642                            }
3643                    }
3644                    else {
3645                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3646                    }
3647    
3648                    String sql = query.toString();
3649    
3650                    Query q = session.createQuery(sql);
3651    
3652                    q.setFirstResult(0);
3653                    q.setMaxResults(2);
3654    
3655                    QueryPos qPos = QueryPos.getInstance(q);
3656    
3657                    if (bindMimeType) {
3658                            qPos.add(mimeType);
3659                    }
3660    
3661                    if (orderByComparator != null) {
3662                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3663    
3664                            for (Object value : values) {
3665                                    qPos.add(value);
3666                            }
3667                    }
3668    
3669                    List<DLFileEntry> list = q.list();
3670    
3671                    if (list.size() == 2) {
3672                            return list.get(1);
3673                    }
3674                    else {
3675                            return null;
3676                    }
3677            }
3678    
3679            /**
3680             * Removes all the document library file entries where mimeType = &#63; from the database.
3681             *
3682             * @param mimeType the mime type
3683             */
3684            @Override
3685            public void removeByMimeType(String mimeType) {
3686                    for (DLFileEntry dlFileEntry : findByMimeType(mimeType,
3687                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3688                            remove(dlFileEntry);
3689                    }
3690            }
3691    
3692            /**
3693             * Returns the number of document library file entries where mimeType = &#63;.
3694             *
3695             * @param mimeType the mime type
3696             * @return the number of matching document library file entries
3697             */
3698            @Override
3699            public int countByMimeType(String mimeType) {
3700                    FinderPath finderPath = FINDER_PATH_COUNT_BY_MIMETYPE;
3701    
3702                    Object[] finderArgs = new Object[] { mimeType };
3703    
3704                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3705                                    this);
3706    
3707                    if (count == null) {
3708                            StringBundler query = new StringBundler(2);
3709    
3710                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
3711    
3712                            boolean bindMimeType = false;
3713    
3714                            if (mimeType == null) {
3715                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_1);
3716                            }
3717                            else if (mimeType.equals(StringPool.BLANK)) {
3718                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_3);
3719                            }
3720                            else {
3721                                    bindMimeType = true;
3722    
3723                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_2);
3724                            }
3725    
3726                            String sql = query.toString();
3727    
3728                            Session session = null;
3729    
3730                            try {
3731                                    session = openSession();
3732    
3733                                    Query q = session.createQuery(sql);
3734    
3735                                    QueryPos qPos = QueryPos.getInstance(q);
3736    
3737                                    if (bindMimeType) {
3738                                            qPos.add(mimeType);
3739                                    }
3740    
3741                                    count = (Long)q.uniqueResult();
3742    
3743                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3744                            }
3745                            catch (Exception e) {
3746                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3747    
3748                                    throw processException(e);
3749                            }
3750                            finally {
3751                                    closeSession(session);
3752                            }
3753                    }
3754    
3755                    return count.intValue();
3756            }
3757    
3758            private static final String _FINDER_COLUMN_MIMETYPE_MIMETYPE_1 = "dlFileEntry.mimeType IS NULL";
3759            private static final String _FINDER_COLUMN_MIMETYPE_MIMETYPE_2 = "dlFileEntry.mimeType = ?";
3760            private static final String _FINDER_COLUMN_MIMETYPE_MIMETYPE_3 = "(dlFileEntry.mimeType IS NULL OR dlFileEntry.mimeType = '')";
3761            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYTYPEID =
3762                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3763                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
3764                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileEntryTypeId",
3765                            new String[] {
3766                                    Long.class.getName(),
3767                                    
3768                            Integer.class.getName(), Integer.class.getName(),
3769                                    OrderByComparator.class.getName()
3770                            });
3771            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID =
3772                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3773                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
3774                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileEntryTypeId",
3775                            new String[] { Long.class.getName() },
3776                            DLFileEntryModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK |
3777                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
3778                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
3779            public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYTYPEID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3780                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3781                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3782                            "countByFileEntryTypeId", new String[] { Long.class.getName() });
3783    
3784            /**
3785             * Returns all the document library file entries where fileEntryTypeId = &#63;.
3786             *
3787             * @param fileEntryTypeId the file entry type ID
3788             * @return the matching document library file entries
3789             */
3790            @Override
3791            public List<DLFileEntry> findByFileEntryTypeId(long fileEntryTypeId) {
3792                    return findByFileEntryTypeId(fileEntryTypeId, QueryUtil.ALL_POS,
3793                            QueryUtil.ALL_POS, null);
3794            }
3795    
3796            /**
3797             * Returns a range of all the document library file entries where fileEntryTypeId = &#63;.
3798             *
3799             * <p>
3800             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
3801             * </p>
3802             *
3803             * @param fileEntryTypeId the file entry type ID
3804             * @param start the lower bound of the range of document library file entries
3805             * @param end the upper bound of the range of document library file entries (not inclusive)
3806             * @return the range of matching document library file entries
3807             */
3808            @Override
3809            public List<DLFileEntry> findByFileEntryTypeId(long fileEntryTypeId,
3810                    int start, int end) {
3811                    return findByFileEntryTypeId(fileEntryTypeId, start, end, null);
3812            }
3813    
3814            /**
3815             * Returns an ordered range of all the document library file entries where fileEntryTypeId = &#63;.
3816             *
3817             * <p>
3818             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
3819             * </p>
3820             *
3821             * @param fileEntryTypeId the file entry type ID
3822             * @param start the lower bound of the range of document library file entries
3823             * @param end the upper bound of the range of document library file entries (not inclusive)
3824             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3825             * @return the ordered range of matching document library file entries
3826             */
3827            @Override
3828            public List<DLFileEntry> findByFileEntryTypeId(long fileEntryTypeId,
3829                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
3830                    boolean pagination = true;
3831                    FinderPath finderPath = null;
3832                    Object[] finderArgs = null;
3833    
3834                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3835                                    (orderByComparator == null)) {
3836                            pagination = false;
3837                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID;
3838                            finderArgs = new Object[] { fileEntryTypeId };
3839                    }
3840                    else {
3841                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYTYPEID;
3842                            finderArgs = new Object[] {
3843                                            fileEntryTypeId,
3844                                            
3845                                            start, end, orderByComparator
3846                                    };
3847                    }
3848    
3849                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
3850                                    finderArgs, this);
3851    
3852                    if ((list != null) && !list.isEmpty()) {
3853                            for (DLFileEntry dlFileEntry : list) {
3854                                    if ((fileEntryTypeId != dlFileEntry.getFileEntryTypeId())) {
3855                                            list = null;
3856    
3857                                            break;
3858                                    }
3859                            }
3860                    }
3861    
3862                    if (list == null) {
3863                            StringBundler query = null;
3864    
3865                            if (orderByComparator != null) {
3866                                    query = new StringBundler(3 +
3867                                                    (orderByComparator.getOrderByFields().length * 3));
3868                            }
3869                            else {
3870                                    query = new StringBundler(3);
3871                            }
3872    
3873                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3874    
3875                            query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
3876    
3877                            if (orderByComparator != null) {
3878                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3879                                            orderByComparator);
3880                            }
3881                            else
3882                             if (pagination) {
3883                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3884                            }
3885    
3886                            String sql = query.toString();
3887    
3888                            Session session = null;
3889    
3890                            try {
3891                                    session = openSession();
3892    
3893                                    Query q = session.createQuery(sql);
3894    
3895                                    QueryPos qPos = QueryPos.getInstance(q);
3896    
3897                                    qPos.add(fileEntryTypeId);
3898    
3899                                    if (!pagination) {
3900                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3901                                                            start, end, false);
3902    
3903                                            Collections.sort(list);
3904    
3905                                            list = Collections.unmodifiableList(list);
3906                                    }
3907                                    else {
3908                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3909                                                            start, end);
3910                                    }
3911    
3912                                    cacheResult(list);
3913    
3914                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3915                            }
3916                            catch (Exception e) {
3917                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3918    
3919                                    throw processException(e);
3920                            }
3921                            finally {
3922                                    closeSession(session);
3923                            }
3924                    }
3925    
3926                    return list;
3927            }
3928    
3929            /**
3930             * Returns the first document library file entry in the ordered set where fileEntryTypeId = &#63;.
3931             *
3932             * @param fileEntryTypeId the file entry type ID
3933             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3934             * @return the first matching document library file entry
3935             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
3936             */
3937            @Override
3938            public DLFileEntry findByFileEntryTypeId_First(long fileEntryTypeId,
3939                    OrderByComparator<DLFileEntry> orderByComparator)
3940                    throws NoSuchFileEntryException {
3941                    DLFileEntry dlFileEntry = fetchByFileEntryTypeId_First(fileEntryTypeId,
3942                                    orderByComparator);
3943    
3944                    if (dlFileEntry != null) {
3945                            return dlFileEntry;
3946                    }
3947    
3948                    StringBundler msg = new StringBundler(4);
3949    
3950                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3951    
3952                    msg.append("fileEntryTypeId=");
3953                    msg.append(fileEntryTypeId);
3954    
3955                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3956    
3957                    throw new NoSuchFileEntryException(msg.toString());
3958            }
3959    
3960            /**
3961             * Returns the first document library file entry in the ordered set where fileEntryTypeId = &#63;.
3962             *
3963             * @param fileEntryTypeId the file entry type ID
3964             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3965             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
3966             */
3967            @Override
3968            public DLFileEntry fetchByFileEntryTypeId_First(long fileEntryTypeId,
3969                    OrderByComparator<DLFileEntry> orderByComparator) {
3970                    List<DLFileEntry> list = findByFileEntryTypeId(fileEntryTypeId, 0, 1,
3971                                    orderByComparator);
3972    
3973                    if (!list.isEmpty()) {
3974                            return list.get(0);
3975                    }
3976    
3977                    return null;
3978            }
3979    
3980            /**
3981             * Returns the last document library file entry in the ordered set where fileEntryTypeId = &#63;.
3982             *
3983             * @param fileEntryTypeId the file entry type ID
3984             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3985             * @return the last matching document library file entry
3986             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
3987             */
3988            @Override
3989            public DLFileEntry findByFileEntryTypeId_Last(long fileEntryTypeId,
3990                    OrderByComparator<DLFileEntry> orderByComparator)
3991                    throws NoSuchFileEntryException {
3992                    DLFileEntry dlFileEntry = fetchByFileEntryTypeId_Last(fileEntryTypeId,
3993                                    orderByComparator);
3994    
3995                    if (dlFileEntry != null) {
3996                            return dlFileEntry;
3997                    }
3998    
3999                    StringBundler msg = new StringBundler(4);
4000    
4001                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4002    
4003                    msg.append("fileEntryTypeId=");
4004                    msg.append(fileEntryTypeId);
4005    
4006                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4007    
4008                    throw new NoSuchFileEntryException(msg.toString());
4009            }
4010    
4011            /**
4012             * Returns the last document library file entry in the ordered set where fileEntryTypeId = &#63;.
4013             *
4014             * @param fileEntryTypeId the file entry type ID
4015             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4016             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
4017             */
4018            @Override
4019            public DLFileEntry fetchByFileEntryTypeId_Last(long fileEntryTypeId,
4020                    OrderByComparator<DLFileEntry> orderByComparator) {
4021                    int count = countByFileEntryTypeId(fileEntryTypeId);
4022    
4023                    if (count == 0) {
4024                            return null;
4025                    }
4026    
4027                    List<DLFileEntry> list = findByFileEntryTypeId(fileEntryTypeId,
4028                                    count - 1, count, orderByComparator);
4029    
4030                    if (!list.isEmpty()) {
4031                            return list.get(0);
4032                    }
4033    
4034                    return null;
4035            }
4036    
4037            /**
4038             * Returns the document library file entries before and after the current document library file entry in the ordered set where fileEntryTypeId = &#63;.
4039             *
4040             * @param fileEntryId the primary key of the current document library file entry
4041             * @param fileEntryTypeId the file entry type ID
4042             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4043             * @return the previous, current, and next document library file entry
4044             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
4045             */
4046            @Override
4047            public DLFileEntry[] findByFileEntryTypeId_PrevAndNext(long fileEntryId,
4048                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator)
4049                    throws NoSuchFileEntryException {
4050                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4051    
4052                    Session session = null;
4053    
4054                    try {
4055                            session = openSession();
4056    
4057                            DLFileEntry[] array = new DLFileEntryImpl[3];
4058    
4059                            array[0] = getByFileEntryTypeId_PrevAndNext(session, dlFileEntry,
4060                                            fileEntryTypeId, orderByComparator, true);
4061    
4062                            array[1] = dlFileEntry;
4063    
4064                            array[2] = getByFileEntryTypeId_PrevAndNext(session, dlFileEntry,
4065                                            fileEntryTypeId, orderByComparator, false);
4066    
4067                            return array;
4068                    }
4069                    catch (Exception e) {
4070                            throw processException(e);
4071                    }
4072                    finally {
4073                            closeSession(session);
4074                    }
4075            }
4076    
4077            protected DLFileEntry getByFileEntryTypeId_PrevAndNext(Session session,
4078                    DLFileEntry dlFileEntry, long fileEntryTypeId,
4079                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
4080                    StringBundler query = null;
4081    
4082                    if (orderByComparator != null) {
4083                            query = new StringBundler(6 +
4084                                            (orderByComparator.getOrderByFields().length * 6));
4085                    }
4086                    else {
4087                            query = new StringBundler(3);
4088                    }
4089    
4090                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4091    
4092                    query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
4093    
4094                    if (orderByComparator != null) {
4095                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4096    
4097                            if (orderByConditionFields.length > 0) {
4098                                    query.append(WHERE_AND);
4099                            }
4100    
4101                            for (int i = 0; i < orderByConditionFields.length; i++) {
4102                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4103                                    query.append(orderByConditionFields[i]);
4104    
4105                                    if ((i + 1) < orderByConditionFields.length) {
4106                                            if (orderByComparator.isAscending() ^ previous) {
4107                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4108                                            }
4109                                            else {
4110                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4111                                            }
4112                                    }
4113                                    else {
4114                                            if (orderByComparator.isAscending() ^ previous) {
4115                                                    query.append(WHERE_GREATER_THAN);
4116                                            }
4117                                            else {
4118                                                    query.append(WHERE_LESSER_THAN);
4119                                            }
4120                                    }
4121                            }
4122    
4123                            query.append(ORDER_BY_CLAUSE);
4124    
4125                            String[] orderByFields = orderByComparator.getOrderByFields();
4126    
4127                            for (int i = 0; i < orderByFields.length; i++) {
4128                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4129                                    query.append(orderByFields[i]);
4130    
4131                                    if ((i + 1) < orderByFields.length) {
4132                                            if (orderByComparator.isAscending() ^ previous) {
4133                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4134                                            }
4135                                            else {
4136                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4137                                            }
4138                                    }
4139                                    else {
4140                                            if (orderByComparator.isAscending() ^ previous) {
4141                                                    query.append(ORDER_BY_ASC);
4142                                            }
4143                                            else {
4144                                                    query.append(ORDER_BY_DESC);
4145                                            }
4146                                    }
4147                            }
4148                    }
4149                    else {
4150                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4151                    }
4152    
4153                    String sql = query.toString();
4154    
4155                    Query q = session.createQuery(sql);
4156    
4157                    q.setFirstResult(0);
4158                    q.setMaxResults(2);
4159    
4160                    QueryPos qPos = QueryPos.getInstance(q);
4161    
4162                    qPos.add(fileEntryTypeId);
4163    
4164                    if (orderByComparator != null) {
4165                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
4166    
4167                            for (Object value : values) {
4168                                    qPos.add(value);
4169                            }
4170                    }
4171    
4172                    List<DLFileEntry> list = q.list();
4173    
4174                    if (list.size() == 2) {
4175                            return list.get(1);
4176                    }
4177                    else {
4178                            return null;
4179                    }
4180            }
4181    
4182            /**
4183             * Removes all the document library file entries where fileEntryTypeId = &#63; from the database.
4184             *
4185             * @param fileEntryTypeId the file entry type ID
4186             */
4187            @Override
4188            public void removeByFileEntryTypeId(long fileEntryTypeId) {
4189                    for (DLFileEntry dlFileEntry : findByFileEntryTypeId(fileEntryTypeId,
4190                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4191                            remove(dlFileEntry);
4192                    }
4193            }
4194    
4195            /**
4196             * Returns the number of document library file entries where fileEntryTypeId = &#63;.
4197             *
4198             * @param fileEntryTypeId the file entry type ID
4199             * @return the number of matching document library file entries
4200             */
4201            @Override
4202            public int countByFileEntryTypeId(long fileEntryTypeId) {
4203                    FinderPath finderPath = FINDER_PATH_COUNT_BY_FILEENTRYTYPEID;
4204    
4205                    Object[] finderArgs = new Object[] { fileEntryTypeId };
4206    
4207                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4208                                    this);
4209    
4210                    if (count == null) {
4211                            StringBundler query = new StringBundler(2);
4212    
4213                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
4214    
4215                            query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
4216    
4217                            String sql = query.toString();
4218    
4219                            Session session = null;
4220    
4221                            try {
4222                                    session = openSession();
4223    
4224                                    Query q = session.createQuery(sql);
4225    
4226                                    QueryPos qPos = QueryPos.getInstance(q);
4227    
4228                                    qPos.add(fileEntryTypeId);
4229    
4230                                    count = (Long)q.uniqueResult();
4231    
4232                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4233                            }
4234                            catch (Exception e) {
4235                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4236    
4237                                    throw processException(e);
4238                            }
4239                            finally {
4240                                    closeSession(session);
4241                            }
4242                    }
4243    
4244                    return count.intValue();
4245            }
4246    
4247            private static final String _FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2 =
4248                    "dlFileEntry.fileEntryTypeId = ?";
4249            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
4250                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
4251                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U",
4252                            new String[] {
4253                                    Long.class.getName(), Long.class.getName(),
4254                                    
4255                            Integer.class.getName(), Integer.class.getName(),
4256                                    OrderByComparator.class.getName()
4257                            });
4258            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
4259                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
4260                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
4261                            new String[] { Long.class.getName(), Long.class.getName() },
4262                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
4263                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK |
4264                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
4265                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
4266            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
4267                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4268                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
4269                            new String[] { Long.class.getName(), Long.class.getName() });
4270    
4271            /**
4272             * Returns all the document library file entries where groupId = &#63; and userId = &#63;.
4273             *
4274             * @param groupId the group ID
4275             * @param userId the user ID
4276             * @return the matching document library file entries
4277             */
4278            @Override
4279            public List<DLFileEntry> findByG_U(long groupId, long userId) {
4280                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4281                            null);
4282            }
4283    
4284            /**
4285             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63;.
4286             *
4287             * <p>
4288             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
4289             * </p>
4290             *
4291             * @param groupId the group ID
4292             * @param userId the user ID
4293             * @param start the lower bound of the range of document library file entries
4294             * @param end the upper bound of the range of document library file entries (not inclusive)
4295             * @return the range of matching document library file entries
4296             */
4297            @Override
4298            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
4299                    int end) {
4300                    return findByG_U(groupId, userId, start, end, null);
4301            }
4302    
4303            /**
4304             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63;.
4305             *
4306             * <p>
4307             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
4308             * </p>
4309             *
4310             * @param groupId the group ID
4311             * @param userId the user ID
4312             * @param start the lower bound of the range of document library file entries
4313             * @param end the upper bound of the range of document library file entries (not inclusive)
4314             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4315             * @return the ordered range of matching document library file entries
4316             */
4317            @Override
4318            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
4319                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
4320                    boolean pagination = true;
4321                    FinderPath finderPath = null;
4322                    Object[] finderArgs = null;
4323    
4324                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4325                                    (orderByComparator == null)) {
4326                            pagination = false;
4327                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
4328                            finderArgs = new Object[] { groupId, userId };
4329                    }
4330                    else {
4331                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
4332                            finderArgs = new Object[] {
4333                                            groupId, userId,
4334                                            
4335                                            start, end, orderByComparator
4336                                    };
4337                    }
4338    
4339                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
4340                                    finderArgs, this);
4341    
4342                    if ((list != null) && !list.isEmpty()) {
4343                            for (DLFileEntry dlFileEntry : list) {
4344                                    if ((groupId != dlFileEntry.getGroupId()) ||
4345                                                    (userId != dlFileEntry.getUserId())) {
4346                                            list = null;
4347    
4348                                            break;
4349                                    }
4350                            }
4351                    }
4352    
4353                    if (list == null) {
4354                            StringBundler query = null;
4355    
4356                            if (orderByComparator != null) {
4357                                    query = new StringBundler(4 +
4358                                                    (orderByComparator.getOrderByFields().length * 3));
4359                            }
4360                            else {
4361                                    query = new StringBundler(4);
4362                            }
4363    
4364                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4365    
4366                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4367    
4368                            query.append(_FINDER_COLUMN_G_U_USERID_2);
4369    
4370                            if (orderByComparator != null) {
4371                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4372                                            orderByComparator);
4373                            }
4374                            else
4375                             if (pagination) {
4376                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4377                            }
4378    
4379                            String sql = query.toString();
4380    
4381                            Session session = null;
4382    
4383                            try {
4384                                    session = openSession();
4385    
4386                                    Query q = session.createQuery(sql);
4387    
4388                                    QueryPos qPos = QueryPos.getInstance(q);
4389    
4390                                    qPos.add(groupId);
4391    
4392                                    qPos.add(userId);
4393    
4394                                    if (!pagination) {
4395                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4396                                                            start, end, false);
4397    
4398                                            Collections.sort(list);
4399    
4400                                            list = Collections.unmodifiableList(list);
4401                                    }
4402                                    else {
4403                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4404                                                            start, end);
4405                                    }
4406    
4407                                    cacheResult(list);
4408    
4409                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4410                            }
4411                            catch (Exception e) {
4412                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4413    
4414                                    throw processException(e);
4415                            }
4416                            finally {
4417                                    closeSession(session);
4418                            }
4419                    }
4420    
4421                    return list;
4422            }
4423    
4424            /**
4425             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4426             *
4427             * @param groupId the group ID
4428             * @param userId the user ID
4429             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4430             * @return the first matching document library file entry
4431             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
4432             */
4433            @Override
4434            public DLFileEntry findByG_U_First(long groupId, long userId,
4435                    OrderByComparator<DLFileEntry> orderByComparator)
4436                    throws NoSuchFileEntryException {
4437                    DLFileEntry dlFileEntry = fetchByG_U_First(groupId, userId,
4438                                    orderByComparator);
4439    
4440                    if (dlFileEntry != null) {
4441                            return dlFileEntry;
4442                    }
4443    
4444                    StringBundler msg = new StringBundler(6);
4445    
4446                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4447    
4448                    msg.append("groupId=");
4449                    msg.append(groupId);
4450    
4451                    msg.append(", userId=");
4452                    msg.append(userId);
4453    
4454                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4455    
4456                    throw new NoSuchFileEntryException(msg.toString());
4457            }
4458    
4459            /**
4460             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4461             *
4462             * @param groupId the group ID
4463             * @param userId the user ID
4464             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4465             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
4466             */
4467            @Override
4468            public DLFileEntry fetchByG_U_First(long groupId, long userId,
4469                    OrderByComparator<DLFileEntry> orderByComparator) {
4470                    List<DLFileEntry> list = findByG_U(groupId, userId, 0, 1,
4471                                    orderByComparator);
4472    
4473                    if (!list.isEmpty()) {
4474                            return list.get(0);
4475                    }
4476    
4477                    return null;
4478            }
4479    
4480            /**
4481             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4482             *
4483             * @param groupId the group ID
4484             * @param userId the user ID
4485             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4486             * @return the last matching document library file entry
4487             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
4488             */
4489            @Override
4490            public DLFileEntry findByG_U_Last(long groupId, long userId,
4491                    OrderByComparator<DLFileEntry> orderByComparator)
4492                    throws NoSuchFileEntryException {
4493                    DLFileEntry dlFileEntry = fetchByG_U_Last(groupId, userId,
4494                                    orderByComparator);
4495    
4496                    if (dlFileEntry != null) {
4497                            return dlFileEntry;
4498                    }
4499    
4500                    StringBundler msg = new StringBundler(6);
4501    
4502                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4503    
4504                    msg.append("groupId=");
4505                    msg.append(groupId);
4506    
4507                    msg.append(", userId=");
4508                    msg.append(userId);
4509    
4510                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4511    
4512                    throw new NoSuchFileEntryException(msg.toString());
4513            }
4514    
4515            /**
4516             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4517             *
4518             * @param groupId the group ID
4519             * @param userId the user ID
4520             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4521             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
4522             */
4523            @Override
4524            public DLFileEntry fetchByG_U_Last(long groupId, long userId,
4525                    OrderByComparator<DLFileEntry> orderByComparator) {
4526                    int count = countByG_U(groupId, userId);
4527    
4528                    if (count == 0) {
4529                            return null;
4530                    }
4531    
4532                    List<DLFileEntry> list = findByG_U(groupId, userId, count - 1, count,
4533                                    orderByComparator);
4534    
4535                    if (!list.isEmpty()) {
4536                            return list.get(0);
4537                    }
4538    
4539                    return null;
4540            }
4541    
4542            /**
4543             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4544             *
4545             * @param fileEntryId the primary key of the current document library file entry
4546             * @param groupId the group ID
4547             * @param userId the user ID
4548             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4549             * @return the previous, current, and next document library file entry
4550             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
4551             */
4552            @Override
4553            public DLFileEntry[] findByG_U_PrevAndNext(long fileEntryId, long groupId,
4554                    long userId, OrderByComparator<DLFileEntry> orderByComparator)
4555                    throws NoSuchFileEntryException {
4556                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4557    
4558                    Session session = null;
4559    
4560                    try {
4561                            session = openSession();
4562    
4563                            DLFileEntry[] array = new DLFileEntryImpl[3];
4564    
4565                            array[0] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
4566                                            userId, orderByComparator, true);
4567    
4568                            array[1] = dlFileEntry;
4569    
4570                            array[2] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
4571                                            userId, orderByComparator, false);
4572    
4573                            return array;
4574                    }
4575                    catch (Exception e) {
4576                            throw processException(e);
4577                    }
4578                    finally {
4579                            closeSession(session);
4580                    }
4581            }
4582    
4583            protected DLFileEntry getByG_U_PrevAndNext(Session session,
4584                    DLFileEntry dlFileEntry, long groupId, long userId,
4585                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
4586                    StringBundler query = null;
4587    
4588                    if (orderByComparator != null) {
4589                            query = new StringBundler(6 +
4590                                            (orderByComparator.getOrderByFields().length * 6));
4591                    }
4592                    else {
4593                            query = new StringBundler(3);
4594                    }
4595    
4596                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4597    
4598                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4599    
4600                    query.append(_FINDER_COLUMN_G_U_USERID_2);
4601    
4602                    if (orderByComparator != null) {
4603                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4604    
4605                            if (orderByConditionFields.length > 0) {
4606                                    query.append(WHERE_AND);
4607                            }
4608    
4609                            for (int i = 0; i < orderByConditionFields.length; i++) {
4610                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4611                                    query.append(orderByConditionFields[i]);
4612    
4613                                    if ((i + 1) < orderByConditionFields.length) {
4614                                            if (orderByComparator.isAscending() ^ previous) {
4615                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4616                                            }
4617                                            else {
4618                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4619                                            }
4620                                    }
4621                                    else {
4622                                            if (orderByComparator.isAscending() ^ previous) {
4623                                                    query.append(WHERE_GREATER_THAN);
4624                                            }
4625                                            else {
4626                                                    query.append(WHERE_LESSER_THAN);
4627                                            }
4628                                    }
4629                            }
4630    
4631                            query.append(ORDER_BY_CLAUSE);
4632    
4633                            String[] orderByFields = orderByComparator.getOrderByFields();
4634    
4635                            for (int i = 0; i < orderByFields.length; i++) {
4636                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4637                                    query.append(orderByFields[i]);
4638    
4639                                    if ((i + 1) < orderByFields.length) {
4640                                            if (orderByComparator.isAscending() ^ previous) {
4641                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4642                                            }
4643                                            else {
4644                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4645                                            }
4646                                    }
4647                                    else {
4648                                            if (orderByComparator.isAscending() ^ previous) {
4649                                                    query.append(ORDER_BY_ASC);
4650                                            }
4651                                            else {
4652                                                    query.append(ORDER_BY_DESC);
4653                                            }
4654                                    }
4655                            }
4656                    }
4657                    else {
4658                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4659                    }
4660    
4661                    String sql = query.toString();
4662    
4663                    Query q = session.createQuery(sql);
4664    
4665                    q.setFirstResult(0);
4666                    q.setMaxResults(2);
4667    
4668                    QueryPos qPos = QueryPos.getInstance(q);
4669    
4670                    qPos.add(groupId);
4671    
4672                    qPos.add(userId);
4673    
4674                    if (orderByComparator != null) {
4675                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
4676    
4677                            for (Object value : values) {
4678                                    qPos.add(value);
4679                            }
4680                    }
4681    
4682                    List<DLFileEntry> list = q.list();
4683    
4684                    if (list.size() == 2) {
4685                            return list.get(1);
4686                    }
4687                    else {
4688                            return null;
4689                    }
4690            }
4691    
4692            /**
4693             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
4694             *
4695             * @param groupId the group ID
4696             * @param userId the user ID
4697             * @return the matching document library file entries that the user has permission to view
4698             */
4699            @Override
4700            public List<DLFileEntry> filterFindByG_U(long groupId, long userId) {
4701                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
4702                            QueryUtil.ALL_POS, null);
4703            }
4704    
4705            /**
4706             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
4707             *
4708             * <p>
4709             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
4710             * </p>
4711             *
4712             * @param groupId the group ID
4713             * @param userId the user ID
4714             * @param start the lower bound of the range of document library file entries
4715             * @param end the upper bound of the range of document library file entries (not inclusive)
4716             * @return the range of matching document library file entries that the user has permission to view
4717             */
4718            @Override
4719            public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
4720                    int start, int end) {
4721                    return filterFindByG_U(groupId, userId, start, end, null);
4722            }
4723    
4724            /**
4725             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and userId = &#63;.
4726             *
4727             * <p>
4728             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
4729             * </p>
4730             *
4731             * @param groupId the group ID
4732             * @param userId the user ID
4733             * @param start the lower bound of the range of document library file entries
4734             * @param end the upper bound of the range of document library file entries (not inclusive)
4735             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4736             * @return the ordered range of matching document library file entries that the user has permission to view
4737             */
4738            @Override
4739            public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
4740                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
4741                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4742                            return findByG_U(groupId, userId, start, end, orderByComparator);
4743                    }
4744    
4745                    StringBundler query = null;
4746    
4747                    if (orderByComparator != null) {
4748                            query = new StringBundler(4 +
4749                                            (orderByComparator.getOrderByFields().length * 3));
4750                    }
4751                    else {
4752                            query = new StringBundler(4);
4753                    }
4754    
4755                    if (getDB().isSupportsInlineDistinct()) {
4756                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4757                    }
4758                    else {
4759                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4760                    }
4761    
4762                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4763    
4764                    query.append(_FINDER_COLUMN_G_U_USERID_2);
4765    
4766                    if (!getDB().isSupportsInlineDistinct()) {
4767                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4768                    }
4769    
4770                    if (orderByComparator != null) {
4771                            if (getDB().isSupportsInlineDistinct()) {
4772                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4773                                            orderByComparator, true);
4774                            }
4775                            else {
4776                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4777                                            orderByComparator, true);
4778                            }
4779                    }
4780                    else {
4781                            if (getDB().isSupportsInlineDistinct()) {
4782                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4783                            }
4784                            else {
4785                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
4786                            }
4787                    }
4788    
4789                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4790                                    DLFileEntry.class.getName(),
4791                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4792    
4793                    Session session = null;
4794    
4795                    try {
4796                            session = openSession();
4797    
4798                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4799    
4800                            if (getDB().isSupportsInlineDistinct()) {
4801                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
4802                            }
4803                            else {
4804                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
4805                            }
4806    
4807                            QueryPos qPos = QueryPos.getInstance(q);
4808    
4809                            qPos.add(groupId);
4810    
4811                            qPos.add(userId);
4812    
4813                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
4814                    }
4815                    catch (Exception e) {
4816                            throw processException(e);
4817                    }
4818                    finally {
4819                            closeSession(session);
4820                    }
4821            }
4822    
4823            /**
4824             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
4825             *
4826             * @param fileEntryId the primary key of the current document library file entry
4827             * @param groupId the group ID
4828             * @param userId the user ID
4829             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4830             * @return the previous, current, and next document library file entry
4831             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
4832             */
4833            @Override
4834            public DLFileEntry[] filterFindByG_U_PrevAndNext(long fileEntryId,
4835                    long groupId, long userId,
4836                    OrderByComparator<DLFileEntry> orderByComparator)
4837                    throws NoSuchFileEntryException {
4838                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4839                            return findByG_U_PrevAndNext(fileEntryId, groupId, userId,
4840                                    orderByComparator);
4841                    }
4842    
4843                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4844    
4845                    Session session = null;
4846    
4847                    try {
4848                            session = openSession();
4849    
4850                            DLFileEntry[] array = new DLFileEntryImpl[3];
4851    
4852                            array[0] = filterGetByG_U_PrevAndNext(session, dlFileEntry,
4853                                            groupId, userId, orderByComparator, true);
4854    
4855                            array[1] = dlFileEntry;
4856    
4857                            array[2] = filterGetByG_U_PrevAndNext(session, dlFileEntry,
4858                                            groupId, userId, orderByComparator, false);
4859    
4860                            return array;
4861                    }
4862                    catch (Exception e) {
4863                            throw processException(e);
4864                    }
4865                    finally {
4866                            closeSession(session);
4867                    }
4868            }
4869    
4870            protected DLFileEntry filterGetByG_U_PrevAndNext(Session session,
4871                    DLFileEntry dlFileEntry, long groupId, long userId,
4872                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
4873                    StringBundler query = null;
4874    
4875                    if (orderByComparator != null) {
4876                            query = new StringBundler(6 +
4877                                            (orderByComparator.getOrderByFields().length * 6));
4878                    }
4879                    else {
4880                            query = new StringBundler(3);
4881                    }
4882    
4883                    if (getDB().isSupportsInlineDistinct()) {
4884                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4885                    }
4886                    else {
4887                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4888                    }
4889    
4890                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4891    
4892                    query.append(_FINDER_COLUMN_G_U_USERID_2);
4893    
4894                    if (!getDB().isSupportsInlineDistinct()) {
4895                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4896                    }
4897    
4898                    if (orderByComparator != null) {
4899                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4900    
4901                            if (orderByConditionFields.length > 0) {
4902                                    query.append(WHERE_AND);
4903                            }
4904    
4905                            for (int i = 0; i < orderByConditionFields.length; i++) {
4906                                    if (getDB().isSupportsInlineDistinct()) {
4907                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4908                                    }
4909                                    else {
4910                                            query.append(_ORDER_BY_ENTITY_TABLE);
4911                                    }
4912    
4913                                    query.append(orderByConditionFields[i]);
4914    
4915                                    if ((i + 1) < orderByConditionFields.length) {
4916                                            if (orderByComparator.isAscending() ^ previous) {
4917                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4918                                            }
4919                                            else {
4920                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4921                                            }
4922                                    }
4923                                    else {
4924                                            if (orderByComparator.isAscending() ^ previous) {
4925                                                    query.append(WHERE_GREATER_THAN);
4926                                            }
4927                                            else {
4928                                                    query.append(WHERE_LESSER_THAN);
4929                                            }
4930                                    }
4931                            }
4932    
4933                            query.append(ORDER_BY_CLAUSE);
4934    
4935                            String[] orderByFields = orderByComparator.getOrderByFields();
4936    
4937                            for (int i = 0; i < orderByFields.length; i++) {
4938                                    if (getDB().isSupportsInlineDistinct()) {
4939                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4940                                    }
4941                                    else {
4942                                            query.append(_ORDER_BY_ENTITY_TABLE);
4943                                    }
4944    
4945                                    query.append(orderByFields[i]);
4946    
4947                                    if ((i + 1) < orderByFields.length) {
4948                                            if (orderByComparator.isAscending() ^ previous) {
4949                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4950                                            }
4951                                            else {
4952                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4953                                            }
4954                                    }
4955                                    else {
4956                                            if (orderByComparator.isAscending() ^ previous) {
4957                                                    query.append(ORDER_BY_ASC);
4958                                            }
4959                                            else {
4960                                                    query.append(ORDER_BY_DESC);
4961                                            }
4962                                    }
4963                            }
4964                    }
4965                    else {
4966                            if (getDB().isSupportsInlineDistinct()) {
4967                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4968                            }
4969                            else {
4970                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
4971                            }
4972                    }
4973    
4974                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4975                                    DLFileEntry.class.getName(),
4976                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4977    
4978                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4979    
4980                    q.setFirstResult(0);
4981                    q.setMaxResults(2);
4982    
4983                    if (getDB().isSupportsInlineDistinct()) {
4984                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
4985                    }
4986                    else {
4987                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
4988                    }
4989    
4990                    QueryPos qPos = QueryPos.getInstance(q);
4991    
4992                    qPos.add(groupId);
4993    
4994                    qPos.add(userId);
4995    
4996                    if (orderByComparator != null) {
4997                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
4998    
4999                            for (Object value : values) {
5000                                    qPos.add(value);
5001                            }
5002                    }
5003    
5004                    List<DLFileEntry> list = q.list();
5005    
5006                    if (list.size() == 2) {
5007                            return list.get(1);
5008                    }
5009                    else {
5010                            return null;
5011                    }
5012            }
5013    
5014            /**
5015             * Removes all the document library file entries where groupId = &#63; and userId = &#63; from the database.
5016             *
5017             * @param groupId the group ID
5018             * @param userId the user ID
5019             */
5020            @Override
5021            public void removeByG_U(long groupId, long userId) {
5022                    for (DLFileEntry dlFileEntry : findByG_U(groupId, userId,
5023                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5024                            remove(dlFileEntry);
5025                    }
5026            }
5027    
5028            /**
5029             * Returns the number of document library file entries where groupId = &#63; and userId = &#63;.
5030             *
5031             * @param groupId the group ID
5032             * @param userId the user ID
5033             * @return the number of matching document library file entries
5034             */
5035            @Override
5036            public int countByG_U(long groupId, long userId) {
5037                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
5038    
5039                    Object[] finderArgs = new Object[] { groupId, userId };
5040    
5041                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5042                                    this);
5043    
5044                    if (count == null) {
5045                            StringBundler query = new StringBundler(3);
5046    
5047                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
5048    
5049                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
5050    
5051                            query.append(_FINDER_COLUMN_G_U_USERID_2);
5052    
5053                            String sql = query.toString();
5054    
5055                            Session session = null;
5056    
5057                            try {
5058                                    session = openSession();
5059    
5060                                    Query q = session.createQuery(sql);
5061    
5062                                    QueryPos qPos = QueryPos.getInstance(q);
5063    
5064                                    qPos.add(groupId);
5065    
5066                                    qPos.add(userId);
5067    
5068                                    count = (Long)q.uniqueResult();
5069    
5070                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5071                            }
5072                            catch (Exception e) {
5073                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5074    
5075                                    throw processException(e);
5076                            }
5077                            finally {
5078                                    closeSession(session);
5079                            }
5080                    }
5081    
5082                    return count.intValue();
5083            }
5084    
5085            /**
5086             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
5087             *
5088             * @param groupId the group ID
5089             * @param userId the user ID
5090             * @return the number of matching document library file entries that the user has permission to view
5091             */
5092            @Override
5093            public int filterCountByG_U(long groupId, long userId) {
5094                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5095                            return countByG_U(groupId, userId);
5096                    }
5097    
5098                    StringBundler query = new StringBundler(3);
5099    
5100                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
5101    
5102                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
5103    
5104                    query.append(_FINDER_COLUMN_G_U_USERID_2);
5105    
5106                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5107                                    DLFileEntry.class.getName(),
5108                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5109    
5110                    Session session = null;
5111    
5112                    try {
5113                            session = openSession();
5114    
5115                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5116    
5117                            q.addScalar(COUNT_COLUMN_NAME,
5118                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5119    
5120                            QueryPos qPos = QueryPos.getInstance(q);
5121    
5122                            qPos.add(groupId);
5123    
5124                            qPos.add(userId);
5125    
5126                            Long count = (Long)q.uniqueResult();
5127    
5128                            return count.intValue();
5129                    }
5130                    catch (Exception e) {
5131                            throw processException(e);
5132                    }
5133                    finally {
5134                            closeSession(session);
5135                    }
5136            }
5137    
5138            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
5139            private static final String _FINDER_COLUMN_G_U_USERID_2 = "dlFileEntry.userId = ?";
5140            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
5141                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
5142                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F",
5143                            new String[] {
5144                                    Long.class.getName(), Long.class.getName(),
5145                                    
5146                            Integer.class.getName(), Integer.class.getName(),
5147                                    OrderByComparator.class.getName()
5148                            });
5149            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
5150                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
5151                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
5152                            new String[] { Long.class.getName(), Long.class.getName() },
5153                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
5154                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
5155                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
5156            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
5157                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5158                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
5159                            new String[] { Long.class.getName(), Long.class.getName() });
5160            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
5161                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5162                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
5163                            new String[] { Long.class.getName(), Long.class.getName() });
5164    
5165            /**
5166             * Returns all the document library file entries where groupId = &#63; and folderId = &#63;.
5167             *
5168             * @param groupId the group ID
5169             * @param folderId the folder ID
5170             * @return the matching document library file entries
5171             */
5172            @Override
5173            public List<DLFileEntry> findByG_F(long groupId, long folderId) {
5174                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
5175                            QueryUtil.ALL_POS, null);
5176            }
5177    
5178            /**
5179             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63;.
5180             *
5181             * <p>
5182             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
5183             * </p>
5184             *
5185             * @param groupId the group ID
5186             * @param folderId the folder ID
5187             * @param start the lower bound of the range of document library file entries
5188             * @param end the upper bound of the range of document library file entries (not inclusive)
5189             * @return the range of matching document library file entries
5190             */
5191            @Override
5192            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
5193                    int end) {
5194                    return findByG_F(groupId, folderId, start, end, null);
5195            }
5196    
5197            /**
5198             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63;.
5199             *
5200             * <p>
5201             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
5202             * </p>
5203             *
5204             * @param groupId the group ID
5205             * @param folderId the folder ID
5206             * @param start the lower bound of the range of document library file entries
5207             * @param end the upper bound of the range of document library file entries (not inclusive)
5208             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5209             * @return the ordered range of matching document library file entries
5210             */
5211            @Override
5212            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
5213                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
5214                    boolean pagination = true;
5215                    FinderPath finderPath = null;
5216                    Object[] finderArgs = null;
5217    
5218                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5219                                    (orderByComparator == null)) {
5220                            pagination = false;
5221                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
5222                            finderArgs = new Object[] { groupId, folderId };
5223                    }
5224                    else {
5225                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
5226                            finderArgs = new Object[] {
5227                                            groupId, folderId,
5228                                            
5229                                            start, end, orderByComparator
5230                                    };
5231                    }
5232    
5233                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
5234                                    finderArgs, this);
5235    
5236                    if ((list != null) && !list.isEmpty()) {
5237                            for (DLFileEntry dlFileEntry : list) {
5238                                    if ((groupId != dlFileEntry.getGroupId()) ||
5239                                                    (folderId != dlFileEntry.getFolderId())) {
5240                                            list = null;
5241    
5242                                            break;
5243                                    }
5244                            }
5245                    }
5246    
5247                    if (list == null) {
5248                            StringBundler query = null;
5249    
5250                            if (orderByComparator != null) {
5251                                    query = new StringBundler(4 +
5252                                                    (orderByComparator.getOrderByFields().length * 3));
5253                            }
5254                            else {
5255                                    query = new StringBundler(4);
5256                            }
5257    
5258                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5259    
5260                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5261    
5262                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
5263    
5264                            if (orderByComparator != null) {
5265                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5266                                            orderByComparator);
5267                            }
5268                            else
5269                             if (pagination) {
5270                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5271                            }
5272    
5273                            String sql = query.toString();
5274    
5275                            Session session = null;
5276    
5277                            try {
5278                                    session = openSession();
5279    
5280                                    Query q = session.createQuery(sql);
5281    
5282                                    QueryPos qPos = QueryPos.getInstance(q);
5283    
5284                                    qPos.add(groupId);
5285    
5286                                    qPos.add(folderId);
5287    
5288                                    if (!pagination) {
5289                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
5290                                                            start, end, false);
5291    
5292                                            Collections.sort(list);
5293    
5294                                            list = Collections.unmodifiableList(list);
5295                                    }
5296                                    else {
5297                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
5298                                                            start, end);
5299                                    }
5300    
5301                                    cacheResult(list);
5302    
5303                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5304                            }
5305                            catch (Exception e) {
5306                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5307    
5308                                    throw processException(e);
5309                            }
5310                            finally {
5311                                    closeSession(session);
5312                            }
5313                    }
5314    
5315                    return list;
5316            }
5317    
5318            /**
5319             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
5320             *
5321             * @param groupId the group ID
5322             * @param folderId the folder ID
5323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5324             * @return the first matching document library file entry
5325             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
5326             */
5327            @Override
5328            public DLFileEntry findByG_F_First(long groupId, long folderId,
5329                    OrderByComparator<DLFileEntry> orderByComparator)
5330                    throws NoSuchFileEntryException {
5331                    DLFileEntry dlFileEntry = fetchByG_F_First(groupId, folderId,
5332                                    orderByComparator);
5333    
5334                    if (dlFileEntry != null) {
5335                            return dlFileEntry;
5336                    }
5337    
5338                    StringBundler msg = new StringBundler(6);
5339    
5340                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5341    
5342                    msg.append("groupId=");
5343                    msg.append(groupId);
5344    
5345                    msg.append(", folderId=");
5346                    msg.append(folderId);
5347    
5348                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5349    
5350                    throw new NoSuchFileEntryException(msg.toString());
5351            }
5352    
5353            /**
5354             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
5355             *
5356             * @param groupId the group ID
5357             * @param folderId the folder ID
5358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5359             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5360             */
5361            @Override
5362            public DLFileEntry fetchByG_F_First(long groupId, long folderId,
5363                    OrderByComparator<DLFileEntry> orderByComparator) {
5364                    List<DLFileEntry> list = findByG_F(groupId, folderId, 0, 1,
5365                                    orderByComparator);
5366    
5367                    if (!list.isEmpty()) {
5368                            return list.get(0);
5369                    }
5370    
5371                    return null;
5372            }
5373    
5374            /**
5375             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
5376             *
5377             * @param groupId the group ID
5378             * @param folderId the folder ID
5379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5380             * @return the last matching document library file entry
5381             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
5382             */
5383            @Override
5384            public DLFileEntry findByG_F_Last(long groupId, long folderId,
5385                    OrderByComparator<DLFileEntry> orderByComparator)
5386                    throws NoSuchFileEntryException {
5387                    DLFileEntry dlFileEntry = fetchByG_F_Last(groupId, folderId,
5388                                    orderByComparator);
5389    
5390                    if (dlFileEntry != null) {
5391                            return dlFileEntry;
5392                    }
5393    
5394                    StringBundler msg = new StringBundler(6);
5395    
5396                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5397    
5398                    msg.append("groupId=");
5399                    msg.append(groupId);
5400    
5401                    msg.append(", folderId=");
5402                    msg.append(folderId);
5403    
5404                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5405    
5406                    throw new NoSuchFileEntryException(msg.toString());
5407            }
5408    
5409            /**
5410             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
5411             *
5412             * @param groupId the group ID
5413             * @param folderId the folder ID
5414             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5415             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5416             */
5417            @Override
5418            public DLFileEntry fetchByG_F_Last(long groupId, long folderId,
5419                    OrderByComparator<DLFileEntry> orderByComparator) {
5420                    int count = countByG_F(groupId, folderId);
5421    
5422                    if (count == 0) {
5423                            return null;
5424                    }
5425    
5426                    List<DLFileEntry> list = findByG_F(groupId, folderId, count - 1, count,
5427                                    orderByComparator);
5428    
5429                    if (!list.isEmpty()) {
5430                            return list.get(0);
5431                    }
5432    
5433                    return null;
5434            }
5435    
5436            /**
5437             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
5438             *
5439             * @param fileEntryId the primary key of the current document library file entry
5440             * @param groupId the group ID
5441             * @param folderId the folder ID
5442             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5443             * @return the previous, current, and next document library file entry
5444             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
5445             */
5446            @Override
5447            public DLFileEntry[] findByG_F_PrevAndNext(long fileEntryId, long groupId,
5448                    long folderId, OrderByComparator<DLFileEntry> orderByComparator)
5449                    throws NoSuchFileEntryException {
5450                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
5451    
5452                    Session session = null;
5453    
5454                    try {
5455                            session = openSession();
5456    
5457                            DLFileEntry[] array = new DLFileEntryImpl[3];
5458    
5459                            array[0] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
5460                                            folderId, orderByComparator, true);
5461    
5462                            array[1] = dlFileEntry;
5463    
5464                            array[2] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
5465                                            folderId, orderByComparator, false);
5466    
5467                            return array;
5468                    }
5469                    catch (Exception e) {
5470                            throw processException(e);
5471                    }
5472                    finally {
5473                            closeSession(session);
5474                    }
5475            }
5476    
5477            protected DLFileEntry getByG_F_PrevAndNext(Session session,
5478                    DLFileEntry dlFileEntry, long groupId, long folderId,
5479                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
5480                    StringBundler query = null;
5481    
5482                    if (orderByComparator != null) {
5483                            query = new StringBundler(6 +
5484                                            (orderByComparator.getOrderByFields().length * 6));
5485                    }
5486                    else {
5487                            query = new StringBundler(3);
5488                    }
5489    
5490                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5491    
5492                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5493    
5494                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
5495    
5496                    if (orderByComparator != null) {
5497                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5498    
5499                            if (orderByConditionFields.length > 0) {
5500                                    query.append(WHERE_AND);
5501                            }
5502    
5503                            for (int i = 0; i < orderByConditionFields.length; i++) {
5504                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5505                                    query.append(orderByConditionFields[i]);
5506    
5507                                    if ((i + 1) < orderByConditionFields.length) {
5508                                            if (orderByComparator.isAscending() ^ previous) {
5509                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5510                                            }
5511                                            else {
5512                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5513                                            }
5514                                    }
5515                                    else {
5516                                            if (orderByComparator.isAscending() ^ previous) {
5517                                                    query.append(WHERE_GREATER_THAN);
5518                                            }
5519                                            else {
5520                                                    query.append(WHERE_LESSER_THAN);
5521                                            }
5522                                    }
5523                            }
5524    
5525                            query.append(ORDER_BY_CLAUSE);
5526    
5527                            String[] orderByFields = orderByComparator.getOrderByFields();
5528    
5529                            for (int i = 0; i < orderByFields.length; i++) {
5530                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5531                                    query.append(orderByFields[i]);
5532    
5533                                    if ((i + 1) < orderByFields.length) {
5534                                            if (orderByComparator.isAscending() ^ previous) {
5535                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5536                                            }
5537                                            else {
5538                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5539                                            }
5540                                    }
5541                                    else {
5542                                            if (orderByComparator.isAscending() ^ previous) {
5543                                                    query.append(ORDER_BY_ASC);
5544                                            }
5545                                            else {
5546                                                    query.append(ORDER_BY_DESC);
5547                                            }
5548                                    }
5549                            }
5550                    }
5551                    else {
5552                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5553                    }
5554    
5555                    String sql = query.toString();
5556    
5557                    Query q = session.createQuery(sql);
5558    
5559                    q.setFirstResult(0);
5560                    q.setMaxResults(2);
5561    
5562                    QueryPos qPos = QueryPos.getInstance(q);
5563    
5564                    qPos.add(groupId);
5565    
5566                    qPos.add(folderId);
5567    
5568                    if (orderByComparator != null) {
5569                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
5570    
5571                            for (Object value : values) {
5572                                    qPos.add(value);
5573                            }
5574                    }
5575    
5576                    List<DLFileEntry> list = q.list();
5577    
5578                    if (list.size() == 2) {
5579                            return list.get(1);
5580                    }
5581                    else {
5582                            return null;
5583                    }
5584            }
5585    
5586            /**
5587             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
5588             *
5589             * @param groupId the group ID
5590             * @param folderId the folder ID
5591             * @return the matching document library file entries that the user has permission to view
5592             */
5593            @Override
5594            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId) {
5595                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
5596                            QueryUtil.ALL_POS, null);
5597            }
5598    
5599            /**
5600             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
5601             *
5602             * <p>
5603             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
5604             * </p>
5605             *
5606             * @param groupId the group ID
5607             * @param folderId the folder ID
5608             * @param start the lower bound of the range of document library file entries
5609             * @param end the upper bound of the range of document library file entries (not inclusive)
5610             * @return the range of matching document library file entries that the user has permission to view
5611             */
5612            @Override
5613            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
5614                    int start, int end) {
5615                    return filterFindByG_F(groupId, folderId, start, end, null);
5616            }
5617    
5618            /**
5619             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and folderId = &#63;.
5620             *
5621             * <p>
5622             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
5623             * </p>
5624             *
5625             * @param groupId the group ID
5626             * @param folderId the folder ID
5627             * @param start the lower bound of the range of document library file entries
5628             * @param end the upper bound of the range of document library file entries (not inclusive)
5629             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5630             * @return the ordered range of matching document library file entries that the user has permission to view
5631             */
5632            @Override
5633            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
5634                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
5635                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5636                            return findByG_F(groupId, folderId, start, end, orderByComparator);
5637                    }
5638    
5639                    StringBundler query = null;
5640    
5641                    if (orderByComparator != null) {
5642                            query = new StringBundler(4 +
5643                                            (orderByComparator.getOrderByFields().length * 3));
5644                    }
5645                    else {
5646                            query = new StringBundler(4);
5647                    }
5648    
5649                    if (getDB().isSupportsInlineDistinct()) {
5650                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
5651                    }
5652                    else {
5653                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
5654                    }
5655    
5656                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5657    
5658                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
5659    
5660                    if (!getDB().isSupportsInlineDistinct()) {
5661                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
5662                    }
5663    
5664                    if (orderByComparator != null) {
5665                            if (getDB().isSupportsInlineDistinct()) {
5666                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5667                                            orderByComparator, true);
5668                            }
5669                            else {
5670                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5671                                            orderByComparator, true);
5672                            }
5673                    }
5674                    else {
5675                            if (getDB().isSupportsInlineDistinct()) {
5676                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5677                            }
5678                            else {
5679                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
5680                            }
5681                    }
5682    
5683                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5684                                    DLFileEntry.class.getName(),
5685                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5686    
5687                    Session session = null;
5688    
5689                    try {
5690                            session = openSession();
5691    
5692                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5693    
5694                            if (getDB().isSupportsInlineDistinct()) {
5695                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5696                            }
5697                            else {
5698                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5699                            }
5700    
5701                            QueryPos qPos = QueryPos.getInstance(q);
5702    
5703                            qPos.add(groupId);
5704    
5705                            qPos.add(folderId);
5706    
5707                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
5708                    }
5709                    catch (Exception e) {
5710                            throw processException(e);
5711                    }
5712                    finally {
5713                            closeSession(session);
5714                    }
5715            }
5716    
5717            /**
5718             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
5719             *
5720             * @param fileEntryId the primary key of the current document library file entry
5721             * @param groupId the group ID
5722             * @param folderId the folder ID
5723             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5724             * @return the previous, current, and next document library file entry
5725             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
5726             */
5727            @Override
5728            public DLFileEntry[] filterFindByG_F_PrevAndNext(long fileEntryId,
5729                    long groupId, long folderId,
5730                    OrderByComparator<DLFileEntry> orderByComparator)
5731                    throws NoSuchFileEntryException {
5732                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5733                            return findByG_F_PrevAndNext(fileEntryId, groupId, folderId,
5734                                    orderByComparator);
5735                    }
5736    
5737                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
5738    
5739                    Session session = null;
5740    
5741                    try {
5742                            session = openSession();
5743    
5744                            DLFileEntry[] array = new DLFileEntryImpl[3];
5745    
5746                            array[0] = filterGetByG_F_PrevAndNext(session, dlFileEntry,
5747                                            groupId, folderId, orderByComparator, true);
5748    
5749                            array[1] = dlFileEntry;
5750    
5751                            array[2] = filterGetByG_F_PrevAndNext(session, dlFileEntry,
5752                                            groupId, folderId, orderByComparator, false);
5753    
5754                            return array;
5755                    }
5756                    catch (Exception e) {
5757                            throw processException(e);
5758                    }
5759                    finally {
5760                            closeSession(session);
5761                    }
5762            }
5763    
5764            protected DLFileEntry filterGetByG_F_PrevAndNext(Session session,
5765                    DLFileEntry dlFileEntry, long groupId, long folderId,
5766                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
5767                    StringBundler query = null;
5768    
5769                    if (orderByComparator != null) {
5770                            query = new StringBundler(6 +
5771                                            (orderByComparator.getOrderByFields().length * 6));
5772                    }
5773                    else {
5774                            query = new StringBundler(3);
5775                    }
5776    
5777                    if (getDB().isSupportsInlineDistinct()) {
5778                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
5779                    }
5780                    else {
5781                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
5782                    }
5783    
5784                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5785    
5786                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
5787    
5788                    if (!getDB().isSupportsInlineDistinct()) {
5789                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
5790                    }
5791    
5792                    if (orderByComparator != null) {
5793                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5794    
5795                            if (orderByConditionFields.length > 0) {
5796                                    query.append(WHERE_AND);
5797                            }
5798    
5799                            for (int i = 0; i < orderByConditionFields.length; i++) {
5800                                    if (getDB().isSupportsInlineDistinct()) {
5801                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5802                                    }
5803                                    else {
5804                                            query.append(_ORDER_BY_ENTITY_TABLE);
5805                                    }
5806    
5807                                    query.append(orderByConditionFields[i]);
5808    
5809                                    if ((i + 1) < orderByConditionFields.length) {
5810                                            if (orderByComparator.isAscending() ^ previous) {
5811                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5812                                            }
5813                                            else {
5814                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5815                                            }
5816                                    }
5817                                    else {
5818                                            if (orderByComparator.isAscending() ^ previous) {
5819                                                    query.append(WHERE_GREATER_THAN);
5820                                            }
5821                                            else {
5822                                                    query.append(WHERE_LESSER_THAN);
5823                                            }
5824                                    }
5825                            }
5826    
5827                            query.append(ORDER_BY_CLAUSE);
5828    
5829                            String[] orderByFields = orderByComparator.getOrderByFields();
5830    
5831                            for (int i = 0; i < orderByFields.length; i++) {
5832                                    if (getDB().isSupportsInlineDistinct()) {
5833                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5834                                    }
5835                                    else {
5836                                            query.append(_ORDER_BY_ENTITY_TABLE);
5837                                    }
5838    
5839                                    query.append(orderByFields[i]);
5840    
5841                                    if ((i + 1) < orderByFields.length) {
5842                                            if (orderByComparator.isAscending() ^ previous) {
5843                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5844                                            }
5845                                            else {
5846                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5847                                            }
5848                                    }
5849                                    else {
5850                                            if (orderByComparator.isAscending() ^ previous) {
5851                                                    query.append(ORDER_BY_ASC);
5852                                            }
5853                                            else {
5854                                                    query.append(ORDER_BY_DESC);
5855                                            }
5856                                    }
5857                            }
5858                    }
5859                    else {
5860                            if (getDB().isSupportsInlineDistinct()) {
5861                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5862                            }
5863                            else {
5864                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
5865                            }
5866                    }
5867    
5868                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5869                                    DLFileEntry.class.getName(),
5870                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5871    
5872                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5873    
5874                    q.setFirstResult(0);
5875                    q.setMaxResults(2);
5876    
5877                    if (getDB().isSupportsInlineDistinct()) {
5878                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5879                    }
5880                    else {
5881                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5882                    }
5883    
5884                    QueryPos qPos = QueryPos.getInstance(q);
5885    
5886                    qPos.add(groupId);
5887    
5888                    qPos.add(folderId);
5889    
5890                    if (orderByComparator != null) {
5891                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
5892    
5893                            for (Object value : values) {
5894                                    qPos.add(value);
5895                            }
5896                    }
5897    
5898                    List<DLFileEntry> list = q.list();
5899    
5900                    if (list.size() == 2) {
5901                            return list.get(1);
5902                    }
5903                    else {
5904                            return null;
5905                    }
5906            }
5907    
5908            /**
5909             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
5910             *
5911             * @param groupId the group ID
5912             * @param folderIds the folder IDs
5913             * @return the matching document library file entries that the user has permission to view
5914             */
5915            @Override
5916            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds) {
5917                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
5918                            QueryUtil.ALL_POS, null);
5919            }
5920    
5921            /**
5922             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
5923             *
5924             * <p>
5925             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
5926             * </p>
5927             *
5928             * @param groupId the group ID
5929             * @param folderIds the folder IDs
5930             * @param start the lower bound of the range of document library file entries
5931             * @param end the upper bound of the range of document library file entries (not inclusive)
5932             * @return the range of matching document library file entries that the user has permission to view
5933             */
5934            @Override
5935            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
5936                    int start, int end) {
5937                    return filterFindByG_F(groupId, folderIds, start, end, null);
5938            }
5939    
5940            /**
5941             * Returns an ordered range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
5942             *
5943             * <p>
5944             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
5945             * </p>
5946             *
5947             * @param groupId the group ID
5948             * @param folderIds the folder IDs
5949             * @param start the lower bound of the range of document library file entries
5950             * @param end the upper bound of the range of document library file entries (not inclusive)
5951             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5952             * @return the ordered range of matching document library file entries that the user has permission to view
5953             */
5954            @Override
5955            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
5956                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
5957                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5958                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
5959                    }
5960    
5961                    if (folderIds == null) {
5962                            folderIds = new long[0];
5963                    }
5964                    else {
5965                            folderIds = ArrayUtil.unique(folderIds);
5966                    }
5967    
5968                    StringBundler query = new StringBundler();
5969    
5970                    if (getDB().isSupportsInlineDistinct()) {
5971                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
5972                    }
5973                    else {
5974                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
5975                    }
5976    
5977                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5978    
5979                    if (folderIds.length > 0) {
5980                            query.append(StringPool.OPEN_PARENTHESIS);
5981    
5982                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
5983    
5984                            query.append(StringUtil.merge(folderIds));
5985    
5986                            query.append(StringPool.CLOSE_PARENTHESIS);
5987    
5988                            query.append(StringPool.CLOSE_PARENTHESIS);
5989                    }
5990    
5991                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
5992                            query.index() - 1);
5993    
5994                    if (!getDB().isSupportsInlineDistinct()) {
5995                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
5996                    }
5997    
5998                    if (orderByComparator != null) {
5999                            if (getDB().isSupportsInlineDistinct()) {
6000                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6001                                            orderByComparator, true);
6002                            }
6003                            else {
6004                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6005                                            orderByComparator, true);
6006                            }
6007                    }
6008                    else {
6009                            if (getDB().isSupportsInlineDistinct()) {
6010                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6011                            }
6012                            else {
6013                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6014                            }
6015                    }
6016    
6017                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6018                                    DLFileEntry.class.getName(),
6019                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6020    
6021                    Session session = null;
6022    
6023                    try {
6024                            session = openSession();
6025    
6026                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6027    
6028                            if (getDB().isSupportsInlineDistinct()) {
6029                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6030                            }
6031                            else {
6032                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6033                            }
6034    
6035                            QueryPos qPos = QueryPos.getInstance(q);
6036    
6037                            qPos.add(groupId);
6038    
6039                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
6040                    }
6041                    catch (Exception e) {
6042                            throw processException(e);
6043                    }
6044                    finally {
6045                            closeSession(session);
6046                    }
6047            }
6048    
6049            /**
6050             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63;.
6051             *
6052             * <p>
6053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
6054             * </p>
6055             *
6056             * @param groupId the group ID
6057             * @param folderIds the folder IDs
6058             * @return the matching document library file entries
6059             */
6060            @Override
6061            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds) {
6062                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
6063                            QueryUtil.ALL_POS, null);
6064            }
6065    
6066            /**
6067             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63;.
6068             *
6069             * <p>
6070             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
6071             * </p>
6072             *
6073             * @param groupId the group ID
6074             * @param folderIds the folder IDs
6075             * @param start the lower bound of the range of document library file entries
6076             * @param end the upper bound of the range of document library file entries (not inclusive)
6077             * @return the range of matching document library file entries
6078             */
6079            @Override
6080            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
6081                    int start, int end) {
6082                    return findByG_F(groupId, folderIds, start, end, null);
6083            }
6084    
6085            /**
6086             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63;.
6087             *
6088             * <p>
6089             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
6090             * </p>
6091             *
6092             * @param groupId the group ID
6093             * @param folderIds the folder IDs
6094             * @param start the lower bound of the range of document library file entries
6095             * @param end the upper bound of the range of document library file entries (not inclusive)
6096             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6097             * @return the ordered range of matching document library file entries
6098             */
6099            @Override
6100            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
6101                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
6102                    if (folderIds == null) {
6103                            folderIds = new long[0];
6104                    }
6105                    else {
6106                            folderIds = ArrayUtil.unique(folderIds);
6107                    }
6108    
6109                    if (folderIds.length == 1) {
6110                            return findByG_F(groupId, folderIds[0], start, end,
6111                                    orderByComparator);
6112                    }
6113    
6114                    boolean pagination = true;
6115                    Object[] finderArgs = null;
6116    
6117                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6118                                    (orderByComparator == null)) {
6119                            pagination = false;
6120                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
6121                    }
6122                    else {
6123                            finderArgs = new Object[] {
6124                                            groupId, StringUtil.merge(folderIds),
6125                                            
6126                                            start, end, orderByComparator
6127                                    };
6128                    }
6129    
6130                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
6131                                    finderArgs, this);
6132    
6133                    if ((list != null) && !list.isEmpty()) {
6134                            for (DLFileEntry dlFileEntry : list) {
6135                                    if ((groupId != dlFileEntry.getGroupId()) ||
6136                                                    !ArrayUtil.contains(folderIds, dlFileEntry.getFolderId())) {
6137                                            list = null;
6138    
6139                                            break;
6140                                    }
6141                            }
6142                    }
6143    
6144                    if (list == null) {
6145                            StringBundler query = new StringBundler();
6146    
6147                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
6148    
6149                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6150    
6151                            if (folderIds.length > 0) {
6152                                    query.append(StringPool.OPEN_PARENTHESIS);
6153    
6154                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
6155    
6156                                    query.append(StringUtil.merge(folderIds));
6157    
6158                                    query.append(StringPool.CLOSE_PARENTHESIS);
6159    
6160                                    query.append(StringPool.CLOSE_PARENTHESIS);
6161                            }
6162    
6163                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
6164                                                    1)), query.index() - 1);
6165    
6166                            if (orderByComparator != null) {
6167                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6168                                            orderByComparator);
6169                            }
6170                            else
6171                             if (pagination) {
6172                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6173                            }
6174    
6175                            String sql = query.toString();
6176    
6177                            Session session = null;
6178    
6179                            try {
6180                                    session = openSession();
6181    
6182                                    Query q = session.createQuery(sql);
6183    
6184                                    QueryPos qPos = QueryPos.getInstance(q);
6185    
6186                                    qPos.add(groupId);
6187    
6188                                    if (!pagination) {
6189                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6190                                                            start, end, false);
6191    
6192                                            Collections.sort(list);
6193    
6194                                            list = Collections.unmodifiableList(list);
6195                                    }
6196                                    else {
6197                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6198                                                            start, end);
6199                                    }
6200    
6201                                    cacheResult(list);
6202    
6203                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
6204                                            finderArgs, list);
6205                            }
6206                            catch (Exception e) {
6207                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
6208                                            finderArgs);
6209    
6210                                    throw processException(e);
6211                            }
6212                            finally {
6213                                    closeSession(session);
6214                            }
6215                    }
6216    
6217                    return list;
6218            }
6219    
6220            /**
6221             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; from the database.
6222             *
6223             * @param groupId the group ID
6224             * @param folderId the folder ID
6225             */
6226            @Override
6227            public void removeByG_F(long groupId, long folderId) {
6228                    for (DLFileEntry dlFileEntry : findByG_F(groupId, folderId,
6229                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6230                            remove(dlFileEntry);
6231                    }
6232            }
6233    
6234            /**
6235             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63;.
6236             *
6237             * @param groupId the group ID
6238             * @param folderId the folder ID
6239             * @return the number of matching document library file entries
6240             */
6241            @Override
6242            public int countByG_F(long groupId, long folderId) {
6243                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
6244    
6245                    Object[] finderArgs = new Object[] { groupId, folderId };
6246    
6247                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6248                                    this);
6249    
6250                    if (count == null) {
6251                            StringBundler query = new StringBundler(3);
6252    
6253                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
6254    
6255                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6256    
6257                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
6258    
6259                            String sql = query.toString();
6260    
6261                            Session session = null;
6262    
6263                            try {
6264                                    session = openSession();
6265    
6266                                    Query q = session.createQuery(sql);
6267    
6268                                    QueryPos qPos = QueryPos.getInstance(q);
6269    
6270                                    qPos.add(groupId);
6271    
6272                                    qPos.add(folderId);
6273    
6274                                    count = (Long)q.uniqueResult();
6275    
6276                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6277                            }
6278                            catch (Exception e) {
6279                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6280    
6281                                    throw processException(e);
6282                            }
6283                            finally {
6284                                    closeSession(session);
6285                            }
6286                    }
6287    
6288                    return count.intValue();
6289            }
6290    
6291            /**
6292             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63;.
6293             *
6294             * @param groupId the group ID
6295             * @param folderIds the folder IDs
6296             * @return the number of matching document library file entries
6297             */
6298            @Override
6299            public int countByG_F(long groupId, long[] folderIds) {
6300                    if (folderIds == null) {
6301                            folderIds = new long[0];
6302                    }
6303                    else {
6304                            folderIds = ArrayUtil.unique(folderIds);
6305                    }
6306    
6307                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
6308    
6309                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
6310                                    finderArgs, this);
6311    
6312                    if (count == null) {
6313                            StringBundler query = new StringBundler();
6314    
6315                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
6316    
6317                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6318    
6319                            if (folderIds.length > 0) {
6320                                    query.append(StringPool.OPEN_PARENTHESIS);
6321    
6322                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
6323    
6324                                    query.append(StringUtil.merge(folderIds));
6325    
6326                                    query.append(StringPool.CLOSE_PARENTHESIS);
6327    
6328                                    query.append(StringPool.CLOSE_PARENTHESIS);
6329                            }
6330    
6331                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
6332                                                    1)), query.index() - 1);
6333    
6334                            String sql = query.toString();
6335    
6336                            Session session = null;
6337    
6338                            try {
6339                                    session = openSession();
6340    
6341                                    Query q = session.createQuery(sql);
6342    
6343                                    QueryPos qPos = QueryPos.getInstance(q);
6344    
6345                                    qPos.add(groupId);
6346    
6347                                    count = (Long)q.uniqueResult();
6348    
6349                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
6350                                            finderArgs, count);
6351                            }
6352                            catch (Exception e) {
6353                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
6354                                            finderArgs);
6355    
6356                                    throw processException(e);
6357                            }
6358                            finally {
6359                                    closeSession(session);
6360                            }
6361                    }
6362    
6363                    return count.intValue();
6364            }
6365    
6366            /**
6367             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
6368             *
6369             * @param groupId the group ID
6370             * @param folderId the folder ID
6371             * @return the number of matching document library file entries that the user has permission to view
6372             */
6373            @Override
6374            public int filterCountByG_F(long groupId, long folderId) {
6375                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6376                            return countByG_F(groupId, folderId);
6377                    }
6378    
6379                    StringBundler query = new StringBundler(3);
6380    
6381                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
6382    
6383                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6384    
6385                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
6386    
6387                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6388                                    DLFileEntry.class.getName(),
6389                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6390    
6391                    Session session = null;
6392    
6393                    try {
6394                            session = openSession();
6395    
6396                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6397    
6398                            q.addScalar(COUNT_COLUMN_NAME,
6399                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6400    
6401                            QueryPos qPos = QueryPos.getInstance(q);
6402    
6403                            qPos.add(groupId);
6404    
6405                            qPos.add(folderId);
6406    
6407                            Long count = (Long)q.uniqueResult();
6408    
6409                            return count.intValue();
6410                    }
6411                    catch (Exception e) {
6412                            throw processException(e);
6413                    }
6414                    finally {
6415                            closeSession(session);
6416                    }
6417            }
6418    
6419            /**
6420             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
6421             *
6422             * @param groupId the group ID
6423             * @param folderIds the folder IDs
6424             * @return the number of matching document library file entries that the user has permission to view
6425             */
6426            @Override
6427            public int filterCountByG_F(long groupId, long[] folderIds) {
6428                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6429                            return countByG_F(groupId, folderIds);
6430                    }
6431    
6432                    if (folderIds == null) {
6433                            folderIds = new long[0];
6434                    }
6435                    else {
6436                            folderIds = ArrayUtil.unique(folderIds);
6437                    }
6438    
6439                    StringBundler query = new StringBundler();
6440    
6441                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
6442    
6443                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6444    
6445                    if (folderIds.length > 0) {
6446                            query.append(StringPool.OPEN_PARENTHESIS);
6447    
6448                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
6449    
6450                            query.append(StringUtil.merge(folderIds));
6451    
6452                            query.append(StringPool.CLOSE_PARENTHESIS);
6453    
6454                            query.append(StringPool.CLOSE_PARENTHESIS);
6455                    }
6456    
6457                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
6458                            query.index() - 1);
6459    
6460                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6461                                    DLFileEntry.class.getName(),
6462                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6463    
6464                    Session session = null;
6465    
6466                    try {
6467                            session = openSession();
6468    
6469                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6470    
6471                            q.addScalar(COUNT_COLUMN_NAME,
6472                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6473    
6474                            QueryPos qPos = QueryPos.getInstance(q);
6475    
6476                            qPos.add(groupId);
6477    
6478                            Long count = (Long)q.uniqueResult();
6479    
6480                            return count.intValue();
6481                    }
6482                    catch (Exception e) {
6483                            throw processException(e);
6484                    }
6485                    finally {
6486                            closeSession(session);
6487                    }
6488            }
6489    
6490            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
6491            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
6492            private static final String _FINDER_COLUMN_G_F_FOLDERID_7 = "dlFileEntry.folderId IN (";
6493            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6494                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
6495                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_F",
6496                            new String[] {
6497                                    Long.class.getName(), Long.class.getName(),
6498                                    
6499                            Integer.class.getName(), Integer.class.getName(),
6500                                    OrderByComparator.class.getName()
6501                            });
6502            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6503                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
6504                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_F",
6505                            new String[] { Long.class.getName(), Long.class.getName() },
6506                            DLFileEntryModelImpl.REPOSITORYID_COLUMN_BITMASK |
6507                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
6508                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
6509            public static final FinderPath FINDER_PATH_COUNT_BY_R_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6510                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6511                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_F",
6512                            new String[] { Long.class.getName(), Long.class.getName() });
6513    
6514            /**
6515             * Returns all the document library file entries where repositoryId = &#63; and folderId = &#63;.
6516             *
6517             * @param repositoryId the repository ID
6518             * @param folderId the folder ID
6519             * @return the matching document library file entries
6520             */
6521            @Override
6522            public List<DLFileEntry> findByR_F(long repositoryId, long folderId) {
6523                    return findByR_F(repositoryId, folderId, QueryUtil.ALL_POS,
6524                            QueryUtil.ALL_POS, null);
6525            }
6526    
6527            /**
6528             * Returns a range of all the document library file entries where repositoryId = &#63; and folderId = &#63;.
6529             *
6530             * <p>
6531             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
6532             * </p>
6533             *
6534             * @param repositoryId the repository ID
6535             * @param folderId the folder ID
6536             * @param start the lower bound of the range of document library file entries
6537             * @param end the upper bound of the range of document library file entries (not inclusive)
6538             * @return the range of matching document library file entries
6539             */
6540            @Override
6541            public List<DLFileEntry> findByR_F(long repositoryId, long folderId,
6542                    int start, int end) {
6543                    return findByR_F(repositoryId, folderId, start, end, null);
6544            }
6545    
6546            /**
6547             * Returns an ordered range of all the document library file entries where repositoryId = &#63; and folderId = &#63;.
6548             *
6549             * <p>
6550             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
6551             * </p>
6552             *
6553             * @param repositoryId the repository ID
6554             * @param folderId the folder ID
6555             * @param start the lower bound of the range of document library file entries
6556             * @param end the upper bound of the range of document library file entries (not inclusive)
6557             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6558             * @return the ordered range of matching document library file entries
6559             */
6560            @Override
6561            public List<DLFileEntry> findByR_F(long repositoryId, long folderId,
6562                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
6563                    boolean pagination = true;
6564                    FinderPath finderPath = null;
6565                    Object[] finderArgs = null;
6566    
6567                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6568                                    (orderByComparator == null)) {
6569                            pagination = false;
6570                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F;
6571                            finderArgs = new Object[] { repositoryId, folderId };
6572                    }
6573                    else {
6574                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_F;
6575                            finderArgs = new Object[] {
6576                                            repositoryId, folderId,
6577                                            
6578                                            start, end, orderByComparator
6579                                    };
6580                    }
6581    
6582                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
6583                                    finderArgs, this);
6584    
6585                    if ((list != null) && !list.isEmpty()) {
6586                            for (DLFileEntry dlFileEntry : list) {
6587                                    if ((repositoryId != dlFileEntry.getRepositoryId()) ||
6588                                                    (folderId != dlFileEntry.getFolderId())) {
6589                                            list = null;
6590    
6591                                            break;
6592                                    }
6593                            }
6594                    }
6595    
6596                    if (list == null) {
6597                            StringBundler query = null;
6598    
6599                            if (orderByComparator != null) {
6600                                    query = new StringBundler(4 +
6601                                                    (orderByComparator.getOrderByFields().length * 3));
6602                            }
6603                            else {
6604                                    query = new StringBundler(4);
6605                            }
6606    
6607                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
6608    
6609                            query.append(_FINDER_COLUMN_R_F_REPOSITORYID_2);
6610    
6611                            query.append(_FINDER_COLUMN_R_F_FOLDERID_2);
6612    
6613                            if (orderByComparator != null) {
6614                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6615                                            orderByComparator);
6616                            }
6617                            else
6618                             if (pagination) {
6619                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6620                            }
6621    
6622                            String sql = query.toString();
6623    
6624                            Session session = null;
6625    
6626                            try {
6627                                    session = openSession();
6628    
6629                                    Query q = session.createQuery(sql);
6630    
6631                                    QueryPos qPos = QueryPos.getInstance(q);
6632    
6633                                    qPos.add(repositoryId);
6634    
6635                                    qPos.add(folderId);
6636    
6637                                    if (!pagination) {
6638                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6639                                                            start, end, false);
6640    
6641                                            Collections.sort(list);
6642    
6643                                            list = Collections.unmodifiableList(list);
6644                                    }
6645                                    else {
6646                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6647                                                            start, end);
6648                                    }
6649    
6650                                    cacheResult(list);
6651    
6652                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6653                            }
6654                            catch (Exception e) {
6655                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6656    
6657                                    throw processException(e);
6658                            }
6659                            finally {
6660                                    closeSession(session);
6661                            }
6662                    }
6663    
6664                    return list;
6665            }
6666    
6667            /**
6668             * Returns the first document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
6669             *
6670             * @param repositoryId the repository ID
6671             * @param folderId the folder ID
6672             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6673             * @return the first matching document library file entry
6674             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
6675             */
6676            @Override
6677            public DLFileEntry findByR_F_First(long repositoryId, long folderId,
6678                    OrderByComparator<DLFileEntry> orderByComparator)
6679                    throws NoSuchFileEntryException {
6680                    DLFileEntry dlFileEntry = fetchByR_F_First(repositoryId, folderId,
6681                                    orderByComparator);
6682    
6683                    if (dlFileEntry != null) {
6684                            return dlFileEntry;
6685                    }
6686    
6687                    StringBundler msg = new StringBundler(6);
6688    
6689                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6690    
6691                    msg.append("repositoryId=");
6692                    msg.append(repositoryId);
6693    
6694                    msg.append(", folderId=");
6695                    msg.append(folderId);
6696    
6697                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6698    
6699                    throw new NoSuchFileEntryException(msg.toString());
6700            }
6701    
6702            /**
6703             * Returns the first document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
6704             *
6705             * @param repositoryId the repository ID
6706             * @param folderId the folder ID
6707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6708             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
6709             */
6710            @Override
6711            public DLFileEntry fetchByR_F_First(long repositoryId, long folderId,
6712                    OrderByComparator<DLFileEntry> orderByComparator) {
6713                    List<DLFileEntry> list = findByR_F(repositoryId, folderId, 0, 1,
6714                                    orderByComparator);
6715    
6716                    if (!list.isEmpty()) {
6717                            return list.get(0);
6718                    }
6719    
6720                    return null;
6721            }
6722    
6723            /**
6724             * Returns the last document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
6725             *
6726             * @param repositoryId the repository ID
6727             * @param folderId the folder ID
6728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6729             * @return the last matching document library file entry
6730             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
6731             */
6732            @Override
6733            public DLFileEntry findByR_F_Last(long repositoryId, long folderId,
6734                    OrderByComparator<DLFileEntry> orderByComparator)
6735                    throws NoSuchFileEntryException {
6736                    DLFileEntry dlFileEntry = fetchByR_F_Last(repositoryId, folderId,
6737                                    orderByComparator);
6738    
6739                    if (dlFileEntry != null) {
6740                            return dlFileEntry;
6741                    }
6742    
6743                    StringBundler msg = new StringBundler(6);
6744    
6745                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6746    
6747                    msg.append("repositoryId=");
6748                    msg.append(repositoryId);
6749    
6750                    msg.append(", folderId=");
6751                    msg.append(folderId);
6752    
6753                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6754    
6755                    throw new NoSuchFileEntryException(msg.toString());
6756            }
6757    
6758            /**
6759             * Returns the last document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
6760             *
6761             * @param repositoryId the repository ID
6762             * @param folderId the folder ID
6763             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6764             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
6765             */
6766            @Override
6767            public DLFileEntry fetchByR_F_Last(long repositoryId, long folderId,
6768                    OrderByComparator<DLFileEntry> orderByComparator) {
6769                    int count = countByR_F(repositoryId, folderId);
6770    
6771                    if (count == 0) {
6772                            return null;
6773                    }
6774    
6775                    List<DLFileEntry> list = findByR_F(repositoryId, folderId, count - 1,
6776                                    count, orderByComparator);
6777    
6778                    if (!list.isEmpty()) {
6779                            return list.get(0);
6780                    }
6781    
6782                    return null;
6783            }
6784    
6785            /**
6786             * Returns the document library file entries before and after the current document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
6787             *
6788             * @param fileEntryId the primary key of the current document library file entry
6789             * @param repositoryId the repository ID
6790             * @param folderId the folder ID
6791             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6792             * @return the previous, current, and next document library file entry
6793             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
6794             */
6795            @Override
6796            public DLFileEntry[] findByR_F_PrevAndNext(long fileEntryId,
6797                    long repositoryId, long folderId,
6798                    OrderByComparator<DLFileEntry> orderByComparator)
6799                    throws NoSuchFileEntryException {
6800                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
6801    
6802                    Session session = null;
6803    
6804                    try {
6805                            session = openSession();
6806    
6807                            DLFileEntry[] array = new DLFileEntryImpl[3];
6808    
6809                            array[0] = getByR_F_PrevAndNext(session, dlFileEntry, repositoryId,
6810                                            folderId, orderByComparator, true);
6811    
6812                            array[1] = dlFileEntry;
6813    
6814                            array[2] = getByR_F_PrevAndNext(session, dlFileEntry, repositoryId,
6815                                            folderId, orderByComparator, false);
6816    
6817                            return array;
6818                    }
6819                    catch (Exception e) {
6820                            throw processException(e);
6821                    }
6822                    finally {
6823                            closeSession(session);
6824                    }
6825            }
6826    
6827            protected DLFileEntry getByR_F_PrevAndNext(Session session,
6828                    DLFileEntry dlFileEntry, long repositoryId, long folderId,
6829                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
6830                    StringBundler query = null;
6831    
6832                    if (orderByComparator != null) {
6833                            query = new StringBundler(6 +
6834                                            (orderByComparator.getOrderByFields().length * 6));
6835                    }
6836                    else {
6837                            query = new StringBundler(3);
6838                    }
6839    
6840                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
6841    
6842                    query.append(_FINDER_COLUMN_R_F_REPOSITORYID_2);
6843    
6844                    query.append(_FINDER_COLUMN_R_F_FOLDERID_2);
6845    
6846                    if (orderByComparator != null) {
6847                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6848    
6849                            if (orderByConditionFields.length > 0) {
6850                                    query.append(WHERE_AND);
6851                            }
6852    
6853                            for (int i = 0; i < orderByConditionFields.length; i++) {
6854                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6855                                    query.append(orderByConditionFields[i]);
6856    
6857                                    if ((i + 1) < orderByConditionFields.length) {
6858                                            if (orderByComparator.isAscending() ^ previous) {
6859                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6860                                            }
6861                                            else {
6862                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6863                                            }
6864                                    }
6865                                    else {
6866                                            if (orderByComparator.isAscending() ^ previous) {
6867                                                    query.append(WHERE_GREATER_THAN);
6868                                            }
6869                                            else {
6870                                                    query.append(WHERE_LESSER_THAN);
6871                                            }
6872                                    }
6873                            }
6874    
6875                            query.append(ORDER_BY_CLAUSE);
6876    
6877                            String[] orderByFields = orderByComparator.getOrderByFields();
6878    
6879                            for (int i = 0; i < orderByFields.length; i++) {
6880                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6881                                    query.append(orderByFields[i]);
6882    
6883                                    if ((i + 1) < orderByFields.length) {
6884                                            if (orderByComparator.isAscending() ^ previous) {
6885                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6886                                            }
6887                                            else {
6888                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6889                                            }
6890                                    }
6891                                    else {
6892                                            if (orderByComparator.isAscending() ^ previous) {
6893                                                    query.append(ORDER_BY_ASC);
6894                                            }
6895                                            else {
6896                                                    query.append(ORDER_BY_DESC);
6897                                            }
6898                                    }
6899                            }
6900                    }
6901                    else {
6902                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6903                    }
6904    
6905                    String sql = query.toString();
6906    
6907                    Query q = session.createQuery(sql);
6908    
6909                    q.setFirstResult(0);
6910                    q.setMaxResults(2);
6911    
6912                    QueryPos qPos = QueryPos.getInstance(q);
6913    
6914                    qPos.add(repositoryId);
6915    
6916                    qPos.add(folderId);
6917    
6918                    if (orderByComparator != null) {
6919                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
6920    
6921                            for (Object value : values) {
6922                                    qPos.add(value);
6923                            }
6924                    }
6925    
6926                    List<DLFileEntry> list = q.list();
6927    
6928                    if (list.size() == 2) {
6929                            return list.get(1);
6930                    }
6931                    else {
6932                            return null;
6933                    }
6934            }
6935    
6936            /**
6937             * Removes all the document library file entries where repositoryId = &#63; and folderId = &#63; from the database.
6938             *
6939             * @param repositoryId the repository ID
6940             * @param folderId the folder ID
6941             */
6942            @Override
6943            public void removeByR_F(long repositoryId, long folderId) {
6944                    for (DLFileEntry dlFileEntry : findByR_F(repositoryId, folderId,
6945                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6946                            remove(dlFileEntry);
6947                    }
6948            }
6949    
6950            /**
6951             * Returns the number of document library file entries where repositoryId = &#63; and folderId = &#63;.
6952             *
6953             * @param repositoryId the repository ID
6954             * @param folderId the folder ID
6955             * @return the number of matching document library file entries
6956             */
6957            @Override
6958            public int countByR_F(long repositoryId, long folderId) {
6959                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_F;
6960    
6961                    Object[] finderArgs = new Object[] { repositoryId, folderId };
6962    
6963                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6964                                    this);
6965    
6966                    if (count == null) {
6967                            StringBundler query = new StringBundler(3);
6968    
6969                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
6970    
6971                            query.append(_FINDER_COLUMN_R_F_REPOSITORYID_2);
6972    
6973                            query.append(_FINDER_COLUMN_R_F_FOLDERID_2);
6974    
6975                            String sql = query.toString();
6976    
6977                            Session session = null;
6978    
6979                            try {
6980                                    session = openSession();
6981    
6982                                    Query q = session.createQuery(sql);
6983    
6984                                    QueryPos qPos = QueryPos.getInstance(q);
6985    
6986                                    qPos.add(repositoryId);
6987    
6988                                    qPos.add(folderId);
6989    
6990                                    count = (Long)q.uniqueResult();
6991    
6992                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6993                            }
6994                            catch (Exception e) {
6995                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6996    
6997                                    throw processException(e);
6998                            }
6999                            finally {
7000                                    closeSession(session);
7001                            }
7002                    }
7003    
7004                    return count.intValue();
7005            }
7006    
7007            private static final String _FINDER_COLUMN_R_F_REPOSITORYID_2 = "dlFileEntry.repositoryId = ? AND ";
7008            private static final String _FINDER_COLUMN_R_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
7009            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7010                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
7011                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByF_N",
7012                            new String[] {
7013                                    Long.class.getName(), String.class.getName(),
7014                                    
7015                            Integer.class.getName(), Integer.class.getName(),
7016                                    OrderByComparator.class.getName()
7017                            });
7018            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7019                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
7020                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByF_N",
7021                            new String[] { Long.class.getName(), String.class.getName() },
7022                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
7023                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
7024            public static final FinderPath FINDER_PATH_COUNT_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7025                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7026                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByF_N",
7027                            new String[] { Long.class.getName(), String.class.getName() });
7028    
7029            /**
7030             * Returns all the document library file entries where folderId = &#63; and name = &#63;.
7031             *
7032             * @param folderId the folder ID
7033             * @param name the name
7034             * @return the matching document library file entries
7035             */
7036            @Override
7037            public List<DLFileEntry> findByF_N(long folderId, String name) {
7038                    return findByF_N(folderId, name, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7039                            null);
7040            }
7041    
7042            /**
7043             * Returns a range of all the document library file entries where folderId = &#63; and name = &#63;.
7044             *
7045             * <p>
7046             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
7047             * </p>
7048             *
7049             * @param folderId the folder ID
7050             * @param name the name
7051             * @param start the lower bound of the range of document library file entries
7052             * @param end the upper bound of the range of document library file entries (not inclusive)
7053             * @return the range of matching document library file entries
7054             */
7055            @Override
7056            public List<DLFileEntry> findByF_N(long folderId, String name, int start,
7057                    int end) {
7058                    return findByF_N(folderId, name, start, end, null);
7059            }
7060    
7061            /**
7062             * Returns an ordered range of all the document library file entries where folderId = &#63; and name = &#63;.
7063             *
7064             * <p>
7065             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
7066             * </p>
7067             *
7068             * @param folderId the folder ID
7069             * @param name the name
7070             * @param start the lower bound of the range of document library file entries
7071             * @param end the upper bound of the range of document library file entries (not inclusive)
7072             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7073             * @return the ordered range of matching document library file entries
7074             */
7075            @Override
7076            public List<DLFileEntry> findByF_N(long folderId, String name, int start,
7077                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
7078                    boolean pagination = true;
7079                    FinderPath finderPath = null;
7080                    Object[] finderArgs = null;
7081    
7082                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7083                                    (orderByComparator == null)) {
7084                            pagination = false;
7085                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N;
7086                            finderArgs = new Object[] { folderId, name };
7087                    }
7088                    else {
7089                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_F_N;
7090                            finderArgs = new Object[] {
7091                                            folderId, name,
7092                                            
7093                                            start, end, orderByComparator
7094                                    };
7095                    }
7096    
7097                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
7098                                    finderArgs, this);
7099    
7100                    if ((list != null) && !list.isEmpty()) {
7101                            for (DLFileEntry dlFileEntry : list) {
7102                                    if ((folderId != dlFileEntry.getFolderId()) ||
7103                                                    !Validator.equals(name, dlFileEntry.getName())) {
7104                                            list = null;
7105    
7106                                            break;
7107                                    }
7108                            }
7109                    }
7110    
7111                    if (list == null) {
7112                            StringBundler query = null;
7113    
7114                            if (orderByComparator != null) {
7115                                    query = new StringBundler(4 +
7116                                                    (orderByComparator.getOrderByFields().length * 3));
7117                            }
7118                            else {
7119                                    query = new StringBundler(4);
7120                            }
7121    
7122                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7123    
7124                            query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
7125    
7126                            boolean bindName = false;
7127    
7128                            if (name == null) {
7129                                    query.append(_FINDER_COLUMN_F_N_NAME_1);
7130                            }
7131                            else if (name.equals(StringPool.BLANK)) {
7132                                    query.append(_FINDER_COLUMN_F_N_NAME_3);
7133                            }
7134                            else {
7135                                    bindName = true;
7136    
7137                                    query.append(_FINDER_COLUMN_F_N_NAME_2);
7138                            }
7139    
7140                            if (orderByComparator != null) {
7141                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7142                                            orderByComparator);
7143                            }
7144                            else
7145                             if (pagination) {
7146                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7147                            }
7148    
7149                            String sql = query.toString();
7150    
7151                            Session session = null;
7152    
7153                            try {
7154                                    session = openSession();
7155    
7156                                    Query q = session.createQuery(sql);
7157    
7158                                    QueryPos qPos = QueryPos.getInstance(q);
7159    
7160                                    qPos.add(folderId);
7161    
7162                                    if (bindName) {
7163                                            qPos.add(name);
7164                                    }
7165    
7166                                    if (!pagination) {
7167                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
7168                                                            start, end, false);
7169    
7170                                            Collections.sort(list);
7171    
7172                                            list = Collections.unmodifiableList(list);
7173                                    }
7174                                    else {
7175                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
7176                                                            start, end);
7177                                    }
7178    
7179                                    cacheResult(list);
7180    
7181                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7182                            }
7183                            catch (Exception e) {
7184                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7185    
7186                                    throw processException(e);
7187                            }
7188                            finally {
7189                                    closeSession(session);
7190                            }
7191                    }
7192    
7193                    return list;
7194            }
7195    
7196            /**
7197             * Returns the first document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7198             *
7199             * @param folderId the folder ID
7200             * @param name the name
7201             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7202             * @return the first matching document library file entry
7203             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
7204             */
7205            @Override
7206            public DLFileEntry findByF_N_First(long folderId, String name,
7207                    OrderByComparator<DLFileEntry> orderByComparator)
7208                    throws NoSuchFileEntryException {
7209                    DLFileEntry dlFileEntry = fetchByF_N_First(folderId, name,
7210                                    orderByComparator);
7211    
7212                    if (dlFileEntry != null) {
7213                            return dlFileEntry;
7214                    }
7215    
7216                    StringBundler msg = new StringBundler(6);
7217    
7218                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7219    
7220                    msg.append("folderId=");
7221                    msg.append(folderId);
7222    
7223                    msg.append(", name=");
7224                    msg.append(name);
7225    
7226                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7227    
7228                    throw new NoSuchFileEntryException(msg.toString());
7229            }
7230    
7231            /**
7232             * Returns the first document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7233             *
7234             * @param folderId the folder ID
7235             * @param name the name
7236             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7237             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7238             */
7239            @Override
7240            public DLFileEntry fetchByF_N_First(long folderId, String name,
7241                    OrderByComparator<DLFileEntry> orderByComparator) {
7242                    List<DLFileEntry> list = findByF_N(folderId, name, 0, 1,
7243                                    orderByComparator);
7244    
7245                    if (!list.isEmpty()) {
7246                            return list.get(0);
7247                    }
7248    
7249                    return null;
7250            }
7251    
7252            /**
7253             * Returns the last document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7254             *
7255             * @param folderId the folder ID
7256             * @param name the name
7257             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7258             * @return the last matching document library file entry
7259             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
7260             */
7261            @Override
7262            public DLFileEntry findByF_N_Last(long folderId, String name,
7263                    OrderByComparator<DLFileEntry> orderByComparator)
7264                    throws NoSuchFileEntryException {
7265                    DLFileEntry dlFileEntry = fetchByF_N_Last(folderId, name,
7266                                    orderByComparator);
7267    
7268                    if (dlFileEntry != null) {
7269                            return dlFileEntry;
7270                    }
7271    
7272                    StringBundler msg = new StringBundler(6);
7273    
7274                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7275    
7276                    msg.append("folderId=");
7277                    msg.append(folderId);
7278    
7279                    msg.append(", name=");
7280                    msg.append(name);
7281    
7282                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7283    
7284                    throw new NoSuchFileEntryException(msg.toString());
7285            }
7286    
7287            /**
7288             * Returns the last document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7289             *
7290             * @param folderId the folder ID
7291             * @param name the name
7292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7293             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7294             */
7295            @Override
7296            public DLFileEntry fetchByF_N_Last(long folderId, String name,
7297                    OrderByComparator<DLFileEntry> orderByComparator) {
7298                    int count = countByF_N(folderId, name);
7299    
7300                    if (count == 0) {
7301                            return null;
7302                    }
7303    
7304                    List<DLFileEntry> list = findByF_N(folderId, name, count - 1, count,
7305                                    orderByComparator);
7306    
7307                    if (!list.isEmpty()) {
7308                            return list.get(0);
7309                    }
7310    
7311                    return null;
7312            }
7313    
7314            /**
7315             * Returns the document library file entries before and after the current document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7316             *
7317             * @param fileEntryId the primary key of the current document library file entry
7318             * @param folderId the folder ID
7319             * @param name the name
7320             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7321             * @return the previous, current, and next document library file entry
7322             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
7323             */
7324            @Override
7325            public DLFileEntry[] findByF_N_PrevAndNext(long fileEntryId, long folderId,
7326                    String name, OrderByComparator<DLFileEntry> orderByComparator)
7327                    throws NoSuchFileEntryException {
7328                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
7329    
7330                    Session session = null;
7331    
7332                    try {
7333                            session = openSession();
7334    
7335                            DLFileEntry[] array = new DLFileEntryImpl[3];
7336    
7337                            array[0] = getByF_N_PrevAndNext(session, dlFileEntry, folderId,
7338                                            name, orderByComparator, true);
7339    
7340                            array[1] = dlFileEntry;
7341    
7342                            array[2] = getByF_N_PrevAndNext(session, dlFileEntry, folderId,
7343                                            name, orderByComparator, false);
7344    
7345                            return array;
7346                    }
7347                    catch (Exception e) {
7348                            throw processException(e);
7349                    }
7350                    finally {
7351                            closeSession(session);
7352                    }
7353            }
7354    
7355            protected DLFileEntry getByF_N_PrevAndNext(Session session,
7356                    DLFileEntry dlFileEntry, long folderId, String name,
7357                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
7358                    StringBundler query = null;
7359    
7360                    if (orderByComparator != null) {
7361                            query = new StringBundler(6 +
7362                                            (orderByComparator.getOrderByFields().length * 6));
7363                    }
7364                    else {
7365                            query = new StringBundler(3);
7366                    }
7367    
7368                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7369    
7370                    query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
7371    
7372                    boolean bindName = false;
7373    
7374                    if (name == null) {
7375                            query.append(_FINDER_COLUMN_F_N_NAME_1);
7376                    }
7377                    else if (name.equals(StringPool.BLANK)) {
7378                            query.append(_FINDER_COLUMN_F_N_NAME_3);
7379                    }
7380                    else {
7381                            bindName = true;
7382    
7383                            query.append(_FINDER_COLUMN_F_N_NAME_2);
7384                    }
7385    
7386                    if (orderByComparator != null) {
7387                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7388    
7389                            if (orderByConditionFields.length > 0) {
7390                                    query.append(WHERE_AND);
7391                            }
7392    
7393                            for (int i = 0; i < orderByConditionFields.length; i++) {
7394                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7395                                    query.append(orderByConditionFields[i]);
7396    
7397                                    if ((i + 1) < orderByConditionFields.length) {
7398                                            if (orderByComparator.isAscending() ^ previous) {
7399                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7400                                            }
7401                                            else {
7402                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7403                                            }
7404                                    }
7405                                    else {
7406                                            if (orderByComparator.isAscending() ^ previous) {
7407                                                    query.append(WHERE_GREATER_THAN);
7408                                            }
7409                                            else {
7410                                                    query.append(WHERE_LESSER_THAN);
7411                                            }
7412                                    }
7413                            }
7414    
7415                            query.append(ORDER_BY_CLAUSE);
7416    
7417                            String[] orderByFields = orderByComparator.getOrderByFields();
7418    
7419                            for (int i = 0; i < orderByFields.length; i++) {
7420                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7421                                    query.append(orderByFields[i]);
7422    
7423                                    if ((i + 1) < orderByFields.length) {
7424                                            if (orderByComparator.isAscending() ^ previous) {
7425                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7426                                            }
7427                                            else {
7428                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7429                                            }
7430                                    }
7431                                    else {
7432                                            if (orderByComparator.isAscending() ^ previous) {
7433                                                    query.append(ORDER_BY_ASC);
7434                                            }
7435                                            else {
7436                                                    query.append(ORDER_BY_DESC);
7437                                            }
7438                                    }
7439                            }
7440                    }
7441                    else {
7442                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7443                    }
7444    
7445                    String sql = query.toString();
7446    
7447                    Query q = session.createQuery(sql);
7448    
7449                    q.setFirstResult(0);
7450                    q.setMaxResults(2);
7451    
7452                    QueryPos qPos = QueryPos.getInstance(q);
7453    
7454                    qPos.add(folderId);
7455    
7456                    if (bindName) {
7457                            qPos.add(name);
7458                    }
7459    
7460                    if (orderByComparator != null) {
7461                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
7462    
7463                            for (Object value : values) {
7464                                    qPos.add(value);
7465                            }
7466                    }
7467    
7468                    List<DLFileEntry> list = q.list();
7469    
7470                    if (list.size() == 2) {
7471                            return list.get(1);
7472                    }
7473                    else {
7474                            return null;
7475                    }
7476            }
7477    
7478            /**
7479             * Removes all the document library file entries where folderId = &#63; and name = &#63; from the database.
7480             *
7481             * @param folderId the folder ID
7482             * @param name the name
7483             */
7484            @Override
7485            public void removeByF_N(long folderId, String name) {
7486                    for (DLFileEntry dlFileEntry : findByF_N(folderId, name,
7487                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7488                            remove(dlFileEntry);
7489                    }
7490            }
7491    
7492            /**
7493             * Returns the number of document library file entries where folderId = &#63; and name = &#63;.
7494             *
7495             * @param folderId the folder ID
7496             * @param name the name
7497             * @return the number of matching document library file entries
7498             */
7499            @Override
7500            public int countByF_N(long folderId, String name) {
7501                    FinderPath finderPath = FINDER_PATH_COUNT_BY_F_N;
7502    
7503                    Object[] finderArgs = new Object[] { folderId, name };
7504    
7505                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7506                                    this);
7507    
7508                    if (count == null) {
7509                            StringBundler query = new StringBundler(3);
7510    
7511                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7512    
7513                            query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
7514    
7515                            boolean bindName = false;
7516    
7517                            if (name == null) {
7518                                    query.append(_FINDER_COLUMN_F_N_NAME_1);
7519                            }
7520                            else if (name.equals(StringPool.BLANK)) {
7521                                    query.append(_FINDER_COLUMN_F_N_NAME_3);
7522                            }
7523                            else {
7524                                    bindName = true;
7525    
7526                                    query.append(_FINDER_COLUMN_F_N_NAME_2);
7527                            }
7528    
7529                            String sql = query.toString();
7530    
7531                            Session session = null;
7532    
7533                            try {
7534                                    session = openSession();
7535    
7536                                    Query q = session.createQuery(sql);
7537    
7538                                    QueryPos qPos = QueryPos.getInstance(q);
7539    
7540                                    qPos.add(folderId);
7541    
7542                                    if (bindName) {
7543                                            qPos.add(name);
7544                                    }
7545    
7546                                    count = (Long)q.uniqueResult();
7547    
7548                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7549                            }
7550                            catch (Exception e) {
7551                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7552    
7553                                    throw processException(e);
7554                            }
7555                            finally {
7556                                    closeSession(session);
7557                            }
7558                    }
7559    
7560                    return count.intValue();
7561            }
7562    
7563            private static final String _FINDER_COLUMN_F_N_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
7564            private static final String _FINDER_COLUMN_F_N_NAME_1 = "dlFileEntry.name IS NULL";
7565            private static final String _FINDER_COLUMN_F_N_NAME_2 = "dlFileEntry.name = ?";
7566            private static final String _FINDER_COLUMN_F_N_NAME_3 = "(dlFileEntry.name IS NULL OR dlFileEntry.name = '')";
7567            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7568                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
7569                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_F",
7570                            new String[] {
7571                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
7572                                    
7573                            Integer.class.getName(), Integer.class.getName(),
7574                                    OrderByComparator.class.getName()
7575                            });
7576            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7577                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
7578                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F",
7579                            new String[] {
7580                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
7581                            },
7582                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
7583                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK |
7584                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
7585                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
7586            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7587                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7588                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F",
7589                            new String[] {
7590                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
7591                            });
7592            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7593                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7594                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_F",
7595                            new String[] {
7596                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
7597                            });
7598    
7599            /**
7600             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7601             *
7602             * @param groupId the group ID
7603             * @param userId the user ID
7604             * @param folderId the folder ID
7605             * @return the matching document library file entries
7606             */
7607            @Override
7608            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7609                    long folderId) {
7610                    return findByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
7611                            QueryUtil.ALL_POS, null);
7612            }
7613    
7614            /**
7615             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7616             *
7617             * <p>
7618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
7619             * </p>
7620             *
7621             * @param groupId the group ID
7622             * @param userId the user ID
7623             * @param folderId the folder ID
7624             * @param start the lower bound of the range of document library file entries
7625             * @param end the upper bound of the range of document library file entries (not inclusive)
7626             * @return the range of matching document library file entries
7627             */
7628            @Override
7629            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7630                    long folderId, int start, int end) {
7631                    return findByG_U_F(groupId, userId, folderId, start, end, null);
7632            }
7633    
7634            /**
7635             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7636             *
7637             * <p>
7638             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
7639             * </p>
7640             *
7641             * @param groupId the group ID
7642             * @param userId the user ID
7643             * @param folderId the folder ID
7644             * @param start the lower bound of the range of document library file entries
7645             * @param end the upper bound of the range of document library file entries (not inclusive)
7646             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7647             * @return the ordered range of matching document library file entries
7648             */
7649            @Override
7650            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7651                    long folderId, int start, int end,
7652                    OrderByComparator<DLFileEntry> orderByComparator) {
7653                    boolean pagination = true;
7654                    FinderPath finderPath = null;
7655                    Object[] finderArgs = null;
7656    
7657                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7658                                    (orderByComparator == null)) {
7659                            pagination = false;
7660                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F;
7661                            finderArgs = new Object[] { groupId, userId, folderId };
7662                    }
7663                    else {
7664                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
7665                            finderArgs = new Object[] {
7666                                            groupId, userId, folderId,
7667                                            
7668                                            start, end, orderByComparator
7669                                    };
7670                    }
7671    
7672                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
7673                                    finderArgs, this);
7674    
7675                    if ((list != null) && !list.isEmpty()) {
7676                            for (DLFileEntry dlFileEntry : list) {
7677                                    if ((groupId != dlFileEntry.getGroupId()) ||
7678                                                    (userId != dlFileEntry.getUserId()) ||
7679                                                    (folderId != dlFileEntry.getFolderId())) {
7680                                            list = null;
7681    
7682                                            break;
7683                                    }
7684                            }
7685                    }
7686    
7687                    if (list == null) {
7688                            StringBundler query = null;
7689    
7690                            if (orderByComparator != null) {
7691                                    query = new StringBundler(5 +
7692                                                    (orderByComparator.getOrderByFields().length * 3));
7693                            }
7694                            else {
7695                                    query = new StringBundler(5);
7696                            }
7697    
7698                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7699    
7700                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7701    
7702                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7703    
7704                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7705    
7706                            if (orderByComparator != null) {
7707                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7708                                            orderByComparator);
7709                            }
7710                            else
7711                             if (pagination) {
7712                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7713                            }
7714    
7715                            String sql = query.toString();
7716    
7717                            Session session = null;
7718    
7719                            try {
7720                                    session = openSession();
7721    
7722                                    Query q = session.createQuery(sql);
7723    
7724                                    QueryPos qPos = QueryPos.getInstance(q);
7725    
7726                                    qPos.add(groupId);
7727    
7728                                    qPos.add(userId);
7729    
7730                                    qPos.add(folderId);
7731    
7732                                    if (!pagination) {
7733                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
7734                                                            start, end, false);
7735    
7736                                            Collections.sort(list);
7737    
7738                                            list = Collections.unmodifiableList(list);
7739                                    }
7740                                    else {
7741                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
7742                                                            start, end);
7743                                    }
7744    
7745                                    cacheResult(list);
7746    
7747                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7748                            }
7749                            catch (Exception e) {
7750                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7751    
7752                                    throw processException(e);
7753                            }
7754                            finally {
7755                                    closeSession(session);
7756                            }
7757                    }
7758    
7759                    return list;
7760            }
7761    
7762            /**
7763             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
7764             *
7765             * @param groupId the group ID
7766             * @param userId the user ID
7767             * @param folderId the folder ID
7768             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7769             * @return the first matching document library file entry
7770             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
7771             */
7772            @Override
7773            public DLFileEntry findByG_U_F_First(long groupId, long userId,
7774                    long folderId, OrderByComparator<DLFileEntry> orderByComparator)
7775                    throws NoSuchFileEntryException {
7776                    DLFileEntry dlFileEntry = fetchByG_U_F_First(groupId, userId, folderId,
7777                                    orderByComparator);
7778    
7779                    if (dlFileEntry != null) {
7780                            return dlFileEntry;
7781                    }
7782    
7783                    StringBundler msg = new StringBundler(8);
7784    
7785                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7786    
7787                    msg.append("groupId=");
7788                    msg.append(groupId);
7789    
7790                    msg.append(", userId=");
7791                    msg.append(userId);
7792    
7793                    msg.append(", folderId=");
7794                    msg.append(folderId);
7795    
7796                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7797    
7798                    throw new NoSuchFileEntryException(msg.toString());
7799            }
7800    
7801            /**
7802             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
7803             *
7804             * @param groupId the group ID
7805             * @param userId the user ID
7806             * @param folderId the folder ID
7807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7808             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7809             */
7810            @Override
7811            public DLFileEntry fetchByG_U_F_First(long groupId, long userId,
7812                    long folderId, OrderByComparator<DLFileEntry> orderByComparator) {
7813                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId, 0, 1,
7814                                    orderByComparator);
7815    
7816                    if (!list.isEmpty()) {
7817                            return list.get(0);
7818                    }
7819    
7820                    return null;
7821            }
7822    
7823            /**
7824             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
7825             *
7826             * @param groupId the group ID
7827             * @param userId the user ID
7828             * @param folderId the folder ID
7829             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7830             * @return the last matching document library file entry
7831             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
7832             */
7833            @Override
7834            public DLFileEntry findByG_U_F_Last(long groupId, long userId,
7835                    long folderId, OrderByComparator<DLFileEntry> orderByComparator)
7836                    throws NoSuchFileEntryException {
7837                    DLFileEntry dlFileEntry = fetchByG_U_F_Last(groupId, userId, folderId,
7838                                    orderByComparator);
7839    
7840                    if (dlFileEntry != null) {
7841                            return dlFileEntry;
7842                    }
7843    
7844                    StringBundler msg = new StringBundler(8);
7845    
7846                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7847    
7848                    msg.append("groupId=");
7849                    msg.append(groupId);
7850    
7851                    msg.append(", userId=");
7852                    msg.append(userId);
7853    
7854                    msg.append(", folderId=");
7855                    msg.append(folderId);
7856    
7857                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7858    
7859                    throw new NoSuchFileEntryException(msg.toString());
7860            }
7861    
7862            /**
7863             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
7864             *
7865             * @param groupId the group ID
7866             * @param userId the user ID
7867             * @param folderId the folder ID
7868             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7869             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7870             */
7871            @Override
7872            public DLFileEntry fetchByG_U_F_Last(long groupId, long userId,
7873                    long folderId, OrderByComparator<DLFileEntry> orderByComparator) {
7874                    int count = countByG_U_F(groupId, userId, folderId);
7875    
7876                    if (count == 0) {
7877                            return null;
7878                    }
7879    
7880                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId,
7881                                    count - 1, count, orderByComparator);
7882    
7883                    if (!list.isEmpty()) {
7884                            return list.get(0);
7885                    }
7886    
7887                    return null;
7888            }
7889    
7890            /**
7891             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
7892             *
7893             * @param fileEntryId the primary key of the current document library file entry
7894             * @param groupId the group ID
7895             * @param userId the user ID
7896             * @param folderId the folder ID
7897             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7898             * @return the previous, current, and next document library file entry
7899             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
7900             */
7901            @Override
7902            public DLFileEntry[] findByG_U_F_PrevAndNext(long fileEntryId,
7903                    long groupId, long userId, long folderId,
7904                    OrderByComparator<DLFileEntry> orderByComparator)
7905                    throws NoSuchFileEntryException {
7906                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
7907    
7908                    Session session = null;
7909    
7910                    try {
7911                            session = openSession();
7912    
7913                            DLFileEntry[] array = new DLFileEntryImpl[3];
7914    
7915                            array[0] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
7916                                            userId, folderId, orderByComparator, true);
7917    
7918                            array[1] = dlFileEntry;
7919    
7920                            array[2] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
7921                                            userId, folderId, orderByComparator, false);
7922    
7923                            return array;
7924                    }
7925                    catch (Exception e) {
7926                            throw processException(e);
7927                    }
7928                    finally {
7929                            closeSession(session);
7930                    }
7931            }
7932    
7933            protected DLFileEntry getByG_U_F_PrevAndNext(Session session,
7934                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
7935                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
7936                    StringBundler query = null;
7937    
7938                    if (orderByComparator != null) {
7939                            query = new StringBundler(6 +
7940                                            (orderByComparator.getOrderByFields().length * 6));
7941                    }
7942                    else {
7943                            query = new StringBundler(3);
7944                    }
7945    
7946                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7947    
7948                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7949    
7950                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7951    
7952                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7953    
7954                    if (orderByComparator != null) {
7955                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7956    
7957                            if (orderByConditionFields.length > 0) {
7958                                    query.append(WHERE_AND);
7959                            }
7960    
7961                            for (int i = 0; i < orderByConditionFields.length; i++) {
7962                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7963                                    query.append(orderByConditionFields[i]);
7964    
7965                                    if ((i + 1) < orderByConditionFields.length) {
7966                                            if (orderByComparator.isAscending() ^ previous) {
7967                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7968                                            }
7969                                            else {
7970                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7971                                            }
7972                                    }
7973                                    else {
7974                                            if (orderByComparator.isAscending() ^ previous) {
7975                                                    query.append(WHERE_GREATER_THAN);
7976                                            }
7977                                            else {
7978                                                    query.append(WHERE_LESSER_THAN);
7979                                            }
7980                                    }
7981                            }
7982    
7983                            query.append(ORDER_BY_CLAUSE);
7984    
7985                            String[] orderByFields = orderByComparator.getOrderByFields();
7986    
7987                            for (int i = 0; i < orderByFields.length; i++) {
7988                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7989                                    query.append(orderByFields[i]);
7990    
7991                                    if ((i + 1) < orderByFields.length) {
7992                                            if (orderByComparator.isAscending() ^ previous) {
7993                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7994                                            }
7995                                            else {
7996                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7997                                            }
7998                                    }
7999                                    else {
8000                                            if (orderByComparator.isAscending() ^ previous) {
8001                                                    query.append(ORDER_BY_ASC);
8002                                            }
8003                                            else {
8004                                                    query.append(ORDER_BY_DESC);
8005                                            }
8006                                    }
8007                            }
8008                    }
8009                    else {
8010                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8011                    }
8012    
8013                    String sql = query.toString();
8014    
8015                    Query q = session.createQuery(sql);
8016    
8017                    q.setFirstResult(0);
8018                    q.setMaxResults(2);
8019    
8020                    QueryPos qPos = QueryPos.getInstance(q);
8021    
8022                    qPos.add(groupId);
8023    
8024                    qPos.add(userId);
8025    
8026                    qPos.add(folderId);
8027    
8028                    if (orderByComparator != null) {
8029                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
8030    
8031                            for (Object value : values) {
8032                                    qPos.add(value);
8033                            }
8034                    }
8035    
8036                    List<DLFileEntry> list = q.list();
8037    
8038                    if (list.size() == 2) {
8039                            return list.get(1);
8040                    }
8041                    else {
8042                            return null;
8043                    }
8044            }
8045    
8046            /**
8047             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
8048             *
8049             * @param groupId the group ID
8050             * @param userId the user ID
8051             * @param folderId the folder ID
8052             * @return the matching document library file entries that the user has permission to view
8053             */
8054            @Override
8055            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8056                    long folderId) {
8057                    return filterFindByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
8058                            QueryUtil.ALL_POS, null);
8059            }
8060    
8061            /**
8062             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
8063             *
8064             * <p>
8065             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
8066             * </p>
8067             *
8068             * @param groupId the group ID
8069             * @param userId the user ID
8070             * @param folderId the folder ID
8071             * @param start the lower bound of the range of document library file entries
8072             * @param end the upper bound of the range of document library file entries (not inclusive)
8073             * @return the range of matching document library file entries that the user has permission to view
8074             */
8075            @Override
8076            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8077                    long folderId, int start, int end) {
8078                    return filterFindByG_U_F(groupId, userId, folderId, start, end, null);
8079            }
8080    
8081            /**
8082             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
8083             *
8084             * <p>
8085             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
8086             * </p>
8087             *
8088             * @param groupId the group ID
8089             * @param userId the user ID
8090             * @param folderId the folder ID
8091             * @param start the lower bound of the range of document library file entries
8092             * @param end the upper bound of the range of document library file entries (not inclusive)
8093             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8094             * @return the ordered range of matching document library file entries that the user has permission to view
8095             */
8096            @Override
8097            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8098                    long folderId, int start, int end,
8099                    OrderByComparator<DLFileEntry> orderByComparator) {
8100                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8101                            return findByG_U_F(groupId, userId, folderId, start, end,
8102                                    orderByComparator);
8103                    }
8104    
8105                    StringBundler query = null;
8106    
8107                    if (orderByComparator != null) {
8108                            query = new StringBundler(5 +
8109                                            (orderByComparator.getOrderByFields().length * 3));
8110                    }
8111                    else {
8112                            query = new StringBundler(5);
8113                    }
8114    
8115                    if (getDB().isSupportsInlineDistinct()) {
8116                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
8117                    }
8118                    else {
8119                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
8120                    }
8121    
8122                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8123    
8124                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8125    
8126                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8127    
8128                    if (!getDB().isSupportsInlineDistinct()) {
8129                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
8130                    }
8131    
8132                    if (orderByComparator != null) {
8133                            if (getDB().isSupportsInlineDistinct()) {
8134                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8135                                            orderByComparator, true);
8136                            }
8137                            else {
8138                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8139                                            orderByComparator, true);
8140                            }
8141                    }
8142                    else {
8143                            if (getDB().isSupportsInlineDistinct()) {
8144                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8145                            }
8146                            else {
8147                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
8148                            }
8149                    }
8150    
8151                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8152                                    DLFileEntry.class.getName(),
8153                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8154    
8155                    Session session = null;
8156    
8157                    try {
8158                            session = openSession();
8159    
8160                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8161    
8162                            if (getDB().isSupportsInlineDistinct()) {
8163                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
8164                            }
8165                            else {
8166                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
8167                            }
8168    
8169                            QueryPos qPos = QueryPos.getInstance(q);
8170    
8171                            qPos.add(groupId);
8172    
8173                            qPos.add(userId);
8174    
8175                            qPos.add(folderId);
8176    
8177                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
8178                    }
8179                    catch (Exception e) {
8180                            throw processException(e);
8181                    }
8182                    finally {
8183                            closeSession(session);
8184                    }
8185            }
8186    
8187            /**
8188             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
8189             *
8190             * @param fileEntryId the primary key of the current document library file entry
8191             * @param groupId the group ID
8192             * @param userId the user ID
8193             * @param folderId the folder ID
8194             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8195             * @return the previous, current, and next document library file entry
8196             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
8197             */
8198            @Override
8199            public DLFileEntry[] filterFindByG_U_F_PrevAndNext(long fileEntryId,
8200                    long groupId, long userId, long folderId,
8201                    OrderByComparator<DLFileEntry> orderByComparator)
8202                    throws NoSuchFileEntryException {
8203                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8204                            return findByG_U_F_PrevAndNext(fileEntryId, groupId, userId,
8205                                    folderId, orderByComparator);
8206                    }
8207    
8208                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
8209    
8210                    Session session = null;
8211    
8212                    try {
8213                            session = openSession();
8214    
8215                            DLFileEntry[] array = new DLFileEntryImpl[3];
8216    
8217                            array[0] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
8218                                            groupId, userId, folderId, orderByComparator, true);
8219    
8220                            array[1] = dlFileEntry;
8221    
8222                            array[2] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
8223                                            groupId, userId, folderId, orderByComparator, false);
8224    
8225                            return array;
8226                    }
8227                    catch (Exception e) {
8228                            throw processException(e);
8229                    }
8230                    finally {
8231                            closeSession(session);
8232                    }
8233            }
8234    
8235            protected DLFileEntry filterGetByG_U_F_PrevAndNext(Session session,
8236                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
8237                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
8238                    StringBundler query = null;
8239    
8240                    if (orderByComparator != null) {
8241                            query = new StringBundler(6 +
8242                                            (orderByComparator.getOrderByFields().length * 6));
8243                    }
8244                    else {
8245                            query = new StringBundler(3);
8246                    }
8247    
8248                    if (getDB().isSupportsInlineDistinct()) {
8249                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
8250                    }
8251                    else {
8252                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
8253                    }
8254    
8255                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8256    
8257                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8258    
8259                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8260    
8261                    if (!getDB().isSupportsInlineDistinct()) {
8262                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
8263                    }
8264    
8265                    if (orderByComparator != null) {
8266                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8267    
8268                            if (orderByConditionFields.length > 0) {
8269                                    query.append(WHERE_AND);
8270                            }
8271    
8272                            for (int i = 0; i < orderByConditionFields.length; i++) {
8273                                    if (getDB().isSupportsInlineDistinct()) {
8274                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8275                                    }
8276                                    else {
8277                                            query.append(_ORDER_BY_ENTITY_TABLE);
8278                                    }
8279    
8280                                    query.append(orderByConditionFields[i]);
8281    
8282                                    if ((i + 1) < orderByConditionFields.length) {
8283                                            if (orderByComparator.isAscending() ^ previous) {
8284                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8285                                            }
8286                                            else {
8287                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8288                                            }
8289                                    }
8290                                    else {
8291                                            if (orderByComparator.isAscending() ^ previous) {
8292                                                    query.append(WHERE_GREATER_THAN);
8293                                            }
8294                                            else {
8295                                                    query.append(WHERE_LESSER_THAN);
8296                                            }
8297                                    }
8298                            }
8299    
8300                            query.append(ORDER_BY_CLAUSE);
8301    
8302                            String[] orderByFields = orderByComparator.getOrderByFields();
8303    
8304                            for (int i = 0; i < orderByFields.length; i++) {
8305                                    if (getDB().isSupportsInlineDistinct()) {
8306                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8307                                    }
8308                                    else {
8309                                            query.append(_ORDER_BY_ENTITY_TABLE);
8310                                    }
8311    
8312                                    query.append(orderByFields[i]);
8313    
8314                                    if ((i + 1) < orderByFields.length) {
8315                                            if (orderByComparator.isAscending() ^ previous) {
8316                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8317                                            }
8318                                            else {
8319                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8320                                            }
8321                                    }
8322                                    else {
8323                                            if (orderByComparator.isAscending() ^ previous) {
8324                                                    query.append(ORDER_BY_ASC);
8325                                            }
8326                                            else {
8327                                                    query.append(ORDER_BY_DESC);
8328                                            }
8329                                    }
8330                            }
8331                    }
8332                    else {
8333                            if (getDB().isSupportsInlineDistinct()) {
8334                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8335                            }
8336                            else {
8337                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
8338                            }
8339                    }
8340    
8341                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8342                                    DLFileEntry.class.getName(),
8343                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8344    
8345                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
8346    
8347                    q.setFirstResult(0);
8348                    q.setMaxResults(2);
8349    
8350                    if (getDB().isSupportsInlineDistinct()) {
8351                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
8352                    }
8353                    else {
8354                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
8355                    }
8356    
8357                    QueryPos qPos = QueryPos.getInstance(q);
8358    
8359                    qPos.add(groupId);
8360    
8361                    qPos.add(userId);
8362    
8363                    qPos.add(folderId);
8364    
8365                    if (orderByComparator != null) {
8366                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
8367    
8368                            for (Object value : values) {
8369                                    qPos.add(value);
8370                            }
8371                    }
8372    
8373                    List<DLFileEntry> list = q.list();
8374    
8375                    if (list.size() == 2) {
8376                            return list.get(1);
8377                    }
8378                    else {
8379                            return null;
8380                    }
8381            }
8382    
8383            /**
8384             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8385             *
8386             * @param groupId the group ID
8387             * @param userId the user ID
8388             * @param folderIds the folder IDs
8389             * @return the matching document library file entries that the user has permission to view
8390             */
8391            @Override
8392            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8393                    long[] folderIds) {
8394                    return filterFindByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
8395                            QueryUtil.ALL_POS, null);
8396            }
8397    
8398            /**
8399             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8400             *
8401             * <p>
8402             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
8403             * </p>
8404             *
8405             * @param groupId the group ID
8406             * @param userId the user ID
8407             * @param folderIds the folder IDs
8408             * @param start the lower bound of the range of document library file entries
8409             * @param end the upper bound of the range of document library file entries (not inclusive)
8410             * @return the range of matching document library file entries that the user has permission to view
8411             */
8412            @Override
8413            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8414                    long[] folderIds, int start, int end) {
8415                    return filterFindByG_U_F(groupId, userId, folderIds, start, end, null);
8416            }
8417    
8418            /**
8419             * Returns an ordered range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8420             *
8421             * <p>
8422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
8423             * </p>
8424             *
8425             * @param groupId the group ID
8426             * @param userId the user ID
8427             * @param folderIds the folder IDs
8428             * @param start the lower bound of the range of document library file entries
8429             * @param end the upper bound of the range of document library file entries (not inclusive)
8430             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8431             * @return the ordered range of matching document library file entries that the user has permission to view
8432             */
8433            @Override
8434            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8435                    long[] folderIds, int start, int end,
8436                    OrderByComparator<DLFileEntry> orderByComparator) {
8437                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8438                            return findByG_U_F(groupId, userId, folderIds, start, end,
8439                                    orderByComparator);
8440                    }
8441    
8442                    if (folderIds == null) {
8443                            folderIds = new long[0];
8444                    }
8445                    else {
8446                            folderIds = ArrayUtil.unique(folderIds);
8447                    }
8448    
8449                    StringBundler query = new StringBundler();
8450    
8451                    if (getDB().isSupportsInlineDistinct()) {
8452                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
8453                    }
8454                    else {
8455                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
8456                    }
8457    
8458                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8459    
8460                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8461    
8462                    if (folderIds.length > 0) {
8463                            query.append(StringPool.OPEN_PARENTHESIS);
8464    
8465                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_7);
8466    
8467                            query.append(StringUtil.merge(folderIds));
8468    
8469                            query.append(StringPool.CLOSE_PARENTHESIS);
8470    
8471                            query.append(StringPool.CLOSE_PARENTHESIS);
8472                    }
8473    
8474                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8475                            query.index() - 1);
8476    
8477                    if (!getDB().isSupportsInlineDistinct()) {
8478                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
8479                    }
8480    
8481                    if (orderByComparator != null) {
8482                            if (getDB().isSupportsInlineDistinct()) {
8483                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8484                                            orderByComparator, true);
8485                            }
8486                            else {
8487                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8488                                            orderByComparator, true);
8489                            }
8490                    }
8491                    else {
8492                            if (getDB().isSupportsInlineDistinct()) {
8493                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8494                            }
8495                            else {
8496                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
8497                            }
8498                    }
8499    
8500                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8501                                    DLFileEntry.class.getName(),
8502                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8503    
8504                    Session session = null;
8505    
8506                    try {
8507                            session = openSession();
8508    
8509                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8510    
8511                            if (getDB().isSupportsInlineDistinct()) {
8512                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
8513                            }
8514                            else {
8515                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
8516                            }
8517    
8518                            QueryPos qPos = QueryPos.getInstance(q);
8519    
8520                            qPos.add(groupId);
8521    
8522                            qPos.add(userId);
8523    
8524                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
8525                    }
8526                    catch (Exception e) {
8527                            throw processException(e);
8528                    }
8529                    finally {
8530                            closeSession(session);
8531                    }
8532            }
8533    
8534            /**
8535             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8536             *
8537             * <p>
8538             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
8539             * </p>
8540             *
8541             * @param groupId the group ID
8542             * @param userId the user ID
8543             * @param folderIds the folder IDs
8544             * @return the matching document library file entries
8545             */
8546            @Override
8547            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
8548                    long[] folderIds) {
8549                    return findByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
8550                            QueryUtil.ALL_POS, null);
8551            }
8552    
8553            /**
8554             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8555             *
8556             * <p>
8557             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
8558             * </p>
8559             *
8560             * @param groupId the group ID
8561             * @param userId the user ID
8562             * @param folderIds the folder IDs
8563             * @param start the lower bound of the range of document library file entries
8564             * @param end the upper bound of the range of document library file entries (not inclusive)
8565             * @return the range of matching document library file entries
8566             */
8567            @Override
8568            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
8569                    long[] folderIds, int start, int end) {
8570                    return findByG_U_F(groupId, userId, folderIds, start, end, null);
8571            }
8572    
8573            /**
8574             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8575             *
8576             * <p>
8577             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
8578             * </p>
8579             *
8580             * @param groupId the group ID
8581             * @param userId the user ID
8582             * @param folderIds the folder IDs
8583             * @param start the lower bound of the range of document library file entries
8584             * @param end the upper bound of the range of document library file entries (not inclusive)
8585             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8586             * @return the ordered range of matching document library file entries
8587             */
8588            @Override
8589            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
8590                    long[] folderIds, int start, int end,
8591                    OrderByComparator<DLFileEntry> orderByComparator) {
8592                    if (folderIds == null) {
8593                            folderIds = new long[0];
8594                    }
8595                    else {
8596                            folderIds = ArrayUtil.unique(folderIds);
8597                    }
8598    
8599                    if (folderIds.length == 1) {
8600                            return findByG_U_F(groupId, userId, folderIds[0], start, end,
8601                                    orderByComparator);
8602                    }
8603    
8604                    boolean pagination = true;
8605                    Object[] finderArgs = null;
8606    
8607                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8608                                    (orderByComparator == null)) {
8609                            pagination = false;
8610                            finderArgs = new Object[] {
8611                                            groupId, userId, StringUtil.merge(folderIds)
8612                                    };
8613                    }
8614                    else {
8615                            finderArgs = new Object[] {
8616                                            groupId, userId, StringUtil.merge(folderIds),
8617                                            
8618                                            start, end, orderByComparator
8619                                    };
8620                    }
8621    
8622                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
8623                                    finderArgs, this);
8624    
8625                    if ((list != null) && !list.isEmpty()) {
8626                            for (DLFileEntry dlFileEntry : list) {
8627                                    if ((groupId != dlFileEntry.getGroupId()) ||
8628                                                    (userId != dlFileEntry.getUserId()) ||
8629                                                    !ArrayUtil.contains(folderIds, dlFileEntry.getFolderId())) {
8630                                            list = null;
8631    
8632                                            break;
8633                                    }
8634                            }
8635                    }
8636    
8637                    if (list == null) {
8638                            StringBundler query = new StringBundler();
8639    
8640                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
8641    
8642                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8643    
8644                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8645    
8646                            if (folderIds.length > 0) {
8647                                    query.append(StringPool.OPEN_PARENTHESIS);
8648    
8649                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_7);
8650    
8651                                    query.append(StringUtil.merge(folderIds));
8652    
8653                                    query.append(StringPool.CLOSE_PARENTHESIS);
8654    
8655                                    query.append(StringPool.CLOSE_PARENTHESIS);
8656                            }
8657    
8658                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
8659                                                    1)), query.index() - 1);
8660    
8661                            if (orderByComparator != null) {
8662                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8663                                            orderByComparator);
8664                            }
8665                            else
8666                             if (pagination) {
8667                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8668                            }
8669    
8670                            String sql = query.toString();
8671    
8672                            Session session = null;
8673    
8674                            try {
8675                                    session = openSession();
8676    
8677                                    Query q = session.createQuery(sql);
8678    
8679                                    QueryPos qPos = QueryPos.getInstance(q);
8680    
8681                                    qPos.add(groupId);
8682    
8683                                    qPos.add(userId);
8684    
8685                                    if (!pagination) {
8686                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
8687                                                            start, end, false);
8688    
8689                                            Collections.sort(list);
8690    
8691                                            list = Collections.unmodifiableList(list);
8692                                    }
8693                                    else {
8694                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
8695                                                            start, end);
8696                                    }
8697    
8698                                    cacheResult(list);
8699    
8700                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
8701                                            finderArgs, list);
8702                            }
8703                            catch (Exception e) {
8704                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
8705                                            finderArgs);
8706    
8707                                    throw processException(e);
8708                            }
8709                            finally {
8710                                    closeSession(session);
8711                            }
8712                    }
8713    
8714                    return list;
8715            }
8716    
8717            /**
8718             * Removes all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63; from the database.
8719             *
8720             * @param groupId the group ID
8721             * @param userId the user ID
8722             * @param folderId the folder ID
8723             */
8724            @Override
8725            public void removeByG_U_F(long groupId, long userId, long folderId) {
8726                    for (DLFileEntry dlFileEntry : findByG_U_F(groupId, userId, folderId,
8727                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8728                            remove(dlFileEntry);
8729                    }
8730            }
8731    
8732            /**
8733             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
8734             *
8735             * @param groupId the group ID
8736             * @param userId the user ID
8737             * @param folderId the folder ID
8738             * @return the number of matching document library file entries
8739             */
8740            @Override
8741            public int countByG_U_F(long groupId, long userId, long folderId) {
8742                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_F;
8743    
8744                    Object[] finderArgs = new Object[] { groupId, userId, folderId };
8745    
8746                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8747                                    this);
8748    
8749                    if (count == null) {
8750                            StringBundler query = new StringBundler(4);
8751    
8752                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8753    
8754                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8755    
8756                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8757    
8758                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8759    
8760                            String sql = query.toString();
8761    
8762                            Session session = null;
8763    
8764                            try {
8765                                    session = openSession();
8766    
8767                                    Query q = session.createQuery(sql);
8768    
8769                                    QueryPos qPos = QueryPos.getInstance(q);
8770    
8771                                    qPos.add(groupId);
8772    
8773                                    qPos.add(userId);
8774    
8775                                    qPos.add(folderId);
8776    
8777                                    count = (Long)q.uniqueResult();
8778    
8779                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8780                            }
8781                            catch (Exception e) {
8782                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8783    
8784                                    throw processException(e);
8785                            }
8786                            finally {
8787                                    closeSession(session);
8788                            }
8789                    }
8790    
8791                    return count.intValue();
8792            }
8793    
8794            /**
8795             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8796             *
8797             * @param groupId the group ID
8798             * @param userId the user ID
8799             * @param folderIds the folder IDs
8800             * @return the number of matching document library file entries
8801             */
8802            @Override
8803            public int countByG_U_F(long groupId, long userId, long[] folderIds) {
8804                    if (folderIds == null) {
8805                            folderIds = new long[0];
8806                    }
8807                    else {
8808                            folderIds = ArrayUtil.unique(folderIds);
8809                    }
8810    
8811                    Object[] finderArgs = new Object[] {
8812                                    groupId, userId, StringUtil.merge(folderIds)
8813                            };
8814    
8815                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
8816                                    finderArgs, this);
8817    
8818                    if (count == null) {
8819                            StringBundler query = new StringBundler();
8820    
8821                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8822    
8823                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8824    
8825                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8826    
8827                            if (folderIds.length > 0) {
8828                                    query.append(StringPool.OPEN_PARENTHESIS);
8829    
8830                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_7);
8831    
8832                                    query.append(StringUtil.merge(folderIds));
8833    
8834                                    query.append(StringPool.CLOSE_PARENTHESIS);
8835    
8836                                    query.append(StringPool.CLOSE_PARENTHESIS);
8837                            }
8838    
8839                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
8840                                                    1)), query.index() - 1);
8841    
8842                            String sql = query.toString();
8843    
8844                            Session session = null;
8845    
8846                            try {
8847                                    session = openSession();
8848    
8849                                    Query q = session.createQuery(sql);
8850    
8851                                    QueryPos qPos = QueryPos.getInstance(q);
8852    
8853                                    qPos.add(groupId);
8854    
8855                                    qPos.add(userId);
8856    
8857                                    count = (Long)q.uniqueResult();
8858    
8859                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
8860                                            finderArgs, count);
8861                            }
8862                            catch (Exception e) {
8863                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
8864                                            finderArgs);
8865    
8866                                    throw processException(e);
8867                            }
8868                            finally {
8869                                    closeSession(session);
8870                            }
8871                    }
8872    
8873                    return count.intValue();
8874            }
8875    
8876            /**
8877             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
8878             *
8879             * @param groupId the group ID
8880             * @param userId the user ID
8881             * @param folderId the folder ID
8882             * @return the number of matching document library file entries that the user has permission to view
8883             */
8884            @Override
8885            public int filterCountByG_U_F(long groupId, long userId, long folderId) {
8886                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8887                            return countByG_U_F(groupId, userId, folderId);
8888                    }
8889    
8890                    StringBundler query = new StringBundler(4);
8891    
8892                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
8893    
8894                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8895    
8896                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8897    
8898                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8899    
8900                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8901                                    DLFileEntry.class.getName(),
8902                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8903    
8904                    Session session = null;
8905    
8906                    try {
8907                            session = openSession();
8908    
8909                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8910    
8911                            q.addScalar(COUNT_COLUMN_NAME,
8912                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8913    
8914                            QueryPos qPos = QueryPos.getInstance(q);
8915    
8916                            qPos.add(groupId);
8917    
8918                            qPos.add(userId);
8919    
8920                            qPos.add(folderId);
8921    
8922                            Long count = (Long)q.uniqueResult();
8923    
8924                            return count.intValue();
8925                    }
8926                    catch (Exception e) {
8927                            throw processException(e);
8928                    }
8929                    finally {
8930                            closeSession(session);
8931                    }
8932            }
8933    
8934            /**
8935             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8936             *
8937             * @param groupId the group ID
8938             * @param userId the user ID
8939             * @param folderIds the folder IDs
8940             * @return the number of matching document library file entries that the user has permission to view
8941             */
8942            @Override
8943            public int filterCountByG_U_F(long groupId, long userId, long[] folderIds) {
8944                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8945                            return countByG_U_F(groupId, userId, folderIds);
8946                    }
8947    
8948                    if (folderIds == null) {
8949                            folderIds = new long[0];
8950                    }
8951                    else {
8952                            folderIds = ArrayUtil.unique(folderIds);
8953                    }
8954    
8955                    StringBundler query = new StringBundler();
8956    
8957                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
8958    
8959                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8960    
8961                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8962    
8963                    if (folderIds.length > 0) {
8964                            query.append(StringPool.OPEN_PARENTHESIS);
8965    
8966                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_7);
8967    
8968                            query.append(StringUtil.merge(folderIds));
8969    
8970                            query.append(StringPool.CLOSE_PARENTHESIS);
8971    
8972                            query.append(StringPool.CLOSE_PARENTHESIS);
8973                    }
8974    
8975                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8976                            query.index() - 1);
8977    
8978                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8979                                    DLFileEntry.class.getName(),
8980                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8981    
8982                    Session session = null;
8983    
8984                    try {
8985                            session = openSession();
8986    
8987                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8988    
8989                            q.addScalar(COUNT_COLUMN_NAME,
8990                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8991    
8992                            QueryPos qPos = QueryPos.getInstance(q);
8993    
8994                            qPos.add(groupId);
8995    
8996                            qPos.add(userId);
8997    
8998                            Long count = (Long)q.uniqueResult();
8999    
9000                            return count.intValue();
9001                    }
9002                    catch (Exception e) {
9003                            throw processException(e);
9004                    }
9005                    finally {
9006                            closeSession(session);
9007                    }
9008            }
9009    
9010            private static final String _FINDER_COLUMN_G_U_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
9011            private static final String _FINDER_COLUMN_G_U_F_USERID_2 = "dlFileEntry.userId = ? AND ";
9012            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
9013            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_7 = "dlFileEntry.folderId IN (";
9014            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9015                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
9016                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_N",
9017                            new String[] {
9018                                    Long.class.getName(), Long.class.getName(),
9019                                    String.class.getName()
9020                            },
9021                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
9022                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
9023                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
9024            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9025                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9026                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_N",
9027                            new String[] {
9028                                    Long.class.getName(), Long.class.getName(),
9029                                    String.class.getName()
9030                            });
9031    
9032            /**
9033             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; or throws a {@link NoSuchFileEntryException} if it could not be found.
9034             *
9035             * @param groupId the group ID
9036             * @param folderId the folder ID
9037             * @param name the name
9038             * @return the matching document library file entry
9039             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
9040             */
9041            @Override
9042            public DLFileEntry findByG_F_N(long groupId, long folderId, String name)
9043                    throws NoSuchFileEntryException {
9044                    DLFileEntry dlFileEntry = fetchByG_F_N(groupId, folderId, name);
9045    
9046                    if (dlFileEntry == null) {
9047                            StringBundler msg = new StringBundler(8);
9048    
9049                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9050    
9051                            msg.append("groupId=");
9052                            msg.append(groupId);
9053    
9054                            msg.append(", folderId=");
9055                            msg.append(folderId);
9056    
9057                            msg.append(", name=");
9058                            msg.append(name);
9059    
9060                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9061    
9062                            if (_log.isWarnEnabled()) {
9063                                    _log.warn(msg.toString());
9064                            }
9065    
9066                            throw new NoSuchFileEntryException(msg.toString());
9067                    }
9068    
9069                    return dlFileEntry;
9070            }
9071    
9072            /**
9073             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
9074             *
9075             * @param groupId the group ID
9076             * @param folderId the folder ID
9077             * @param name the name
9078             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9079             */
9080            @Override
9081            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name) {
9082                    return fetchByG_F_N(groupId, folderId, name, true);
9083            }
9084    
9085            /**
9086             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
9087             *
9088             * @param groupId the group ID
9089             * @param folderId the folder ID
9090             * @param name the name
9091             * @param retrieveFromCache whether to use the finder cache
9092             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9093             */
9094            @Override
9095            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name,
9096                    boolean retrieveFromCache) {
9097                    Object[] finderArgs = new Object[] { groupId, folderId, name };
9098    
9099                    Object result = null;
9100    
9101                    if (retrieveFromCache) {
9102                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_N,
9103                                            finderArgs, this);
9104                    }
9105    
9106                    if (result instanceof DLFileEntry) {
9107                            DLFileEntry dlFileEntry = (DLFileEntry)result;
9108    
9109                            if ((groupId != dlFileEntry.getGroupId()) ||
9110                                            (folderId != dlFileEntry.getFolderId()) ||
9111                                            !Validator.equals(name, dlFileEntry.getName())) {
9112                                    result = null;
9113                            }
9114                    }
9115    
9116                    if (result == null) {
9117                            StringBundler query = new StringBundler(5);
9118    
9119                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9120    
9121                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
9122    
9123                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
9124    
9125                            boolean bindName = false;
9126    
9127                            if (name == null) {
9128                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
9129                            }
9130                            else if (name.equals(StringPool.BLANK)) {
9131                                    query.append(_FINDER_COLUMN_G_F_N_NAME_3);
9132                            }
9133                            else {
9134                                    bindName = true;
9135    
9136                                    query.append(_FINDER_COLUMN_G_F_N_NAME_2);
9137                            }
9138    
9139                            String sql = query.toString();
9140    
9141                            Session session = null;
9142    
9143                            try {
9144                                    session = openSession();
9145    
9146                                    Query q = session.createQuery(sql);
9147    
9148                                    QueryPos qPos = QueryPos.getInstance(q);
9149    
9150                                    qPos.add(groupId);
9151    
9152                                    qPos.add(folderId);
9153    
9154                                    if (bindName) {
9155                                            qPos.add(name);
9156                                    }
9157    
9158                                    List<DLFileEntry> list = q.list();
9159    
9160                                    if (list.isEmpty()) {
9161                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
9162                                                    finderArgs, list);
9163                                    }
9164                                    else {
9165                                            DLFileEntry dlFileEntry = list.get(0);
9166    
9167                                            result = dlFileEntry;
9168    
9169                                            cacheResult(dlFileEntry);
9170    
9171                                            if ((dlFileEntry.getGroupId() != groupId) ||
9172                                                            (dlFileEntry.getFolderId() != folderId) ||
9173                                                            (dlFileEntry.getName() == null) ||
9174                                                            !dlFileEntry.getName().equals(name)) {
9175                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
9176                                                            finderArgs, dlFileEntry);
9177                                            }
9178                                    }
9179                            }
9180                            catch (Exception e) {
9181                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
9182                                            finderArgs);
9183    
9184                                    throw processException(e);
9185                            }
9186                            finally {
9187                                    closeSession(session);
9188                            }
9189                    }
9190    
9191                    if (result instanceof List<?>) {
9192                            return null;
9193                    }
9194                    else {
9195                            return (DLFileEntry)result;
9196                    }
9197            }
9198    
9199            /**
9200             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; from the database.
9201             *
9202             * @param groupId the group ID
9203             * @param folderId the folder ID
9204             * @param name the name
9205             * @return the document library file entry that was removed
9206             */
9207            @Override
9208            public DLFileEntry removeByG_F_N(long groupId, long folderId, String name)
9209                    throws NoSuchFileEntryException {
9210                    DLFileEntry dlFileEntry = findByG_F_N(groupId, folderId, name);
9211    
9212                    return remove(dlFileEntry);
9213            }
9214    
9215            /**
9216             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and name = &#63;.
9217             *
9218             * @param groupId the group ID
9219             * @param folderId the folder ID
9220             * @param name the name
9221             * @return the number of matching document library file entries
9222             */
9223            @Override
9224            public int countByG_F_N(long groupId, long folderId, String name) {
9225                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_N;
9226    
9227                    Object[] finderArgs = new Object[] { groupId, folderId, name };
9228    
9229                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9230                                    this);
9231    
9232                    if (count == null) {
9233                            StringBundler query = new StringBundler(4);
9234    
9235                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
9236    
9237                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
9238    
9239                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
9240    
9241                            boolean bindName = false;
9242    
9243                            if (name == null) {
9244                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
9245                            }
9246                            else if (name.equals(StringPool.BLANK)) {
9247                                    query.append(_FINDER_COLUMN_G_F_N_NAME_3);
9248                            }
9249                            else {
9250                                    bindName = true;
9251    
9252                                    query.append(_FINDER_COLUMN_G_F_N_NAME_2);
9253                            }
9254    
9255                            String sql = query.toString();
9256    
9257                            Session session = null;
9258    
9259                            try {
9260                                    session = openSession();
9261    
9262                                    Query q = session.createQuery(sql);
9263    
9264                                    QueryPos qPos = QueryPos.getInstance(q);
9265    
9266                                    qPos.add(groupId);
9267    
9268                                    qPos.add(folderId);
9269    
9270                                    if (bindName) {
9271                                            qPos.add(name);
9272                                    }
9273    
9274                                    count = (Long)q.uniqueResult();
9275    
9276                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9277                            }
9278                            catch (Exception e) {
9279                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9280    
9281                                    throw processException(e);
9282                            }
9283                            finally {
9284                                    closeSession(session);
9285                            }
9286                    }
9287    
9288                    return count.intValue();
9289            }
9290    
9291            private static final String _FINDER_COLUMN_G_F_N_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
9292            private static final String _FINDER_COLUMN_G_F_N_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
9293            private static final String _FINDER_COLUMN_G_F_N_NAME_1 = "dlFileEntry.name IS NULL";
9294            private static final String _FINDER_COLUMN_G_F_N_NAME_2 = "dlFileEntry.name = ?";
9295            private static final String _FINDER_COLUMN_G_F_N_NAME_3 = "(dlFileEntry.name IS NULL OR dlFileEntry.name = '')";
9296            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_FN = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9297                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
9298                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_FN",
9299                            new String[] {
9300                                    Long.class.getName(), Long.class.getName(),
9301                                    String.class.getName()
9302                            },
9303                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
9304                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
9305                            DLFileEntryModelImpl.FILENAME_COLUMN_BITMASK);
9306            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_FN = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9307                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9308                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_FN",
9309                            new String[] {
9310                                    Long.class.getName(), Long.class.getName(),
9311                                    String.class.getName()
9312                            });
9313    
9314            /**
9315             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and fileName = &#63; or throws a {@link NoSuchFileEntryException} if it could not be found.
9316             *
9317             * @param groupId the group ID
9318             * @param folderId the folder ID
9319             * @param fileName the file name
9320             * @return the matching document library file entry
9321             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
9322             */
9323            @Override
9324            public DLFileEntry findByG_F_FN(long groupId, long folderId, String fileName)
9325                    throws NoSuchFileEntryException {
9326                    DLFileEntry dlFileEntry = fetchByG_F_FN(groupId, folderId, fileName);
9327    
9328                    if (dlFileEntry == null) {
9329                            StringBundler msg = new StringBundler(8);
9330    
9331                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9332    
9333                            msg.append("groupId=");
9334                            msg.append(groupId);
9335    
9336                            msg.append(", folderId=");
9337                            msg.append(folderId);
9338    
9339                            msg.append(", fileName=");
9340                            msg.append(fileName);
9341    
9342                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9343    
9344                            if (_log.isWarnEnabled()) {
9345                                    _log.warn(msg.toString());
9346                            }
9347    
9348                            throw new NoSuchFileEntryException(msg.toString());
9349                    }
9350    
9351                    return dlFileEntry;
9352            }
9353    
9354            /**
9355             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and fileName = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
9356             *
9357             * @param groupId the group ID
9358             * @param folderId the folder ID
9359             * @param fileName the file name
9360             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9361             */
9362            @Override
9363            public DLFileEntry fetchByG_F_FN(long groupId, long folderId,
9364                    String fileName) {
9365                    return fetchByG_F_FN(groupId, folderId, fileName, true);
9366            }
9367    
9368            /**
9369             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and fileName = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
9370             *
9371             * @param groupId the group ID
9372             * @param folderId the folder ID
9373             * @param fileName the file name
9374             * @param retrieveFromCache whether to use the finder cache
9375             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9376             */
9377            @Override
9378            public DLFileEntry fetchByG_F_FN(long groupId, long folderId,
9379                    String fileName, boolean retrieveFromCache) {
9380                    Object[] finderArgs = new Object[] { groupId, folderId, fileName };
9381    
9382                    Object result = null;
9383    
9384                    if (retrieveFromCache) {
9385                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_FN,
9386                                            finderArgs, this);
9387                    }
9388    
9389                    if (result instanceof DLFileEntry) {
9390                            DLFileEntry dlFileEntry = (DLFileEntry)result;
9391    
9392                            if ((groupId != dlFileEntry.getGroupId()) ||
9393                                            (folderId != dlFileEntry.getFolderId()) ||
9394                                            !Validator.equals(fileName, dlFileEntry.getFileName())) {
9395                                    result = null;
9396                            }
9397                    }
9398    
9399                    if (result == null) {
9400                            StringBundler query = new StringBundler(5);
9401    
9402                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9403    
9404                            query.append(_FINDER_COLUMN_G_F_FN_GROUPID_2);
9405    
9406                            query.append(_FINDER_COLUMN_G_F_FN_FOLDERID_2);
9407    
9408                            boolean bindFileName = false;
9409    
9410                            if (fileName == null) {
9411                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_1);
9412                            }
9413                            else if (fileName.equals(StringPool.BLANK)) {
9414                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_3);
9415                            }
9416                            else {
9417                                    bindFileName = true;
9418    
9419                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_2);
9420                            }
9421    
9422                            String sql = query.toString();
9423    
9424                            Session session = null;
9425    
9426                            try {
9427                                    session = openSession();
9428    
9429                                    Query q = session.createQuery(sql);
9430    
9431                                    QueryPos qPos = QueryPos.getInstance(q);
9432    
9433                                    qPos.add(groupId);
9434    
9435                                    qPos.add(folderId);
9436    
9437                                    if (bindFileName) {
9438                                            qPos.add(fileName);
9439                                    }
9440    
9441                                    List<DLFileEntry> list = q.list();
9442    
9443                                    if (list.isEmpty()) {
9444                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_FN,
9445                                                    finderArgs, list);
9446                                    }
9447                                    else {
9448                                            DLFileEntry dlFileEntry = list.get(0);
9449    
9450                                            result = dlFileEntry;
9451    
9452                                            cacheResult(dlFileEntry);
9453    
9454                                            if ((dlFileEntry.getGroupId() != groupId) ||
9455                                                            (dlFileEntry.getFolderId() != folderId) ||
9456                                                            (dlFileEntry.getFileName() == null) ||
9457                                                            !dlFileEntry.getFileName().equals(fileName)) {
9458                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_FN,
9459                                                            finderArgs, dlFileEntry);
9460                                            }
9461                                    }
9462                            }
9463                            catch (Exception e) {
9464                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_FN,
9465                                            finderArgs);
9466    
9467                                    throw processException(e);
9468                            }
9469                            finally {
9470                                    closeSession(session);
9471                            }
9472                    }
9473    
9474                    if (result instanceof List<?>) {
9475                            return null;
9476                    }
9477                    else {
9478                            return (DLFileEntry)result;
9479                    }
9480            }
9481    
9482            /**
9483             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and fileName = &#63; from the database.
9484             *
9485             * @param groupId the group ID
9486             * @param folderId the folder ID
9487             * @param fileName the file name
9488             * @return the document library file entry that was removed
9489             */
9490            @Override
9491            public DLFileEntry removeByG_F_FN(long groupId, long folderId,
9492                    String fileName) throws NoSuchFileEntryException {
9493                    DLFileEntry dlFileEntry = findByG_F_FN(groupId, folderId, fileName);
9494    
9495                    return remove(dlFileEntry);
9496            }
9497    
9498            /**
9499             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and fileName = &#63;.
9500             *
9501             * @param groupId the group ID
9502             * @param folderId the folder ID
9503             * @param fileName the file name
9504             * @return the number of matching document library file entries
9505             */
9506            @Override
9507            public int countByG_F_FN(long groupId, long folderId, String fileName) {
9508                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_FN;
9509    
9510                    Object[] finderArgs = new Object[] { groupId, folderId, fileName };
9511    
9512                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9513                                    this);
9514    
9515                    if (count == null) {
9516                            StringBundler query = new StringBundler(4);
9517    
9518                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
9519    
9520                            query.append(_FINDER_COLUMN_G_F_FN_GROUPID_2);
9521    
9522                            query.append(_FINDER_COLUMN_G_F_FN_FOLDERID_2);
9523    
9524                            boolean bindFileName = false;
9525    
9526                            if (fileName == null) {
9527                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_1);
9528                            }
9529                            else if (fileName.equals(StringPool.BLANK)) {
9530                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_3);
9531                            }
9532                            else {
9533                                    bindFileName = true;
9534    
9535                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_2);
9536                            }
9537    
9538                            String sql = query.toString();
9539    
9540                            Session session = null;
9541    
9542                            try {
9543                                    session = openSession();
9544    
9545                                    Query q = session.createQuery(sql);
9546    
9547                                    QueryPos qPos = QueryPos.getInstance(q);
9548    
9549                                    qPos.add(groupId);
9550    
9551                                    qPos.add(folderId);
9552    
9553                                    if (bindFileName) {
9554                                            qPos.add(fileName);
9555                                    }
9556    
9557                                    count = (Long)q.uniqueResult();
9558    
9559                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9560                            }
9561                            catch (Exception e) {
9562                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9563    
9564                                    throw processException(e);
9565                            }
9566                            finally {
9567                                    closeSession(session);
9568                            }
9569                    }
9570    
9571                    return count.intValue();
9572            }
9573    
9574            private static final String _FINDER_COLUMN_G_F_FN_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
9575            private static final String _FINDER_COLUMN_G_F_FN_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
9576            private static final String _FINDER_COLUMN_G_F_FN_FILENAME_1 = "dlFileEntry.fileName IS NULL";
9577            private static final String _FINDER_COLUMN_G_F_FN_FILENAME_2 = "dlFileEntry.fileName = ?";
9578            private static final String _FINDER_COLUMN_G_F_FN_FILENAME_3 = "(dlFileEntry.fileName IS NULL OR dlFileEntry.fileName = '')";
9579            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9580                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
9581                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_T",
9582                            new String[] {
9583                                    Long.class.getName(), Long.class.getName(),
9584                                    String.class.getName()
9585                            },
9586                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
9587                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
9588                            DLFileEntryModelImpl.TITLE_COLUMN_BITMASK);
9589            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9590                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9591                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_T",
9592                            new String[] {
9593                                    Long.class.getName(), Long.class.getName(),
9594                                    String.class.getName()
9595                            });
9596    
9597            /**
9598             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; or throws a {@link NoSuchFileEntryException} if it could not be found.
9599             *
9600             * @param groupId the group ID
9601             * @param folderId the folder ID
9602             * @param title the title
9603             * @return the matching document library file entry
9604             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
9605             */
9606            @Override
9607            public DLFileEntry findByG_F_T(long groupId, long folderId, String title)
9608                    throws NoSuchFileEntryException {
9609                    DLFileEntry dlFileEntry = fetchByG_F_T(groupId, folderId, title);
9610    
9611                    if (dlFileEntry == null) {
9612                            StringBundler msg = new StringBundler(8);
9613    
9614                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9615    
9616                            msg.append("groupId=");
9617                            msg.append(groupId);
9618    
9619                            msg.append(", folderId=");
9620                            msg.append(folderId);
9621    
9622                            msg.append(", title=");
9623                            msg.append(title);
9624    
9625                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9626    
9627                            if (_log.isWarnEnabled()) {
9628                                    _log.warn(msg.toString());
9629                            }
9630    
9631                            throw new NoSuchFileEntryException(msg.toString());
9632                    }
9633    
9634                    return dlFileEntry;
9635            }
9636    
9637            /**
9638             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
9639             *
9640             * @param groupId the group ID
9641             * @param folderId the folder ID
9642             * @param title the title
9643             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9644             */
9645            @Override
9646            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title) {
9647                    return fetchByG_F_T(groupId, folderId, title, true);
9648            }
9649    
9650            /**
9651             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
9652             *
9653             * @param groupId the group ID
9654             * @param folderId the folder ID
9655             * @param title the title
9656             * @param retrieveFromCache whether to use the finder cache
9657             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9658             */
9659            @Override
9660            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title,
9661                    boolean retrieveFromCache) {
9662                    Object[] finderArgs = new Object[] { groupId, folderId, title };
9663    
9664                    Object result = null;
9665    
9666                    if (retrieveFromCache) {
9667                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_T,
9668                                            finderArgs, this);
9669                    }
9670    
9671                    if (result instanceof DLFileEntry) {
9672                            DLFileEntry dlFileEntry = (DLFileEntry)result;
9673    
9674                            if ((groupId != dlFileEntry.getGroupId()) ||
9675                                            (folderId != dlFileEntry.getFolderId()) ||
9676                                            !Validator.equals(title, dlFileEntry.getTitle())) {
9677                                    result = null;
9678                            }
9679                    }
9680    
9681                    if (result == null) {
9682                            StringBundler query = new StringBundler(5);
9683    
9684                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9685    
9686                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
9687    
9688                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
9689    
9690                            boolean bindTitle = false;
9691    
9692                            if (title == null) {
9693                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
9694                            }
9695                            else if (title.equals(StringPool.BLANK)) {
9696                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
9697                            }
9698                            else {
9699                                    bindTitle = true;
9700    
9701                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
9702                            }
9703    
9704                            String sql = query.toString();
9705    
9706                            Session session = null;
9707    
9708                            try {
9709                                    session = openSession();
9710    
9711                                    Query q = session.createQuery(sql);
9712    
9713                                    QueryPos qPos = QueryPos.getInstance(q);
9714    
9715                                    qPos.add(groupId);
9716    
9717                                    qPos.add(folderId);
9718    
9719                                    if (bindTitle) {
9720                                            qPos.add(title);
9721                                    }
9722    
9723                                    List<DLFileEntry> list = q.list();
9724    
9725                                    if (list.isEmpty()) {
9726                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
9727                                                    finderArgs, list);
9728                                    }
9729                                    else {
9730                                            DLFileEntry dlFileEntry = list.get(0);
9731    
9732                                            result = dlFileEntry;
9733    
9734                                            cacheResult(dlFileEntry);
9735    
9736                                            if ((dlFileEntry.getGroupId() != groupId) ||
9737                                                            (dlFileEntry.getFolderId() != folderId) ||
9738                                                            (dlFileEntry.getTitle() == null) ||
9739                                                            !dlFileEntry.getTitle().equals(title)) {
9740                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
9741                                                            finderArgs, dlFileEntry);
9742                                            }
9743                                    }
9744                            }
9745                            catch (Exception e) {
9746                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
9747                                            finderArgs);
9748    
9749                                    throw processException(e);
9750                            }
9751                            finally {
9752                                    closeSession(session);
9753                            }
9754                    }
9755    
9756                    if (result instanceof List<?>) {
9757                            return null;
9758                    }
9759                    else {
9760                            return (DLFileEntry)result;
9761                    }
9762            }
9763    
9764            /**
9765             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; from the database.
9766             *
9767             * @param groupId the group ID
9768             * @param folderId the folder ID
9769             * @param title the title
9770             * @return the document library file entry that was removed
9771             */
9772            @Override
9773            public DLFileEntry removeByG_F_T(long groupId, long folderId, String title)
9774                    throws NoSuchFileEntryException {
9775                    DLFileEntry dlFileEntry = findByG_F_T(groupId, folderId, title);
9776    
9777                    return remove(dlFileEntry);
9778            }
9779    
9780            /**
9781             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and title = &#63;.
9782             *
9783             * @param groupId the group ID
9784             * @param folderId the folder ID
9785             * @param title the title
9786             * @return the number of matching document library file entries
9787             */
9788            @Override
9789            public int countByG_F_T(long groupId, long folderId, String title) {
9790                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_T;
9791    
9792                    Object[] finderArgs = new Object[] { groupId, folderId, title };
9793    
9794                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9795                                    this);
9796    
9797                    if (count == null) {
9798                            StringBundler query = new StringBundler(4);
9799    
9800                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
9801    
9802                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
9803    
9804                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
9805    
9806                            boolean bindTitle = false;
9807    
9808                            if (title == null) {
9809                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
9810                            }
9811                            else if (title.equals(StringPool.BLANK)) {
9812                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
9813                            }
9814                            else {
9815                                    bindTitle = true;
9816    
9817                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
9818                            }
9819    
9820                            String sql = query.toString();
9821    
9822                            Session session = null;
9823    
9824                            try {
9825                                    session = openSession();
9826    
9827                                    Query q = session.createQuery(sql);
9828    
9829                                    QueryPos qPos = QueryPos.getInstance(q);
9830    
9831                                    qPos.add(groupId);
9832    
9833                                    qPos.add(folderId);
9834    
9835                                    if (bindTitle) {
9836                                            qPos.add(title);
9837                                    }
9838    
9839                                    count = (Long)q.uniqueResult();
9840    
9841                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9842                            }
9843                            catch (Exception e) {
9844                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9845    
9846                                    throw processException(e);
9847                            }
9848                            finally {
9849                                    closeSession(session);
9850                            }
9851                    }
9852    
9853                    return count.intValue();
9854            }
9855    
9856            private static final String _FINDER_COLUMN_G_F_T_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
9857            private static final String _FINDER_COLUMN_G_F_T_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
9858            private static final String _FINDER_COLUMN_G_F_T_TITLE_1 = "dlFileEntry.title IS NULL";
9859            private static final String _FINDER_COLUMN_G_F_T_TITLE_2 = "dlFileEntry.title = ?";
9860            private static final String _FINDER_COLUMN_G_F_T_TITLE_3 = "(dlFileEntry.title IS NULL OR dlFileEntry.title = '')";
9861            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9862                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
9863                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F_F",
9864                            new String[] {
9865                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
9866                                    
9867                            Integer.class.getName(), Integer.class.getName(),
9868                                    OrderByComparator.class.getName()
9869                            });
9870            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9871                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
9872                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_F",
9873                            new String[] {
9874                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
9875                            },
9876                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
9877                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
9878                            DLFileEntryModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK |
9879                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
9880            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9881                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9882                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_F",
9883                            new String[] {
9884                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
9885                            });
9886            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9887                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9888                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_F",
9889                            new String[] {
9890                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
9891                            });
9892    
9893            /**
9894             * Returns all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
9895             *
9896             * @param groupId the group ID
9897             * @param folderId the folder ID
9898             * @param fileEntryTypeId the file entry type ID
9899             * @return the matching document library file entries
9900             */
9901            @Override
9902            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
9903                    long fileEntryTypeId) {
9904                    return findByG_F_F(groupId, folderId, fileEntryTypeId,
9905                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9906            }
9907    
9908            /**
9909             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
9910             *
9911             * <p>
9912             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
9913             * </p>
9914             *
9915             * @param groupId the group ID
9916             * @param folderId the folder ID
9917             * @param fileEntryTypeId the file entry type ID
9918             * @param start the lower bound of the range of document library file entries
9919             * @param end the upper bound of the range of document library file entries (not inclusive)
9920             * @return the range of matching document library file entries
9921             */
9922            @Override
9923            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
9924                    long fileEntryTypeId, int start, int end) {
9925                    return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end, null);
9926            }
9927    
9928            /**
9929             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
9930             *
9931             * <p>
9932             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
9933             * </p>
9934             *
9935             * @param groupId the group ID
9936             * @param folderId the folder ID
9937             * @param fileEntryTypeId the file entry type ID
9938             * @param start the lower bound of the range of document library file entries
9939             * @param end the upper bound of the range of document library file entries (not inclusive)
9940             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9941             * @return the ordered range of matching document library file entries
9942             */
9943            @Override
9944            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
9945                    long fileEntryTypeId, int start, int end,
9946                    OrderByComparator<DLFileEntry> orderByComparator) {
9947                    boolean pagination = true;
9948                    FinderPath finderPath = null;
9949                    Object[] finderArgs = null;
9950    
9951                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9952                                    (orderByComparator == null)) {
9953                            pagination = false;
9954                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F;
9955                            finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
9956                    }
9957                    else {
9958                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F;
9959                            finderArgs = new Object[] {
9960                                            groupId, folderId, fileEntryTypeId,
9961                                            
9962                                            start, end, orderByComparator
9963                                    };
9964                    }
9965    
9966                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
9967                                    finderArgs, this);
9968    
9969                    if ((list != null) && !list.isEmpty()) {
9970                            for (DLFileEntry dlFileEntry : list) {
9971                                    if ((groupId != dlFileEntry.getGroupId()) ||
9972                                                    (folderId != dlFileEntry.getFolderId()) ||
9973                                                    (fileEntryTypeId != dlFileEntry.getFileEntryTypeId())) {
9974                                            list = null;
9975    
9976                                            break;
9977                                    }
9978                            }
9979                    }
9980    
9981                    if (list == null) {
9982                            StringBundler query = null;
9983    
9984                            if (orderByComparator != null) {
9985                                    query = new StringBundler(5 +
9986                                                    (orderByComparator.getOrderByFields().length * 3));
9987                            }
9988                            else {
9989                                    query = new StringBundler(5);
9990                            }
9991    
9992                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9993    
9994                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
9995    
9996                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
9997    
9998                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
9999    
10000                            if (orderByComparator != null) {
10001                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10002                                            orderByComparator);
10003                            }
10004                            else
10005                             if (pagination) {
10006                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10007                            }
10008    
10009                            String sql = query.toString();
10010    
10011                            Session session = null;
10012    
10013                            try {
10014                                    session = openSession();
10015    
10016                                    Query q = session.createQuery(sql);
10017    
10018                                    QueryPos qPos = QueryPos.getInstance(q);
10019    
10020                                    qPos.add(groupId);
10021    
10022                                    qPos.add(folderId);
10023    
10024                                    qPos.add(fileEntryTypeId);
10025    
10026                                    if (!pagination) {
10027                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
10028                                                            start, end, false);
10029    
10030                                            Collections.sort(list);
10031    
10032                                            list = Collections.unmodifiableList(list);
10033                                    }
10034                                    else {
10035                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
10036                                                            start, end);
10037                                    }
10038    
10039                                    cacheResult(list);
10040    
10041                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10042                            }
10043                            catch (Exception e) {
10044                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10045    
10046                                    throw processException(e);
10047                            }
10048                            finally {
10049                                    closeSession(session);
10050                            }
10051                    }
10052    
10053                    return list;
10054            }
10055    
10056            /**
10057             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10058             *
10059             * @param groupId the group ID
10060             * @param folderId the folder ID
10061             * @param fileEntryTypeId the file entry type ID
10062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10063             * @return the first matching document library file entry
10064             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
10065             */
10066            @Override
10067            public DLFileEntry findByG_F_F_First(long groupId, long folderId,
10068                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator)
10069                    throws NoSuchFileEntryException {
10070                    DLFileEntry dlFileEntry = fetchByG_F_F_First(groupId, folderId,
10071                                    fileEntryTypeId, orderByComparator);
10072    
10073                    if (dlFileEntry != null) {
10074                            return dlFileEntry;
10075                    }
10076    
10077                    StringBundler msg = new StringBundler(8);
10078    
10079                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10080    
10081                    msg.append("groupId=");
10082                    msg.append(groupId);
10083    
10084                    msg.append(", folderId=");
10085                    msg.append(folderId);
10086    
10087                    msg.append(", fileEntryTypeId=");
10088                    msg.append(fileEntryTypeId);
10089    
10090                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10091    
10092                    throw new NoSuchFileEntryException(msg.toString());
10093            }
10094    
10095            /**
10096             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10097             *
10098             * @param groupId the group ID
10099             * @param folderId the folder ID
10100             * @param fileEntryTypeId the file entry type ID
10101             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10102             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
10103             */
10104            @Override
10105            public DLFileEntry fetchByG_F_F_First(long groupId, long folderId,
10106                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator) {
10107                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
10108                                    fileEntryTypeId, 0, 1, orderByComparator);
10109    
10110                    if (!list.isEmpty()) {
10111                            return list.get(0);
10112                    }
10113    
10114                    return null;
10115            }
10116    
10117            /**
10118             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10119             *
10120             * @param groupId the group ID
10121             * @param folderId the folder ID
10122             * @param fileEntryTypeId the file entry type ID
10123             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10124             * @return the last matching document library file entry
10125             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
10126             */
10127            @Override
10128            public DLFileEntry findByG_F_F_Last(long groupId, long folderId,
10129                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator)
10130                    throws NoSuchFileEntryException {
10131                    DLFileEntry dlFileEntry = fetchByG_F_F_Last(groupId, folderId,
10132                                    fileEntryTypeId, orderByComparator);
10133    
10134                    if (dlFileEntry != null) {
10135                            return dlFileEntry;
10136                    }
10137    
10138                    StringBundler msg = new StringBundler(8);
10139    
10140                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10141    
10142                    msg.append("groupId=");
10143                    msg.append(groupId);
10144    
10145                    msg.append(", folderId=");
10146                    msg.append(folderId);
10147    
10148                    msg.append(", fileEntryTypeId=");
10149                    msg.append(fileEntryTypeId);
10150    
10151                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10152    
10153                    throw new NoSuchFileEntryException(msg.toString());
10154            }
10155    
10156            /**
10157             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10158             *
10159             * @param groupId the group ID
10160             * @param folderId the folder ID
10161             * @param fileEntryTypeId the file entry type ID
10162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10163             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
10164             */
10165            @Override
10166            public DLFileEntry fetchByG_F_F_Last(long groupId, long folderId,
10167                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator) {
10168                    int count = countByG_F_F(groupId, folderId, fileEntryTypeId);
10169    
10170                    if (count == 0) {
10171                            return null;
10172                    }
10173    
10174                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
10175                                    fileEntryTypeId, count - 1, count, orderByComparator);
10176    
10177                    if (!list.isEmpty()) {
10178                            return list.get(0);
10179                    }
10180    
10181                    return null;
10182            }
10183    
10184            /**
10185             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10186             *
10187             * @param fileEntryId the primary key of the current document library file entry
10188             * @param groupId the group ID
10189             * @param folderId the folder ID
10190             * @param fileEntryTypeId the file entry type ID
10191             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10192             * @return the previous, current, and next document library file entry
10193             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
10194             */
10195            @Override
10196            public DLFileEntry[] findByG_F_F_PrevAndNext(long fileEntryId,
10197                    long groupId, long folderId, long fileEntryTypeId,
10198                    OrderByComparator<DLFileEntry> orderByComparator)
10199                    throws NoSuchFileEntryException {
10200                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
10201    
10202                    Session session = null;
10203    
10204                    try {
10205                            session = openSession();
10206    
10207                            DLFileEntry[] array = new DLFileEntryImpl[3];
10208    
10209                            array[0] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
10210                                            folderId, fileEntryTypeId, orderByComparator, true);
10211    
10212                            array[1] = dlFileEntry;
10213    
10214                            array[2] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
10215                                            folderId, fileEntryTypeId, orderByComparator, false);
10216    
10217                            return array;
10218                    }
10219                    catch (Exception e) {
10220                            throw processException(e);
10221                    }
10222                    finally {
10223                            closeSession(session);
10224                    }
10225            }
10226    
10227            protected DLFileEntry getByG_F_F_PrevAndNext(Session session,
10228                    DLFileEntry dlFileEntry, long groupId, long folderId,
10229                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator,
10230                    boolean previous) {
10231                    StringBundler query = null;
10232    
10233                    if (orderByComparator != null) {
10234                            query = new StringBundler(6 +
10235                                            (orderByComparator.getOrderByFields().length * 6));
10236                    }
10237                    else {
10238                            query = new StringBundler(3);
10239                    }
10240    
10241                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
10242    
10243                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10244    
10245                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10246    
10247                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10248    
10249                    if (orderByComparator != null) {
10250                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10251    
10252                            if (orderByConditionFields.length > 0) {
10253                                    query.append(WHERE_AND);
10254                            }
10255    
10256                            for (int i = 0; i < orderByConditionFields.length; i++) {
10257                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10258                                    query.append(orderByConditionFields[i]);
10259    
10260                                    if ((i + 1) < orderByConditionFields.length) {
10261                                            if (orderByComparator.isAscending() ^ previous) {
10262                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10263                                            }
10264                                            else {
10265                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10266                                            }
10267                                    }
10268                                    else {
10269                                            if (orderByComparator.isAscending() ^ previous) {
10270                                                    query.append(WHERE_GREATER_THAN);
10271                                            }
10272                                            else {
10273                                                    query.append(WHERE_LESSER_THAN);
10274                                            }
10275                                    }
10276                            }
10277    
10278                            query.append(ORDER_BY_CLAUSE);
10279    
10280                            String[] orderByFields = orderByComparator.getOrderByFields();
10281    
10282                            for (int i = 0; i < orderByFields.length; i++) {
10283                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10284                                    query.append(orderByFields[i]);
10285    
10286                                    if ((i + 1) < orderByFields.length) {
10287                                            if (orderByComparator.isAscending() ^ previous) {
10288                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10289                                            }
10290                                            else {
10291                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10292                                            }
10293                                    }
10294                                    else {
10295                                            if (orderByComparator.isAscending() ^ previous) {
10296                                                    query.append(ORDER_BY_ASC);
10297                                            }
10298                                            else {
10299                                                    query.append(ORDER_BY_DESC);
10300                                            }
10301                                    }
10302                            }
10303                    }
10304                    else {
10305                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10306                    }
10307    
10308                    String sql = query.toString();
10309    
10310                    Query q = session.createQuery(sql);
10311    
10312                    q.setFirstResult(0);
10313                    q.setMaxResults(2);
10314    
10315                    QueryPos qPos = QueryPos.getInstance(q);
10316    
10317                    qPos.add(groupId);
10318    
10319                    qPos.add(folderId);
10320    
10321                    qPos.add(fileEntryTypeId);
10322    
10323                    if (orderByComparator != null) {
10324                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
10325    
10326                            for (Object value : values) {
10327                                    qPos.add(value);
10328                            }
10329                    }
10330    
10331                    List<DLFileEntry> list = q.list();
10332    
10333                    if (list.size() == 2) {
10334                            return list.get(1);
10335                    }
10336                    else {
10337                            return null;
10338                    }
10339            }
10340    
10341            /**
10342             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10343             *
10344             * @param groupId the group ID
10345             * @param folderId the folder ID
10346             * @param fileEntryTypeId the file entry type ID
10347             * @return the matching document library file entries that the user has permission to view
10348             */
10349            @Override
10350            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
10351                    long fileEntryTypeId) {
10352                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId,
10353                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10354            }
10355    
10356            /**
10357             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10358             *
10359             * <p>
10360             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
10361             * </p>
10362             *
10363             * @param groupId the group ID
10364             * @param folderId the folder ID
10365             * @param fileEntryTypeId the file entry type ID
10366             * @param start the lower bound of the range of document library file entries
10367             * @param end the upper bound of the range of document library file entries (not inclusive)
10368             * @return the range of matching document library file entries that the user has permission to view
10369             */
10370            @Override
10371            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
10372                    long fileEntryTypeId, int start, int end) {
10373                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId, start,
10374                            end, null);
10375            }
10376    
10377            /**
10378             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10379             *
10380             * <p>
10381             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
10382             * </p>
10383             *
10384             * @param groupId the group ID
10385             * @param folderId the folder ID
10386             * @param fileEntryTypeId the file entry type ID
10387             * @param start the lower bound of the range of document library file entries
10388             * @param end the upper bound of the range of document library file entries (not inclusive)
10389             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10390             * @return the ordered range of matching document library file entries that the user has permission to view
10391             */
10392            @Override
10393            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
10394                    long fileEntryTypeId, int start, int end,
10395                    OrderByComparator<DLFileEntry> orderByComparator) {
10396                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10397                            return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end,
10398                                    orderByComparator);
10399                    }
10400    
10401                    StringBundler query = null;
10402    
10403                    if (orderByComparator != null) {
10404                            query = new StringBundler(5 +
10405                                            (orderByComparator.getOrderByFields().length * 3));
10406                    }
10407                    else {
10408                            query = new StringBundler(5);
10409                    }
10410    
10411                    if (getDB().isSupportsInlineDistinct()) {
10412                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
10413                    }
10414                    else {
10415                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
10416                    }
10417    
10418                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10419    
10420                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10421    
10422                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10423    
10424                    if (!getDB().isSupportsInlineDistinct()) {
10425                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
10426                    }
10427    
10428                    if (orderByComparator != null) {
10429                            if (getDB().isSupportsInlineDistinct()) {
10430                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10431                                            orderByComparator, true);
10432                            }
10433                            else {
10434                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10435                                            orderByComparator, true);
10436                            }
10437                    }
10438                    else {
10439                            if (getDB().isSupportsInlineDistinct()) {
10440                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10441                            }
10442                            else {
10443                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
10444                            }
10445                    }
10446    
10447                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10448                                    DLFileEntry.class.getName(),
10449                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10450    
10451                    Session session = null;
10452    
10453                    try {
10454                            session = openSession();
10455    
10456                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10457    
10458                            if (getDB().isSupportsInlineDistinct()) {
10459                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
10460                            }
10461                            else {
10462                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
10463                            }
10464    
10465                            QueryPos qPos = QueryPos.getInstance(q);
10466    
10467                            qPos.add(groupId);
10468    
10469                            qPos.add(folderId);
10470    
10471                            qPos.add(fileEntryTypeId);
10472    
10473                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
10474                    }
10475                    catch (Exception e) {
10476                            throw processException(e);
10477                    }
10478                    finally {
10479                            closeSession(session);
10480                    }
10481            }
10482    
10483            /**
10484             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10485             *
10486             * @param fileEntryId the primary key of the current document library file entry
10487             * @param groupId the group ID
10488             * @param folderId the folder ID
10489             * @param fileEntryTypeId the file entry type ID
10490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10491             * @return the previous, current, and next document library file entry
10492             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
10493             */
10494            @Override
10495            public DLFileEntry[] filterFindByG_F_F_PrevAndNext(long fileEntryId,
10496                    long groupId, long folderId, long fileEntryTypeId,
10497                    OrderByComparator<DLFileEntry> orderByComparator)
10498                    throws NoSuchFileEntryException {
10499                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10500                            return findByG_F_F_PrevAndNext(fileEntryId, groupId, folderId,
10501                                    fileEntryTypeId, orderByComparator);
10502                    }
10503    
10504                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
10505    
10506                    Session session = null;
10507    
10508                    try {
10509                            session = openSession();
10510    
10511                            DLFileEntry[] array = new DLFileEntryImpl[3];
10512    
10513                            array[0] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
10514                                            groupId, folderId, fileEntryTypeId, orderByComparator, true);
10515    
10516                            array[1] = dlFileEntry;
10517    
10518                            array[2] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
10519                                            groupId, folderId, fileEntryTypeId, orderByComparator, false);
10520    
10521                            return array;
10522                    }
10523                    catch (Exception e) {
10524                            throw processException(e);
10525                    }
10526                    finally {
10527                            closeSession(session);
10528                    }
10529            }
10530    
10531            protected DLFileEntry filterGetByG_F_F_PrevAndNext(Session session,
10532                    DLFileEntry dlFileEntry, long groupId, long folderId,
10533                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator,
10534                    boolean previous) {
10535                    StringBundler query = null;
10536    
10537                    if (orderByComparator != null) {
10538                            query = new StringBundler(6 +
10539                                            (orderByComparator.getOrderByFields().length * 6));
10540                    }
10541                    else {
10542                            query = new StringBundler(3);
10543                    }
10544    
10545                    if (getDB().isSupportsInlineDistinct()) {
10546                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
10547                    }
10548                    else {
10549                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
10550                    }
10551    
10552                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10553    
10554                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10555    
10556                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10557    
10558                    if (!getDB().isSupportsInlineDistinct()) {
10559                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
10560                    }
10561    
10562                    if (orderByComparator != null) {
10563                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10564    
10565                            if (orderByConditionFields.length > 0) {
10566                                    query.append(WHERE_AND);
10567                            }
10568    
10569                            for (int i = 0; i < orderByConditionFields.length; i++) {
10570                                    if (getDB().isSupportsInlineDistinct()) {
10571                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10572                                    }
10573                                    else {
10574                                            query.append(_ORDER_BY_ENTITY_TABLE);
10575                                    }
10576    
10577                                    query.append(orderByConditionFields[i]);
10578    
10579                                    if ((i + 1) < orderByConditionFields.length) {
10580                                            if (orderByComparator.isAscending() ^ previous) {
10581                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10582                                            }
10583                                            else {
10584                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10585                                            }
10586                                    }
10587                                    else {
10588                                            if (orderByComparator.isAscending() ^ previous) {
10589                                                    query.append(WHERE_GREATER_THAN);
10590                                            }
10591                                            else {
10592                                                    query.append(WHERE_LESSER_THAN);
10593                                            }
10594                                    }
10595                            }
10596    
10597                            query.append(ORDER_BY_CLAUSE);
10598    
10599                            String[] orderByFields = orderByComparator.getOrderByFields();
10600    
10601                            for (int i = 0; i < orderByFields.length; i++) {
10602                                    if (getDB().isSupportsInlineDistinct()) {
10603                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10604                                    }
10605                                    else {
10606                                            query.append(_ORDER_BY_ENTITY_TABLE);
10607                                    }
10608    
10609                                    query.append(orderByFields[i]);
10610    
10611                                    if ((i + 1) < orderByFields.length) {
10612                                            if (orderByComparator.isAscending() ^ previous) {
10613                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10614                                            }
10615                                            else {
10616                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10617                                            }
10618                                    }
10619                                    else {
10620                                            if (orderByComparator.isAscending() ^ previous) {
10621                                                    query.append(ORDER_BY_ASC);
10622                                            }
10623                                            else {
10624                                                    query.append(ORDER_BY_DESC);
10625                                            }
10626                                    }
10627                            }
10628                    }
10629                    else {
10630                            if (getDB().isSupportsInlineDistinct()) {
10631                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10632                            }
10633                            else {
10634                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
10635                            }
10636                    }
10637    
10638                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10639                                    DLFileEntry.class.getName(),
10640                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10641    
10642                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10643    
10644                    q.setFirstResult(0);
10645                    q.setMaxResults(2);
10646    
10647                    if (getDB().isSupportsInlineDistinct()) {
10648                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
10649                    }
10650                    else {
10651                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
10652                    }
10653    
10654                    QueryPos qPos = QueryPos.getInstance(q);
10655    
10656                    qPos.add(groupId);
10657    
10658                    qPos.add(folderId);
10659    
10660                    qPos.add(fileEntryTypeId);
10661    
10662                    if (orderByComparator != null) {
10663                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
10664    
10665                            for (Object value : values) {
10666                                    qPos.add(value);
10667                            }
10668                    }
10669    
10670                    List<DLFileEntry> list = q.list();
10671    
10672                    if (list.size() == 2) {
10673                            return list.get(1);
10674                    }
10675                    else {
10676                            return null;
10677                    }
10678            }
10679    
10680            /**
10681             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
10682             *
10683             * @param groupId the group ID
10684             * @param folderIds the folder IDs
10685             * @param fileEntryTypeId the file entry type ID
10686             * @return the matching document library file entries that the user has permission to view
10687             */
10688            @Override
10689            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
10690                    long fileEntryTypeId) {
10691                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId,
10692                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10693            }
10694    
10695            /**
10696             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
10697             *
10698             * <p>
10699             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
10700             * </p>
10701             *
10702             * @param groupId the group ID
10703             * @param folderIds the folder IDs
10704             * @param fileEntryTypeId the file entry type ID
10705             * @param start the lower bound of the range of document library file entries
10706             * @param end the upper bound of the range of document library file entries (not inclusive)
10707             * @return the range of matching document library file entries that the user has permission to view
10708             */
10709            @Override
10710            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
10711                    long fileEntryTypeId, int start, int end) {
10712                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId, start,
10713                            end, null);
10714            }
10715    
10716            /**
10717             * Returns an ordered range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
10718             *
10719             * <p>
10720             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
10721             * </p>
10722             *
10723             * @param groupId the group ID
10724             * @param folderIds the folder IDs
10725             * @param fileEntryTypeId the file entry type ID
10726             * @param start the lower bound of the range of document library file entries
10727             * @param end the upper bound of the range of document library file entries (not inclusive)
10728             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10729             * @return the ordered range of matching document library file entries that the user has permission to view
10730             */
10731            @Override
10732            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
10733                    long fileEntryTypeId, int start, int end,
10734                    OrderByComparator<DLFileEntry> orderByComparator) {
10735                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10736                            return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end,
10737                                    orderByComparator);
10738                    }
10739    
10740                    if (folderIds == null) {
10741                            folderIds = new long[0];
10742                    }
10743                    else {
10744                            folderIds = ArrayUtil.unique(folderIds);
10745                    }
10746    
10747                    StringBundler query = new StringBundler();
10748    
10749                    if (getDB().isSupportsInlineDistinct()) {
10750                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
10751                    }
10752                    else {
10753                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
10754                    }
10755    
10756                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10757    
10758                    if (folderIds.length > 0) {
10759                            query.append(StringPool.OPEN_PARENTHESIS);
10760    
10761                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_7);
10762    
10763                            query.append(StringUtil.merge(folderIds));
10764    
10765                            query.append(StringPool.CLOSE_PARENTHESIS);
10766    
10767                            query.append(StringPool.CLOSE_PARENTHESIS);
10768    
10769                            query.append(WHERE_AND);
10770                    }
10771    
10772                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10773    
10774                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10775                            query.index() - 1);
10776    
10777                    if (!getDB().isSupportsInlineDistinct()) {
10778                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
10779                    }
10780    
10781                    if (orderByComparator != null) {
10782                            if (getDB().isSupportsInlineDistinct()) {
10783                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10784                                            orderByComparator, true);
10785                            }
10786                            else {
10787                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10788                                            orderByComparator, true);
10789                            }
10790                    }
10791                    else {
10792                            if (getDB().isSupportsInlineDistinct()) {
10793                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10794                            }
10795                            else {
10796                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
10797                            }
10798                    }
10799    
10800                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10801                                    DLFileEntry.class.getName(),
10802                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10803    
10804                    Session session = null;
10805    
10806                    try {
10807                            session = openSession();
10808    
10809                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10810    
10811                            if (getDB().isSupportsInlineDistinct()) {
10812                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
10813                            }
10814                            else {
10815                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
10816                            }
10817    
10818                            QueryPos qPos = QueryPos.getInstance(q);
10819    
10820                            qPos.add(groupId);
10821    
10822                            qPos.add(fileEntryTypeId);
10823    
10824                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
10825                    }
10826                    catch (Exception e) {
10827                            throw processException(e);
10828                    }
10829                    finally {
10830                            closeSession(session);
10831                    }
10832            }
10833    
10834            /**
10835             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
10836             *
10837             * <p>
10838             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
10839             * </p>
10840             *
10841             * @param groupId the group ID
10842             * @param folderIds the folder IDs
10843             * @param fileEntryTypeId the file entry type ID
10844             * @return the matching document library file entries
10845             */
10846            @Override
10847            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
10848                    long fileEntryTypeId) {
10849                    return findByG_F_F(groupId, folderIds, fileEntryTypeId,
10850                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10851            }
10852    
10853            /**
10854             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
10855             *
10856             * <p>
10857             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
10858             * </p>
10859             *
10860             * @param groupId the group ID
10861             * @param folderIds the folder IDs
10862             * @param fileEntryTypeId the file entry type ID
10863             * @param start the lower bound of the range of document library file entries
10864             * @param end the upper bound of the range of document library file entries (not inclusive)
10865             * @return the range of matching document library file entries
10866             */
10867            @Override
10868            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
10869                    long fileEntryTypeId, int start, int end) {
10870                    return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end, null);
10871            }
10872    
10873            /**
10874             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
10875             *
10876             * <p>
10877             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
10878             * </p>
10879             *
10880             * @param groupId the group ID
10881             * @param folderIds the folder IDs
10882             * @param fileEntryTypeId the file entry type ID
10883             * @param start the lower bound of the range of document library file entries
10884             * @param end the upper bound of the range of document library file entries (not inclusive)
10885             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10886             * @return the ordered range of matching document library file entries
10887             */
10888            @Override
10889            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
10890                    long fileEntryTypeId, int start, int end,
10891                    OrderByComparator<DLFileEntry> orderByComparator) {
10892                    if (folderIds == null) {
10893                            folderIds = new long[0];
10894                    }
10895                    else {
10896                            folderIds = ArrayUtil.unique(folderIds);
10897                    }
10898    
10899                    if (folderIds.length == 1) {
10900                            return findByG_F_F(groupId, folderIds[0], fileEntryTypeId, start,
10901                                    end, orderByComparator);
10902                    }
10903    
10904                    boolean pagination = true;
10905                    Object[] finderArgs = null;
10906    
10907                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10908                                    (orderByComparator == null)) {
10909                            pagination = false;
10910                            finderArgs = new Object[] {
10911                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId
10912                                    };
10913                    }
10914                    else {
10915                            finderArgs = new Object[] {
10916                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId,
10917                                            
10918                                            start, end, orderByComparator
10919                                    };
10920                    }
10921    
10922                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
10923                                    finderArgs, this);
10924    
10925                    if ((list != null) && !list.isEmpty()) {
10926                            for (DLFileEntry dlFileEntry : list) {
10927                                    if ((groupId != dlFileEntry.getGroupId()) ||
10928                                                    !ArrayUtil.contains(folderIds, dlFileEntry.getFolderId()) ||
10929                                                    (fileEntryTypeId != dlFileEntry.getFileEntryTypeId())) {
10930                                            list = null;
10931    
10932                                            break;
10933                                    }
10934                            }
10935                    }
10936    
10937                    if (list == null) {
10938                            StringBundler query = new StringBundler();
10939    
10940                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
10941    
10942                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10943    
10944                            if (folderIds.length > 0) {
10945                                    query.append(StringPool.OPEN_PARENTHESIS);
10946    
10947                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_7);
10948    
10949                                    query.append(StringUtil.merge(folderIds));
10950    
10951                                    query.append(StringPool.CLOSE_PARENTHESIS);
10952    
10953                                    query.append(StringPool.CLOSE_PARENTHESIS);
10954    
10955                                    query.append(WHERE_AND);
10956                            }
10957    
10958                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10959    
10960                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
10961                                                    1)), query.index() - 1);
10962    
10963                            if (orderByComparator != null) {
10964                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10965                                            orderByComparator);
10966                            }
10967                            else
10968                             if (pagination) {
10969                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10970                            }
10971    
10972                            String sql = query.toString();
10973    
10974                            Session session = null;
10975    
10976                            try {
10977                                    session = openSession();
10978    
10979                                    Query q = session.createQuery(sql);
10980    
10981                                    QueryPos qPos = QueryPos.getInstance(q);
10982    
10983                                    qPos.add(groupId);
10984    
10985                                    qPos.add(fileEntryTypeId);
10986    
10987                                    if (!pagination) {
10988                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
10989                                                            start, end, false);
10990    
10991                                            Collections.sort(list);
10992    
10993                                            list = Collections.unmodifiableList(list);
10994                                    }
10995                                    else {
10996                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
10997                                                            start, end);
10998                                    }
10999    
11000                                    cacheResult(list);
11001    
11002                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
11003                                            finderArgs, list);
11004                            }
11005                            catch (Exception e) {
11006                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
11007                                            finderArgs);
11008    
11009                                    throw processException(e);
11010                            }
11011                            finally {
11012                                    closeSession(session);
11013                            }
11014                    }
11015    
11016                    return list;
11017            }
11018    
11019            /**
11020             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63; from the database.
11021             *
11022             * @param groupId the group ID
11023             * @param folderId the folder ID
11024             * @param fileEntryTypeId the file entry type ID
11025             */
11026            @Override
11027            public void removeByG_F_F(long groupId, long folderId, long fileEntryTypeId) {
11028                    for (DLFileEntry dlFileEntry : findByG_F_F(groupId, folderId,
11029                                    fileEntryTypeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11030                            remove(dlFileEntry);
11031                    }
11032            }
11033    
11034            /**
11035             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
11036             *
11037             * @param groupId the group ID
11038             * @param folderId the folder ID
11039             * @param fileEntryTypeId the file entry type ID
11040             * @return the number of matching document library file entries
11041             */
11042            @Override
11043            public int countByG_F_F(long groupId, long folderId, long fileEntryTypeId) {
11044                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_F;
11045    
11046                    Object[] finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
11047    
11048                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11049                                    this);
11050    
11051                    if (count == null) {
11052                            StringBundler query = new StringBundler(4);
11053    
11054                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
11055    
11056                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11057    
11058                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
11059    
11060                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11061    
11062                            String sql = query.toString();
11063    
11064                            Session session = null;
11065    
11066                            try {
11067                                    session = openSession();
11068    
11069                                    Query q = session.createQuery(sql);
11070    
11071                                    QueryPos qPos = QueryPos.getInstance(q);
11072    
11073                                    qPos.add(groupId);
11074    
11075                                    qPos.add(folderId);
11076    
11077                                    qPos.add(fileEntryTypeId);
11078    
11079                                    count = (Long)q.uniqueResult();
11080    
11081                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11082                            }
11083                            catch (Exception e) {
11084                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11085    
11086                                    throw processException(e);
11087                            }
11088                            finally {
11089                                    closeSession(session);
11090                            }
11091                    }
11092    
11093                    return count.intValue();
11094            }
11095    
11096            /**
11097             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
11098             *
11099             * @param groupId the group ID
11100             * @param folderIds the folder IDs
11101             * @param fileEntryTypeId the file entry type ID
11102             * @return the number of matching document library file entries
11103             */
11104            @Override
11105            public int countByG_F_F(long groupId, long[] folderIds, long fileEntryTypeId) {
11106                    if (folderIds == null) {
11107                            folderIds = new long[0];
11108                    }
11109                    else {
11110                            folderIds = ArrayUtil.unique(folderIds);
11111                    }
11112    
11113                    Object[] finderArgs = new Object[] {
11114                                    groupId, StringUtil.merge(folderIds), fileEntryTypeId
11115                            };
11116    
11117                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
11118                                    finderArgs, this);
11119    
11120                    if (count == null) {
11121                            StringBundler query = new StringBundler();
11122    
11123                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
11124    
11125                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11126    
11127                            if (folderIds.length > 0) {
11128                                    query.append(StringPool.OPEN_PARENTHESIS);
11129    
11130                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_7);
11131    
11132                                    query.append(StringUtil.merge(folderIds));
11133    
11134                                    query.append(StringPool.CLOSE_PARENTHESIS);
11135    
11136                                    query.append(StringPool.CLOSE_PARENTHESIS);
11137    
11138                                    query.append(WHERE_AND);
11139                            }
11140    
11141                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11142    
11143                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
11144                                                    1)), query.index() - 1);
11145    
11146                            String sql = query.toString();
11147    
11148                            Session session = null;
11149    
11150                            try {
11151                                    session = openSession();
11152    
11153                                    Query q = session.createQuery(sql);
11154    
11155                                    QueryPos qPos = QueryPos.getInstance(q);
11156    
11157                                    qPos.add(groupId);
11158    
11159                                    qPos.add(fileEntryTypeId);
11160    
11161                                    count = (Long)q.uniqueResult();
11162    
11163                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
11164                                            finderArgs, count);
11165                            }
11166                            catch (Exception e) {
11167                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
11168                                            finderArgs);
11169    
11170                                    throw processException(e);
11171                            }
11172                            finally {
11173                                    closeSession(session);
11174                            }
11175                    }
11176    
11177                    return count.intValue();
11178            }
11179    
11180            /**
11181             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
11182             *
11183             * @param groupId the group ID
11184             * @param folderId the folder ID
11185             * @param fileEntryTypeId the file entry type ID
11186             * @return the number of matching document library file entries that the user has permission to view
11187             */
11188            @Override
11189            public int filterCountByG_F_F(long groupId, long folderId,
11190                    long fileEntryTypeId) {
11191                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11192                            return countByG_F_F(groupId, folderId, fileEntryTypeId);
11193                    }
11194    
11195                    StringBundler query = new StringBundler(4);
11196    
11197                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
11198    
11199                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11200    
11201                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
11202    
11203                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11204    
11205                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11206                                    DLFileEntry.class.getName(),
11207                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11208    
11209                    Session session = null;
11210    
11211                    try {
11212                            session = openSession();
11213    
11214                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11215    
11216                            q.addScalar(COUNT_COLUMN_NAME,
11217                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11218    
11219                            QueryPos qPos = QueryPos.getInstance(q);
11220    
11221                            qPos.add(groupId);
11222    
11223                            qPos.add(folderId);
11224    
11225                            qPos.add(fileEntryTypeId);
11226    
11227                            Long count = (Long)q.uniqueResult();
11228    
11229                            return count.intValue();
11230                    }
11231                    catch (Exception e) {
11232                            throw processException(e);
11233                    }
11234                    finally {
11235                            closeSession(session);
11236                    }
11237            }
11238    
11239            /**
11240             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
11241             *
11242             * @param groupId the group ID
11243             * @param folderIds the folder IDs
11244             * @param fileEntryTypeId the file entry type ID
11245             * @return the number of matching document library file entries that the user has permission to view
11246             */
11247            @Override
11248            public int filterCountByG_F_F(long groupId, long[] folderIds,
11249                    long fileEntryTypeId) {
11250                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11251                            return countByG_F_F(groupId, folderIds, fileEntryTypeId);
11252                    }
11253    
11254                    if (folderIds == null) {
11255                            folderIds = new long[0];
11256                    }
11257                    else {
11258                            folderIds = ArrayUtil.unique(folderIds);
11259                    }
11260    
11261                    StringBundler query = new StringBundler();
11262    
11263                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
11264    
11265                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11266    
11267                    if (folderIds.length > 0) {
11268                            query.append(StringPool.OPEN_PARENTHESIS);
11269    
11270                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_7);
11271    
11272                            query.append(StringUtil.merge(folderIds));
11273    
11274                            query.append(StringPool.CLOSE_PARENTHESIS);
11275    
11276                            query.append(StringPool.CLOSE_PARENTHESIS);
11277    
11278                            query.append(WHERE_AND);
11279                    }
11280    
11281                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11282    
11283                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
11284                            query.index() - 1);
11285    
11286                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11287                                    DLFileEntry.class.getName(),
11288                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11289    
11290                    Session session = null;
11291    
11292                    try {
11293                            session = openSession();
11294    
11295                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11296    
11297                            q.addScalar(COUNT_COLUMN_NAME,
11298                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11299    
11300                            QueryPos qPos = QueryPos.getInstance(q);
11301    
11302                            qPos.add(groupId);
11303    
11304                            qPos.add(fileEntryTypeId);
11305    
11306                            Long count = (Long)q.uniqueResult();
11307    
11308                            return count.intValue();
11309                    }
11310                    catch (Exception e) {
11311                            throw processException(e);
11312                    }
11313                    finally {
11314                            closeSession(session);
11315                    }
11316            }
11317    
11318            private static final String _FINDER_COLUMN_G_F_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
11319            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
11320            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_7 = "dlFileEntry.folderId IN (";
11321            private static final String _FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2 = "dlFileEntry.fileEntryTypeId = ?";
11322    
11323            public DLFileEntryPersistenceImpl() {
11324                    setModelClass(DLFileEntry.class);
11325            }
11326    
11327            /**
11328             * Caches the document library file entry in the entity cache if it is enabled.
11329             *
11330             * @param dlFileEntry the document library file entry
11331             */
11332            @Override
11333            public void cacheResult(DLFileEntry dlFileEntry) {
11334                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11335                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
11336    
11337                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
11338                            new Object[] { dlFileEntry.getUuid(), dlFileEntry.getGroupId() },
11339                            dlFileEntry);
11340    
11341                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
11342                            new Object[] {
11343                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11344                                    dlFileEntry.getName()
11345                            }, dlFileEntry);
11346    
11347                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_FN,
11348                            new Object[] {
11349                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11350                                    dlFileEntry.getFileName()
11351                            }, dlFileEntry);
11352    
11353                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
11354                            new Object[] {
11355                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11356                                    dlFileEntry.getTitle()
11357                            }, dlFileEntry);
11358    
11359                    dlFileEntry.resetOriginalValues();
11360            }
11361    
11362            /**
11363             * Caches the document library file entries in the entity cache if it is enabled.
11364             *
11365             * @param dlFileEntries the document library file entries
11366             */
11367            @Override
11368            public void cacheResult(List<DLFileEntry> dlFileEntries) {
11369                    for (DLFileEntry dlFileEntry : dlFileEntries) {
11370                            if (EntityCacheUtil.getResult(
11371                                                    DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11372                                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey()) == null) {
11373                                    cacheResult(dlFileEntry);
11374                            }
11375                            else {
11376                                    dlFileEntry.resetOriginalValues();
11377                            }
11378                    }
11379            }
11380    
11381            /**
11382             * Clears the cache for all document library file entries.
11383             *
11384             * <p>
11385             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
11386             * </p>
11387             */
11388            @Override
11389            public void clearCache() {
11390                    EntityCacheUtil.clearCache(DLFileEntryImpl.class);
11391    
11392                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11393                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11394                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11395            }
11396    
11397            /**
11398             * Clears the cache for the document library file entry.
11399             *
11400             * <p>
11401             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
11402             * </p>
11403             */
11404            @Override
11405            public void clearCache(DLFileEntry dlFileEntry) {
11406                    EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11407                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
11408    
11409                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11410                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11411    
11412                    clearUniqueFindersCache(dlFileEntry);
11413            }
11414    
11415            @Override
11416            public void clearCache(List<DLFileEntry> dlFileEntries) {
11417                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11418                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11419    
11420                    for (DLFileEntry dlFileEntry : dlFileEntries) {
11421                            EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11422                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
11423    
11424                            clearUniqueFindersCache(dlFileEntry);
11425                    }
11426            }
11427    
11428            protected void cacheUniqueFindersCache(DLFileEntry dlFileEntry) {
11429                    if (dlFileEntry.isNew()) {
11430                            Object[] args = new Object[] {
11431                                            dlFileEntry.getUuid(), dlFileEntry.getGroupId()
11432                                    };
11433    
11434                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
11435                                    Long.valueOf(1));
11436                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
11437                                    dlFileEntry);
11438    
11439                            args = new Object[] {
11440                                            dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11441                                            dlFileEntry.getName()
11442                                    };
11443    
11444                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N, args,
11445                                    Long.valueOf(1));
11446                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N, args,
11447                                    dlFileEntry);
11448    
11449                            args = new Object[] {
11450                                            dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11451                                            dlFileEntry.getFileName()
11452                                    };
11453    
11454                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_FN, args,
11455                                    Long.valueOf(1));
11456                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_FN, args,
11457                                    dlFileEntry);
11458    
11459                            args = new Object[] {
11460                                            dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11461                                            dlFileEntry.getTitle()
11462                                    };
11463    
11464                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_T, args,
11465                                    Long.valueOf(1));
11466                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T, args,
11467                                    dlFileEntry);
11468                    }
11469                    else {
11470                            DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
11471    
11472                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11473                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
11474                                    Object[] args = new Object[] {
11475                                                    dlFileEntry.getUuid(), dlFileEntry.getGroupId()
11476                                            };
11477    
11478                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
11479                                            Long.valueOf(1));
11480                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
11481                                            dlFileEntry);
11482                            }
11483    
11484                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11485                                            FINDER_PATH_FETCH_BY_G_F_N.getColumnBitmask()) != 0) {
11486                                    Object[] args = new Object[] {
11487                                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11488                                                    dlFileEntry.getName()
11489                                            };
11490    
11491                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N, args,
11492                                            Long.valueOf(1));
11493                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N, args,
11494                                            dlFileEntry);
11495                            }
11496    
11497                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11498                                            FINDER_PATH_FETCH_BY_G_F_FN.getColumnBitmask()) != 0) {
11499                                    Object[] args = new Object[] {
11500                                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11501                                                    dlFileEntry.getFileName()
11502                                            };
11503    
11504                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_FN, args,
11505                                            Long.valueOf(1));
11506                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_FN, args,
11507                                            dlFileEntry);
11508                            }
11509    
11510                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11511                                            FINDER_PATH_FETCH_BY_G_F_T.getColumnBitmask()) != 0) {
11512                                    Object[] args = new Object[] {
11513                                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11514                                                    dlFileEntry.getTitle()
11515                                            };
11516    
11517                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_T, args,
11518                                            Long.valueOf(1));
11519                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T, args,
11520                                            dlFileEntry);
11521                            }
11522                    }
11523            }
11524    
11525            protected void clearUniqueFindersCache(DLFileEntry dlFileEntry) {
11526                    DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
11527    
11528                    Object[] args = new Object[] {
11529                                    dlFileEntry.getUuid(), dlFileEntry.getGroupId()
11530                            };
11531    
11532                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
11533                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
11534    
11535                    if ((dlFileEntryModelImpl.getColumnBitmask() &
11536                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
11537                            args = new Object[] {
11538                                            dlFileEntryModelImpl.getOriginalUuid(),
11539                                            dlFileEntryModelImpl.getOriginalGroupId()
11540                                    };
11541    
11542                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
11543                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
11544                    }
11545    
11546                    args = new Object[] {
11547                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11548                                    dlFileEntry.getName()
11549                            };
11550    
11551                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_N, args);
11552                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N, args);
11553    
11554                    if ((dlFileEntryModelImpl.getColumnBitmask() &
11555                                    FINDER_PATH_FETCH_BY_G_F_N.getColumnBitmask()) != 0) {
11556                            args = new Object[] {
11557                                            dlFileEntryModelImpl.getOriginalGroupId(),
11558                                            dlFileEntryModelImpl.getOriginalFolderId(),
11559                                            dlFileEntryModelImpl.getOriginalName()
11560                                    };
11561    
11562                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_N, args);
11563                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N, args);
11564                    }
11565    
11566                    args = new Object[] {
11567                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11568                                    dlFileEntry.getFileName()
11569                            };
11570    
11571                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_FN, args);
11572                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_FN, args);
11573    
11574                    if ((dlFileEntryModelImpl.getColumnBitmask() &
11575                                    FINDER_PATH_FETCH_BY_G_F_FN.getColumnBitmask()) != 0) {
11576                            args = new Object[] {
11577                                            dlFileEntryModelImpl.getOriginalGroupId(),
11578                                            dlFileEntryModelImpl.getOriginalFolderId(),
11579                                            dlFileEntryModelImpl.getOriginalFileName()
11580                                    };
11581    
11582                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_FN, args);
11583                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_FN, args);
11584                    }
11585    
11586                    args = new Object[] {
11587                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11588                                    dlFileEntry.getTitle()
11589                            };
11590    
11591                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_T, args);
11592                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T, args);
11593    
11594                    if ((dlFileEntryModelImpl.getColumnBitmask() &
11595                                    FINDER_PATH_FETCH_BY_G_F_T.getColumnBitmask()) != 0) {
11596                            args = new Object[] {
11597                                            dlFileEntryModelImpl.getOriginalGroupId(),
11598                                            dlFileEntryModelImpl.getOriginalFolderId(),
11599                                            dlFileEntryModelImpl.getOriginalTitle()
11600                                    };
11601    
11602                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_T, args);
11603                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T, args);
11604                    }
11605            }
11606    
11607            /**
11608             * Creates a new document library file entry with the primary key. Does not add the document library file entry to the database.
11609             *
11610             * @param fileEntryId the primary key for the new document library file entry
11611             * @return the new document library file entry
11612             */
11613            @Override
11614            public DLFileEntry create(long fileEntryId) {
11615                    DLFileEntry dlFileEntry = new DLFileEntryImpl();
11616    
11617                    dlFileEntry.setNew(true);
11618                    dlFileEntry.setPrimaryKey(fileEntryId);
11619    
11620                    String uuid = PortalUUIDUtil.generate();
11621    
11622                    dlFileEntry.setUuid(uuid);
11623    
11624                    return dlFileEntry;
11625            }
11626    
11627            /**
11628             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
11629             *
11630             * @param fileEntryId the primary key of the document library file entry
11631             * @return the document library file entry that was removed
11632             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
11633             */
11634            @Override
11635            public DLFileEntry remove(long fileEntryId) throws NoSuchFileEntryException {
11636                    return remove((Serializable)fileEntryId);
11637            }
11638    
11639            /**
11640             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
11641             *
11642             * @param primaryKey the primary key of the document library file entry
11643             * @return the document library file entry that was removed
11644             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
11645             */
11646            @Override
11647            public DLFileEntry remove(Serializable primaryKey)
11648                    throws NoSuchFileEntryException {
11649                    Session session = null;
11650    
11651                    try {
11652                            session = openSession();
11653    
11654                            DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
11655                                            primaryKey);
11656    
11657                            if (dlFileEntry == null) {
11658                                    if (_log.isWarnEnabled()) {
11659                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
11660                                    }
11661    
11662                                    throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
11663                                            primaryKey);
11664                            }
11665    
11666                            return remove(dlFileEntry);
11667                    }
11668                    catch (NoSuchFileEntryException nsee) {
11669                            throw nsee;
11670                    }
11671                    catch (Exception e) {
11672                            throw processException(e);
11673                    }
11674                    finally {
11675                            closeSession(session);
11676                    }
11677            }
11678    
11679            @Override
11680            protected DLFileEntry removeImpl(DLFileEntry dlFileEntry) {
11681                    dlFileEntry = toUnwrappedModel(dlFileEntry);
11682    
11683                    Session session = null;
11684    
11685                    try {
11686                            session = openSession();
11687    
11688                            if (!session.contains(dlFileEntry)) {
11689                                    dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
11690                                                    dlFileEntry.getPrimaryKeyObj());
11691                            }
11692    
11693                            if (dlFileEntry != null) {
11694                                    session.delete(dlFileEntry);
11695                            }
11696                    }
11697                    catch (Exception e) {
11698                            throw processException(e);
11699                    }
11700                    finally {
11701                            closeSession(session);
11702                    }
11703    
11704                    if (dlFileEntry != null) {
11705                            clearCache(dlFileEntry);
11706                    }
11707    
11708                    return dlFileEntry;
11709            }
11710    
11711            @Override
11712            public DLFileEntry updateImpl(DLFileEntry dlFileEntry) {
11713                    dlFileEntry = toUnwrappedModel(dlFileEntry);
11714    
11715                    boolean isNew = dlFileEntry.isNew();
11716    
11717                    DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
11718    
11719                    if (Validator.isNull(dlFileEntry.getUuid())) {
11720                            String uuid = PortalUUIDUtil.generate();
11721    
11722                            dlFileEntry.setUuid(uuid);
11723                    }
11724    
11725                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
11726    
11727                    Date now = new Date();
11728    
11729                    if (isNew && (dlFileEntry.getCreateDate() == null)) {
11730                            if (serviceContext == null) {
11731                                    dlFileEntry.setCreateDate(now);
11732                            }
11733                            else {
11734                                    dlFileEntry.setCreateDate(serviceContext.getCreateDate(now));
11735                            }
11736                    }
11737    
11738                    if (!dlFileEntryModelImpl.hasSetModifiedDate()) {
11739                            if (serviceContext == null) {
11740                                    dlFileEntry.setModifiedDate(now);
11741                            }
11742                            else {
11743                                    dlFileEntry.setModifiedDate(serviceContext.getModifiedDate(now));
11744                            }
11745                    }
11746    
11747                    Session session = null;
11748    
11749                    try {
11750                            session = openSession();
11751    
11752                            if (dlFileEntry.isNew()) {
11753                                    session.save(dlFileEntry);
11754    
11755                                    dlFileEntry.setNew(false);
11756                            }
11757                            else {
11758                                    session.merge(dlFileEntry);
11759                            }
11760                    }
11761                    catch (Exception e) {
11762                            throw processException(e);
11763                    }
11764                    finally {
11765                            closeSession(session);
11766                    }
11767    
11768                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11769    
11770                    if (isNew || !DLFileEntryModelImpl.COLUMN_BITMASK_ENABLED) {
11771                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11772                    }
11773    
11774                    else {
11775                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11776                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
11777                                    Object[] args = new Object[] {
11778                                                    dlFileEntryModelImpl.getOriginalUuid()
11779                                            };
11780    
11781                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
11782                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
11783                                            args);
11784    
11785                                    args = new Object[] { dlFileEntryModelImpl.getUuid() };
11786    
11787                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
11788                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
11789                                            args);
11790                            }
11791    
11792                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11793                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
11794                                    Object[] args = new Object[] {
11795                                                    dlFileEntryModelImpl.getOriginalUuid(),
11796                                                    dlFileEntryModelImpl.getOriginalCompanyId()
11797                                            };
11798    
11799                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
11800                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
11801                                            args);
11802    
11803                                    args = new Object[] {
11804                                                    dlFileEntryModelImpl.getUuid(),
11805                                                    dlFileEntryModelImpl.getCompanyId()
11806                                            };
11807    
11808                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
11809                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
11810                                            args);
11811                            }
11812    
11813                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11814                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
11815                                    Object[] args = new Object[] {
11816                                                    dlFileEntryModelImpl.getOriginalGroupId()
11817                                            };
11818    
11819                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
11820                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
11821                                            args);
11822    
11823                                    args = new Object[] { dlFileEntryModelImpl.getGroupId() };
11824    
11825                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
11826                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
11827                                            args);
11828                            }
11829    
11830                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11831                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
11832                                    Object[] args = new Object[] {
11833                                                    dlFileEntryModelImpl.getOriginalCompanyId()
11834                                            };
11835    
11836                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
11837                                            args);
11838                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
11839                                            args);
11840    
11841                                    args = new Object[] { dlFileEntryModelImpl.getCompanyId() };
11842    
11843                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
11844                                            args);
11845                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
11846                                            args);
11847                            }
11848    
11849                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11850                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID.getColumnBitmask()) != 0) {
11851                                    Object[] args = new Object[] {
11852                                                    dlFileEntryModelImpl.getOriginalRepositoryId()
11853                                            };
11854    
11855                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
11856                                            args);
11857                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
11858                                            args);
11859    
11860                                    args = new Object[] { dlFileEntryModelImpl.getRepositoryId() };
11861    
11862                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
11863                                            args);
11864                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
11865                                            args);
11866                            }
11867    
11868                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11869                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE.getColumnBitmask()) != 0) {
11870                                    Object[] args = new Object[] {
11871                                                    dlFileEntryModelImpl.getOriginalMimeType()
11872                                            };
11873    
11874                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MIMETYPE, args);
11875                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE,
11876                                            args);
11877    
11878                                    args = new Object[] { dlFileEntryModelImpl.getMimeType() };
11879    
11880                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MIMETYPE, args);
11881                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE,
11882                                            args);
11883                            }
11884    
11885                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11886                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID.getColumnBitmask()) != 0) {
11887                                    Object[] args = new Object[] {
11888                                                    dlFileEntryModelImpl.getOriginalFileEntryTypeId()
11889                                            };
11890    
11891                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
11892                                            args);
11893                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
11894                                            args);
11895    
11896                                    args = new Object[] { dlFileEntryModelImpl.getFileEntryTypeId() };
11897    
11898                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
11899                                            args);
11900                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
11901                                            args);
11902                            }
11903    
11904                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11905                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
11906                                    Object[] args = new Object[] {
11907                                                    dlFileEntryModelImpl.getOriginalGroupId(),
11908                                                    dlFileEntryModelImpl.getOriginalUserId()
11909                                            };
11910    
11911                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
11912                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
11913                                            args);
11914    
11915                                    args = new Object[] {
11916                                                    dlFileEntryModelImpl.getGroupId(),
11917                                                    dlFileEntryModelImpl.getUserId()
11918                                            };
11919    
11920                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
11921                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
11922                                            args);
11923                            }
11924    
11925                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11926                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
11927                                    Object[] args = new Object[] {
11928                                                    dlFileEntryModelImpl.getOriginalGroupId(),
11929                                                    dlFileEntryModelImpl.getOriginalFolderId()
11930                                            };
11931    
11932                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
11933                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
11934                                            args);
11935    
11936                                    args = new Object[] {
11937                                                    dlFileEntryModelImpl.getGroupId(),
11938                                                    dlFileEntryModelImpl.getFolderId()
11939                                            };
11940    
11941                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
11942                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
11943                                            args);
11944                            }
11945    
11946                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11947                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F.getColumnBitmask()) != 0) {
11948                                    Object[] args = new Object[] {
11949                                                    dlFileEntryModelImpl.getOriginalRepositoryId(),
11950                                                    dlFileEntryModelImpl.getOriginalFolderId()
11951                                            };
11952    
11953                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_F, args);
11954                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F,
11955                                            args);
11956    
11957                                    args = new Object[] {
11958                                                    dlFileEntryModelImpl.getRepositoryId(),
11959                                                    dlFileEntryModelImpl.getFolderId()
11960                                            };
11961    
11962                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_F, args);
11963                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F,
11964                                            args);
11965                            }
11966    
11967                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11968                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N.getColumnBitmask()) != 0) {
11969                                    Object[] args = new Object[] {
11970                                                    dlFileEntryModelImpl.getOriginalFolderId(),
11971                                                    dlFileEntryModelImpl.getOriginalName()
11972                                            };
11973    
11974                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_N, args);
11975                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N,
11976                                            args);
11977    
11978                                    args = new Object[] {
11979                                                    dlFileEntryModelImpl.getFolderId(),
11980                                                    dlFileEntryModelImpl.getName()
11981                                            };
11982    
11983                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_N, args);
11984                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N,
11985                                            args);
11986                            }
11987    
11988                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11989                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F.getColumnBitmask()) != 0) {
11990                                    Object[] args = new Object[] {
11991                                                    dlFileEntryModelImpl.getOriginalGroupId(),
11992                                                    dlFileEntryModelImpl.getOriginalUserId(),
11993                                                    dlFileEntryModelImpl.getOriginalFolderId()
11994                                            };
11995    
11996                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
11997                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
11998                                            args);
11999    
12000                                    args = new Object[] {
12001                                                    dlFileEntryModelImpl.getGroupId(),
12002                                                    dlFileEntryModelImpl.getUserId(),
12003                                                    dlFileEntryModelImpl.getFolderId()
12004                                            };
12005    
12006                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
12007                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
12008                                            args);
12009                            }
12010    
12011                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12012                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F.getColumnBitmask()) != 0) {
12013                                    Object[] args = new Object[] {
12014                                                    dlFileEntryModelImpl.getOriginalGroupId(),
12015                                                    dlFileEntryModelImpl.getOriginalFolderId(),
12016                                                    dlFileEntryModelImpl.getOriginalFileEntryTypeId()
12017                                            };
12018    
12019                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
12020                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
12021                                            args);
12022    
12023                                    args = new Object[] {
12024                                                    dlFileEntryModelImpl.getGroupId(),
12025                                                    dlFileEntryModelImpl.getFolderId(),
12026                                                    dlFileEntryModelImpl.getFileEntryTypeId()
12027                                            };
12028    
12029                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
12030                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
12031                                            args);
12032                            }
12033                    }
12034    
12035                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12036                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry,
12037                            false);
12038    
12039                    clearUniqueFindersCache(dlFileEntry);
12040                    cacheUniqueFindersCache(dlFileEntry);
12041    
12042                    dlFileEntry.resetOriginalValues();
12043    
12044                    return dlFileEntry;
12045            }
12046    
12047            protected DLFileEntry toUnwrappedModel(DLFileEntry dlFileEntry) {
12048                    if (dlFileEntry instanceof DLFileEntryImpl) {
12049                            return dlFileEntry;
12050                    }
12051    
12052                    DLFileEntryImpl dlFileEntryImpl = new DLFileEntryImpl();
12053    
12054                    dlFileEntryImpl.setNew(dlFileEntry.isNew());
12055                    dlFileEntryImpl.setPrimaryKey(dlFileEntry.getPrimaryKey());
12056    
12057                    dlFileEntryImpl.setUuid(dlFileEntry.getUuid());
12058                    dlFileEntryImpl.setFileEntryId(dlFileEntry.getFileEntryId());
12059                    dlFileEntryImpl.setGroupId(dlFileEntry.getGroupId());
12060                    dlFileEntryImpl.setCompanyId(dlFileEntry.getCompanyId());
12061                    dlFileEntryImpl.setUserId(dlFileEntry.getUserId());
12062                    dlFileEntryImpl.setUserName(dlFileEntry.getUserName());
12063                    dlFileEntryImpl.setCreateDate(dlFileEntry.getCreateDate());
12064                    dlFileEntryImpl.setModifiedDate(dlFileEntry.getModifiedDate());
12065                    dlFileEntryImpl.setClassNameId(dlFileEntry.getClassNameId());
12066                    dlFileEntryImpl.setClassPK(dlFileEntry.getClassPK());
12067                    dlFileEntryImpl.setRepositoryId(dlFileEntry.getRepositoryId());
12068                    dlFileEntryImpl.setFolderId(dlFileEntry.getFolderId());
12069                    dlFileEntryImpl.setTreePath(dlFileEntry.getTreePath());
12070                    dlFileEntryImpl.setName(dlFileEntry.getName());
12071                    dlFileEntryImpl.setFileName(dlFileEntry.getFileName());
12072                    dlFileEntryImpl.setExtension(dlFileEntry.getExtension());
12073                    dlFileEntryImpl.setMimeType(dlFileEntry.getMimeType());
12074                    dlFileEntryImpl.setTitle(dlFileEntry.getTitle());
12075                    dlFileEntryImpl.setDescription(dlFileEntry.getDescription());
12076                    dlFileEntryImpl.setExtraSettings(dlFileEntry.getExtraSettings());
12077                    dlFileEntryImpl.setFileEntryTypeId(dlFileEntry.getFileEntryTypeId());
12078                    dlFileEntryImpl.setVersion(dlFileEntry.getVersion());
12079                    dlFileEntryImpl.setSize(dlFileEntry.getSize());
12080                    dlFileEntryImpl.setReadCount(dlFileEntry.getReadCount());
12081                    dlFileEntryImpl.setSmallImageId(dlFileEntry.getSmallImageId());
12082                    dlFileEntryImpl.setLargeImageId(dlFileEntry.getLargeImageId());
12083                    dlFileEntryImpl.setCustom1ImageId(dlFileEntry.getCustom1ImageId());
12084                    dlFileEntryImpl.setCustom2ImageId(dlFileEntry.getCustom2ImageId());
12085                    dlFileEntryImpl.setManualCheckInRequired(dlFileEntry.isManualCheckInRequired());
12086    
12087                    return dlFileEntryImpl;
12088            }
12089    
12090            /**
12091             * Returns the document library file entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
12092             *
12093             * @param primaryKey the primary key of the document library file entry
12094             * @return the document library file entry
12095             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
12096             */
12097            @Override
12098            public DLFileEntry findByPrimaryKey(Serializable primaryKey)
12099                    throws NoSuchFileEntryException {
12100                    DLFileEntry dlFileEntry = fetchByPrimaryKey(primaryKey);
12101    
12102                    if (dlFileEntry == null) {
12103                            if (_log.isWarnEnabled()) {
12104                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
12105                            }
12106    
12107                            throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
12108                                    primaryKey);
12109                    }
12110    
12111                    return dlFileEntry;
12112            }
12113    
12114            /**
12115             * Returns the document library file entry with the primary key or throws a {@link NoSuchFileEntryException} if it could not be found.
12116             *
12117             * @param fileEntryId the primary key of the document library file entry
12118             * @return the document library file entry
12119             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
12120             */
12121            @Override
12122            public DLFileEntry findByPrimaryKey(long fileEntryId)
12123                    throws NoSuchFileEntryException {
12124                    return findByPrimaryKey((Serializable)fileEntryId);
12125            }
12126    
12127            /**
12128             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
12129             *
12130             * @param primaryKey the primary key of the document library file entry
12131             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
12132             */
12133            @Override
12134            public DLFileEntry fetchByPrimaryKey(Serializable primaryKey) {
12135                    DLFileEntry dlFileEntry = (DLFileEntry)EntityCacheUtil.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12136                                    DLFileEntryImpl.class, primaryKey);
12137    
12138                    if (dlFileEntry == _nullDLFileEntry) {
12139                            return null;
12140                    }
12141    
12142                    if (dlFileEntry == null) {
12143                            Session session = null;
12144    
12145                            try {
12146                                    session = openSession();
12147    
12148                                    dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
12149                                                    primaryKey);
12150    
12151                                    if (dlFileEntry != null) {
12152                                            cacheResult(dlFileEntry);
12153                                    }
12154                                    else {
12155                                            EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12156                                                    DLFileEntryImpl.class, primaryKey, _nullDLFileEntry);
12157                                    }
12158                            }
12159                            catch (Exception e) {
12160                                    EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12161                                            DLFileEntryImpl.class, primaryKey);
12162    
12163                                    throw processException(e);
12164                            }
12165                            finally {
12166                                    closeSession(session);
12167                            }
12168                    }
12169    
12170                    return dlFileEntry;
12171            }
12172    
12173            /**
12174             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
12175             *
12176             * @param fileEntryId the primary key of the document library file entry
12177             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
12178             */
12179            @Override
12180            public DLFileEntry fetchByPrimaryKey(long fileEntryId) {
12181                    return fetchByPrimaryKey((Serializable)fileEntryId);
12182            }
12183    
12184            @Override
12185            public Map<Serializable, DLFileEntry> fetchByPrimaryKeys(
12186                    Set<Serializable> primaryKeys) {
12187                    if (primaryKeys.isEmpty()) {
12188                            return Collections.emptyMap();
12189                    }
12190    
12191                    Map<Serializable, DLFileEntry> map = new HashMap<Serializable, DLFileEntry>();
12192    
12193                    if (primaryKeys.size() == 1) {
12194                            Iterator<Serializable> iterator = primaryKeys.iterator();
12195    
12196                            Serializable primaryKey = iterator.next();
12197    
12198                            DLFileEntry dlFileEntry = fetchByPrimaryKey(primaryKey);
12199    
12200                            if (dlFileEntry != null) {
12201                                    map.put(primaryKey, dlFileEntry);
12202                            }
12203    
12204                            return map;
12205                    }
12206    
12207                    Set<Serializable> uncachedPrimaryKeys = null;
12208    
12209                    for (Serializable primaryKey : primaryKeys) {
12210                            DLFileEntry dlFileEntry = (DLFileEntry)EntityCacheUtil.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12211                                            DLFileEntryImpl.class, primaryKey);
12212    
12213                            if (dlFileEntry == null) {
12214                                    if (uncachedPrimaryKeys == null) {
12215                                            uncachedPrimaryKeys = new HashSet<Serializable>();
12216                                    }
12217    
12218                                    uncachedPrimaryKeys.add(primaryKey);
12219                            }
12220                            else {
12221                                    map.put(primaryKey, dlFileEntry);
12222                            }
12223                    }
12224    
12225                    if (uncachedPrimaryKeys == null) {
12226                            return map;
12227                    }
12228    
12229                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
12230                                    1);
12231    
12232                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE_PKS_IN);
12233    
12234                    for (Serializable primaryKey : uncachedPrimaryKeys) {
12235                            query.append(String.valueOf(primaryKey));
12236    
12237                            query.append(StringPool.COMMA);
12238                    }
12239    
12240                    query.setIndex(query.index() - 1);
12241    
12242                    query.append(StringPool.CLOSE_PARENTHESIS);
12243    
12244                    String sql = query.toString();
12245    
12246                    Session session = null;
12247    
12248                    try {
12249                            session = openSession();
12250    
12251                            Query q = session.createQuery(sql);
12252    
12253                            for (DLFileEntry dlFileEntry : (List<DLFileEntry>)q.list()) {
12254                                    map.put(dlFileEntry.getPrimaryKeyObj(), dlFileEntry);
12255    
12256                                    cacheResult(dlFileEntry);
12257    
12258                                    uncachedPrimaryKeys.remove(dlFileEntry.getPrimaryKeyObj());
12259                            }
12260    
12261                            for (Serializable primaryKey : uncachedPrimaryKeys) {
12262                                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12263                                            DLFileEntryImpl.class, primaryKey, _nullDLFileEntry);
12264                            }
12265                    }
12266                    catch (Exception e) {
12267                            throw processException(e);
12268                    }
12269                    finally {
12270                            closeSession(session);
12271                    }
12272    
12273                    return map;
12274            }
12275    
12276            /**
12277             * Returns all the document library file entries.
12278             *
12279             * @return the document library file entries
12280             */
12281            @Override
12282            public List<DLFileEntry> findAll() {
12283                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12284            }
12285    
12286            /**
12287             * Returns a range of all the document library file entries.
12288             *
12289             * <p>
12290             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
12291             * </p>
12292             *
12293             * @param start the lower bound of the range of document library file entries
12294             * @param end the upper bound of the range of document library file entries (not inclusive)
12295             * @return the range of document library file entries
12296             */
12297            @Override
12298            public List<DLFileEntry> findAll(int start, int end) {
12299                    return findAll(start, end, null);
12300            }
12301    
12302            /**
12303             * Returns an ordered range of all the document library file entries.
12304             *
12305             * <p>
12306             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. 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.
12307             * </p>
12308             *
12309             * @param start the lower bound of the range of document library file entries
12310             * @param end the upper bound of the range of document library file entries (not inclusive)
12311             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12312             * @return the ordered range of document library file entries
12313             */
12314            @Override
12315            public List<DLFileEntry> findAll(int start, int end,
12316                    OrderByComparator<DLFileEntry> orderByComparator) {
12317                    boolean pagination = true;
12318                    FinderPath finderPath = null;
12319                    Object[] finderArgs = null;
12320    
12321                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12322                                    (orderByComparator == null)) {
12323                            pagination = false;
12324                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
12325                            finderArgs = FINDER_ARGS_EMPTY;
12326                    }
12327                    else {
12328                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
12329                            finderArgs = new Object[] { start, end, orderByComparator };
12330                    }
12331    
12332                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
12333                                    finderArgs, this);
12334    
12335                    if (list == null) {
12336                            StringBundler query = null;
12337                            String sql = null;
12338    
12339                            if (orderByComparator != null) {
12340                                    query = new StringBundler(2 +
12341                                                    (orderByComparator.getOrderByFields().length * 3));
12342    
12343                                    query.append(_SQL_SELECT_DLFILEENTRY);
12344    
12345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12346                                            orderByComparator);
12347    
12348                                    sql = query.toString();
12349                            }
12350                            else {
12351                                    sql = _SQL_SELECT_DLFILEENTRY;
12352    
12353                                    if (pagination) {
12354                                            sql = sql.concat(DLFileEntryModelImpl.ORDER_BY_JPQL);
12355                                    }
12356                            }
12357    
12358                            Session session = null;
12359    
12360                            try {
12361                                    session = openSession();
12362    
12363                                    Query q = session.createQuery(sql);
12364    
12365                                    if (!pagination) {
12366                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
12367                                                            start, end, false);
12368    
12369                                            Collections.sort(list);
12370    
12371                                            list = Collections.unmodifiableList(list);
12372                                    }
12373                                    else {
12374                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
12375                                                            start, end);
12376                                    }
12377    
12378                                    cacheResult(list);
12379    
12380                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12381                            }
12382                            catch (Exception e) {
12383                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12384    
12385                                    throw processException(e);
12386                            }
12387                            finally {
12388                                    closeSession(session);
12389                            }
12390                    }
12391    
12392                    return list;
12393            }
12394    
12395            /**
12396             * Removes all the document library file entries from the database.
12397             *
12398             */
12399            @Override
12400            public void removeAll() {
12401                    for (DLFileEntry dlFileEntry : findAll()) {
12402                            remove(dlFileEntry);
12403                    }
12404            }
12405    
12406            /**
12407             * Returns the number of document library file entries.
12408             *
12409             * @return the number of document library file entries
12410             */
12411            @Override
12412            public int countAll() {
12413                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
12414                                    FINDER_ARGS_EMPTY, this);
12415    
12416                    if (count == null) {
12417                            Session session = null;
12418    
12419                            try {
12420                                    session = openSession();
12421    
12422                                    Query q = session.createQuery(_SQL_COUNT_DLFILEENTRY);
12423    
12424                                    count = (Long)q.uniqueResult();
12425    
12426                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
12427                                            FINDER_ARGS_EMPTY, count);
12428                            }
12429                            catch (Exception e) {
12430                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
12431                                            FINDER_ARGS_EMPTY);
12432    
12433                                    throw processException(e);
12434                            }
12435                            finally {
12436                                    closeSession(session);
12437                            }
12438                    }
12439    
12440                    return count.intValue();
12441            }
12442    
12443            @Override
12444            protected Set<String> getBadColumnNames() {
12445                    return _badColumnNames;
12446            }
12447    
12448            /**
12449             * Initializes the document library file entry persistence.
12450             */
12451            public void afterPropertiesSet() {
12452            }
12453    
12454            public void destroy() {
12455                    EntityCacheUtil.removeCache(DLFileEntryImpl.class.getName());
12456                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
12457                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12458                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12459            }
12460    
12461            private static final String _SQL_SELECT_DLFILEENTRY = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry";
12462            private static final String _SQL_SELECT_DLFILEENTRY_WHERE_PKS_IN = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE fileEntryId IN (";
12463            private static final String _SQL_SELECT_DLFILEENTRY_WHERE = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ";
12464            private static final String _SQL_COUNT_DLFILEENTRY = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry";
12465            private static final String _SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry WHERE ";
12466            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntry.fileEntryId";
12467            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_WHERE = "SELECT DISTINCT {dlFileEntry.*} FROM DLFileEntry dlFileEntry WHERE ";
12468            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1 =
12469                    "SELECT {DLFileEntry.*} FROM (SELECT DISTINCT dlFileEntry.fileEntryId FROM DLFileEntry dlFileEntry WHERE ";
12470            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2 =
12471                    ") TEMP_TABLE INNER JOIN DLFileEntry ON TEMP_TABLE.fileEntryId = DLFileEntry.fileEntryId";
12472            private static final String _FILTER_SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(DISTINCT dlFileEntry.fileEntryId) AS COUNT_VALUE FROM DLFileEntry dlFileEntry WHERE ";
12473            private static final String _FILTER_ENTITY_ALIAS = "dlFileEntry";
12474            private static final String _FILTER_ENTITY_TABLE = "DLFileEntry";
12475            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntry.";
12476            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntry.";
12477            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntry exists with the primary key ";
12478            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntry exists with the key {";
12479            private static final Log _log = LogFactoryUtil.getLog(DLFileEntryPersistenceImpl.class);
12480            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12481                                    "uuid", "size"
12482                            });
12483            private static final DLFileEntry _nullDLFileEntry = new DLFileEntryImpl() {
12484                            @Override
12485                            public Object clone() {
12486                                    return this;
12487                            }
12488    
12489                            @Override
12490                            public CacheModel<DLFileEntry> toCacheModel() {
12491                                    return _nullDLFileEntryCacheModel;
12492                            }
12493                    };
12494    
12495            private static final CacheModel<DLFileEntry> _nullDLFileEntryCacheModel = new CacheModel<DLFileEntry>() {
12496                            @Override
12497                            public DLFileEntry toEntityModel() {
12498                                    return _nullDLFileEntry;
12499                            }
12500                    };
12501    }