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