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