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