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