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