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