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_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6756                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
6757                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_F",
6758                            new String[] {
6759                                    Long.class.getName(), 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_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6765                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
6766                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F",
6767                            new String[] {
6768                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
6769                            },
6770                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
6771                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK |
6772                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
6773                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
6774            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6775                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6776                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F",
6777                            new String[] {
6778                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
6779                            });
6780            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6781                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6782                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_F",
6783                            new String[] {
6784                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
6785                            });
6786    
6787            /**
6788             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
6789             *
6790             * @param groupId the group ID
6791             * @param userId the user ID
6792             * @param folderId the folder ID
6793             * @return the matching document library file entries
6794             * @throws SystemException if a system exception occurred
6795             */
6796            @Override
6797            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
6798                    long folderId) throws SystemException {
6799                    return findByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
6800                            QueryUtil.ALL_POS, null);
6801            }
6802    
6803            /**
6804             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
6805             *
6806             * <p>
6807             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6808             * </p>
6809             *
6810             * @param groupId the group ID
6811             * @param userId the user ID
6812             * @param folderId the folder ID
6813             * @param start the lower bound of the range of document library file entries
6814             * @param end the upper bound of the range of document library file entries (not inclusive)
6815             * @return the range of matching document library file entries
6816             * @throws SystemException if a system exception occurred
6817             */
6818            @Override
6819            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
6820                    long folderId, int start, int end) throws SystemException {
6821                    return findByG_U_F(groupId, userId, folderId, start, end, null);
6822            }
6823    
6824            /**
6825             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
6826             *
6827             * <p>
6828             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6829             * </p>
6830             *
6831             * @param groupId the group ID
6832             * @param userId the user ID
6833             * @param folderId the folder ID
6834             * @param start the lower bound of the range of document library file entries
6835             * @param end the upper bound of the range of document library file entries (not inclusive)
6836             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6837             * @return the ordered range of matching document library file entries
6838             * @throws SystemException if a system exception occurred
6839             */
6840            @Override
6841            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
6842                    long folderId, int start, int end, OrderByComparator orderByComparator)
6843                    throws SystemException {
6844                    boolean pagination = true;
6845                    FinderPath finderPath = null;
6846                    Object[] finderArgs = null;
6847    
6848                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6849                                    (orderByComparator == null)) {
6850                            pagination = false;
6851                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F;
6852                            finderArgs = new Object[] { groupId, userId, folderId };
6853                    }
6854                    else {
6855                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
6856                            finderArgs = new Object[] {
6857                                            groupId, userId, folderId,
6858                                            
6859                                            start, end, orderByComparator
6860                                    };
6861                    }
6862    
6863                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
6864                                    finderArgs, this);
6865    
6866                    if ((list != null) && !list.isEmpty()) {
6867                            for (DLFileEntry dlFileEntry : list) {
6868                                    if ((groupId != dlFileEntry.getGroupId()) ||
6869                                                    (userId != dlFileEntry.getUserId()) ||
6870                                                    (folderId != dlFileEntry.getFolderId())) {
6871                                            list = null;
6872    
6873                                            break;
6874                                    }
6875                            }
6876                    }
6877    
6878                    if (list == null) {
6879                            StringBundler query = null;
6880    
6881                            if (orderByComparator != null) {
6882                                    query = new StringBundler(5 +
6883                                                    (orderByComparator.getOrderByFields().length * 3));
6884                            }
6885                            else {
6886                                    query = new StringBundler(5);
6887                            }
6888    
6889                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
6890    
6891                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
6892    
6893                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
6894    
6895                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
6896    
6897                            if (orderByComparator != null) {
6898                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6899                                            orderByComparator);
6900                            }
6901                            else
6902                             if (pagination) {
6903                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6904                            }
6905    
6906                            String sql = query.toString();
6907    
6908                            Session session = null;
6909    
6910                            try {
6911                                    session = openSession();
6912    
6913                                    Query q = session.createQuery(sql);
6914    
6915                                    QueryPos qPos = QueryPos.getInstance(q);
6916    
6917                                    qPos.add(groupId);
6918    
6919                                    qPos.add(userId);
6920    
6921                                    qPos.add(folderId);
6922    
6923                                    if (!pagination) {
6924                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6925                                                            start, end, false);
6926    
6927                                            Collections.sort(list);
6928    
6929                                            list = new UnmodifiableList<DLFileEntry>(list);
6930                                    }
6931                                    else {
6932                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6933                                                            start, end);
6934                                    }
6935    
6936                                    cacheResult(list);
6937    
6938                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6939                            }
6940                            catch (Exception e) {
6941                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6942    
6943                                    throw processException(e);
6944                            }
6945                            finally {
6946                                    closeSession(session);
6947                            }
6948                    }
6949    
6950                    return list;
6951            }
6952    
6953            /**
6954             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
6955             *
6956             * @param groupId the group ID
6957             * @param userId the user ID
6958             * @param folderId the folder ID
6959             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6960             * @return the first matching document library file entry
6961             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
6962             * @throws SystemException if a system exception occurred
6963             */
6964            @Override
6965            public DLFileEntry findByG_U_F_First(long groupId, long userId,
6966                    long folderId, OrderByComparator orderByComparator)
6967                    throws NoSuchFileEntryException, SystemException {
6968                    DLFileEntry dlFileEntry = fetchByG_U_F_First(groupId, userId, folderId,
6969                                    orderByComparator);
6970    
6971                    if (dlFileEntry != null) {
6972                            return dlFileEntry;
6973                    }
6974    
6975                    StringBundler msg = new StringBundler(8);
6976    
6977                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6978    
6979                    msg.append("groupId=");
6980                    msg.append(groupId);
6981    
6982                    msg.append(", userId=");
6983                    msg.append(userId);
6984    
6985                    msg.append(", folderId=");
6986                    msg.append(folderId);
6987    
6988                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6989    
6990                    throw new NoSuchFileEntryException(msg.toString());
6991            }
6992    
6993            /**
6994             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
6995             *
6996             * @param groupId the group ID
6997             * @param userId the user ID
6998             * @param folderId the folder ID
6999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7000             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7001             * @throws SystemException if a system exception occurred
7002             */
7003            @Override
7004            public DLFileEntry fetchByG_U_F_First(long groupId, long userId,
7005                    long folderId, OrderByComparator orderByComparator)
7006                    throws SystemException {
7007                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId, 0, 1,
7008                                    orderByComparator);
7009    
7010                    if (!list.isEmpty()) {
7011                            return list.get(0);
7012                    }
7013    
7014                    return null;
7015            }
7016    
7017            /**
7018             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
7019             *
7020             * @param groupId the group ID
7021             * @param userId the user ID
7022             * @param folderId the folder ID
7023             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7024             * @return the last matching document library file entry
7025             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
7026             * @throws SystemException if a system exception occurred
7027             */
7028            @Override
7029            public DLFileEntry findByG_U_F_Last(long groupId, long userId,
7030                    long folderId, OrderByComparator orderByComparator)
7031                    throws NoSuchFileEntryException, SystemException {
7032                    DLFileEntry dlFileEntry = fetchByG_U_F_Last(groupId, userId, folderId,
7033                                    orderByComparator);
7034    
7035                    if (dlFileEntry != null) {
7036                            return dlFileEntry;
7037                    }
7038    
7039                    StringBundler msg = new StringBundler(8);
7040    
7041                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7042    
7043                    msg.append("groupId=");
7044                    msg.append(groupId);
7045    
7046                    msg.append(", userId=");
7047                    msg.append(userId);
7048    
7049                    msg.append(", folderId=");
7050                    msg.append(folderId);
7051    
7052                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7053    
7054                    throw new NoSuchFileEntryException(msg.toString());
7055            }
7056    
7057            /**
7058             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
7059             *
7060             * @param groupId the group ID
7061             * @param userId the user ID
7062             * @param folderId the folder ID
7063             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7064             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7065             * @throws SystemException if a system exception occurred
7066             */
7067            @Override
7068            public DLFileEntry fetchByG_U_F_Last(long groupId, long userId,
7069                    long folderId, OrderByComparator orderByComparator)
7070                    throws SystemException {
7071                    int count = countByG_U_F(groupId, userId, folderId);
7072    
7073                    if (count == 0) {
7074                            return null;
7075                    }
7076    
7077                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId,
7078                                    count - 1, count, orderByComparator);
7079    
7080                    if (!list.isEmpty()) {
7081                            return list.get(0);
7082                    }
7083    
7084                    return null;
7085            }
7086    
7087            /**
7088             * 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;.
7089             *
7090             * @param fileEntryId the primary key of the current document library file entry
7091             * @param groupId the group ID
7092             * @param userId the user ID
7093             * @param folderId the folder ID
7094             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7095             * @return the previous, current, and next document library file entry
7096             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
7097             * @throws SystemException if a system exception occurred
7098             */
7099            @Override
7100            public DLFileEntry[] findByG_U_F_PrevAndNext(long fileEntryId,
7101                    long groupId, long userId, long folderId,
7102                    OrderByComparator orderByComparator)
7103                    throws NoSuchFileEntryException, SystemException {
7104                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
7105    
7106                    Session session = null;
7107    
7108                    try {
7109                            session = openSession();
7110    
7111                            DLFileEntry[] array = new DLFileEntryImpl[3];
7112    
7113                            array[0] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
7114                                            userId, folderId, orderByComparator, true);
7115    
7116                            array[1] = dlFileEntry;
7117    
7118                            array[2] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
7119                                            userId, folderId, orderByComparator, false);
7120    
7121                            return array;
7122                    }
7123                    catch (Exception e) {
7124                            throw processException(e);
7125                    }
7126                    finally {
7127                            closeSession(session);
7128                    }
7129            }
7130    
7131            protected DLFileEntry getByG_U_F_PrevAndNext(Session session,
7132                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
7133                    OrderByComparator orderByComparator, boolean previous) {
7134                    StringBundler query = null;
7135    
7136                    if (orderByComparator != null) {
7137                            query = new StringBundler(6 +
7138                                            (orderByComparator.getOrderByFields().length * 6));
7139                    }
7140                    else {
7141                            query = new StringBundler(3);
7142                    }
7143    
7144                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7145    
7146                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7147    
7148                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7149    
7150                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7151    
7152                    if (orderByComparator != null) {
7153                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7154    
7155                            if (orderByConditionFields.length > 0) {
7156                                    query.append(WHERE_AND);
7157                            }
7158    
7159                            for (int i = 0; i < orderByConditionFields.length; i++) {
7160                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7161                                    query.append(orderByConditionFields[i]);
7162    
7163                                    if ((i + 1) < orderByConditionFields.length) {
7164                                            if (orderByComparator.isAscending() ^ previous) {
7165                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7166                                            }
7167                                            else {
7168                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7169                                            }
7170                                    }
7171                                    else {
7172                                            if (orderByComparator.isAscending() ^ previous) {
7173                                                    query.append(WHERE_GREATER_THAN);
7174                                            }
7175                                            else {
7176                                                    query.append(WHERE_LESSER_THAN);
7177                                            }
7178                                    }
7179                            }
7180    
7181                            query.append(ORDER_BY_CLAUSE);
7182    
7183                            String[] orderByFields = orderByComparator.getOrderByFields();
7184    
7185                            for (int i = 0; i < orderByFields.length; i++) {
7186                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7187                                    query.append(orderByFields[i]);
7188    
7189                                    if ((i + 1) < orderByFields.length) {
7190                                            if (orderByComparator.isAscending() ^ previous) {
7191                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7192                                            }
7193                                            else {
7194                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7195                                            }
7196                                    }
7197                                    else {
7198                                            if (orderByComparator.isAscending() ^ previous) {
7199                                                    query.append(ORDER_BY_ASC);
7200                                            }
7201                                            else {
7202                                                    query.append(ORDER_BY_DESC);
7203                                            }
7204                                    }
7205                            }
7206                    }
7207                    else {
7208                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7209                    }
7210    
7211                    String sql = query.toString();
7212    
7213                    Query q = session.createQuery(sql);
7214    
7215                    q.setFirstResult(0);
7216                    q.setMaxResults(2);
7217    
7218                    QueryPos qPos = QueryPos.getInstance(q);
7219    
7220                    qPos.add(groupId);
7221    
7222                    qPos.add(userId);
7223    
7224                    qPos.add(folderId);
7225    
7226                    if (orderByComparator != null) {
7227                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
7228    
7229                            for (Object value : values) {
7230                                    qPos.add(value);
7231                            }
7232                    }
7233    
7234                    List<DLFileEntry> list = q.list();
7235    
7236                    if (list.size() == 2) {
7237                            return list.get(1);
7238                    }
7239                    else {
7240                            return null;
7241                    }
7242            }
7243    
7244            /**
7245             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
7246             *
7247             * @param groupId the group ID
7248             * @param userId the user ID
7249             * @param folderId the folder ID
7250             * @return the matching document library file entries that the user has permission to view
7251             * @throws SystemException if a system exception occurred
7252             */
7253            @Override
7254            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
7255                    long folderId) throws SystemException {
7256                    return filterFindByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
7257                            QueryUtil.ALL_POS, null);
7258            }
7259    
7260            /**
7261             * 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;.
7262             *
7263             * <p>
7264             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7265             * </p>
7266             *
7267             * @param groupId the group ID
7268             * @param userId the user ID
7269             * @param folderId the folder ID
7270             * @param start the lower bound of the range of document library file entries
7271             * @param end the upper bound of the range of document library file entries (not inclusive)
7272             * @return the range of matching document library file entries that the user has permission to view
7273             * @throws SystemException if a system exception occurred
7274             */
7275            @Override
7276            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
7277                    long folderId, int start, int end) throws SystemException {
7278                    return filterFindByG_U_F(groupId, userId, folderId, start, end, null);
7279            }
7280    
7281            /**
7282             * 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;.
7283             *
7284             * <p>
7285             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7286             * </p>
7287             *
7288             * @param groupId the group ID
7289             * @param userId the user ID
7290             * @param folderId the folder ID
7291             * @param start the lower bound of the range of document library file entries
7292             * @param end the upper bound of the range of document library file entries (not inclusive)
7293             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7294             * @return the ordered range of matching document library file entries that the user has permission to view
7295             * @throws SystemException if a system exception occurred
7296             */
7297            @Override
7298            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
7299                    long folderId, int start, int end, OrderByComparator orderByComparator)
7300                    throws SystemException {
7301                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7302                            return findByG_U_F(groupId, userId, folderId, start, end,
7303                                    orderByComparator);
7304                    }
7305    
7306                    StringBundler query = null;
7307    
7308                    if (orderByComparator != null) {
7309                            query = new StringBundler(5 +
7310                                            (orderByComparator.getOrderByFields().length * 3));
7311                    }
7312                    else {
7313                            query = new StringBundler(5);
7314                    }
7315    
7316                    if (getDB().isSupportsInlineDistinct()) {
7317                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
7318                    }
7319                    else {
7320                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
7321                    }
7322    
7323                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7324    
7325                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7326    
7327                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7328    
7329                    if (!getDB().isSupportsInlineDistinct()) {
7330                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
7331                    }
7332    
7333                    if (orderByComparator != null) {
7334                            if (getDB().isSupportsInlineDistinct()) {
7335                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7336                                            orderByComparator, true);
7337                            }
7338                            else {
7339                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7340                                            orderByComparator, true);
7341                            }
7342                    }
7343                    else {
7344                            if (getDB().isSupportsInlineDistinct()) {
7345                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7346                            }
7347                            else {
7348                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
7349                            }
7350                    }
7351    
7352                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7353                                    DLFileEntry.class.getName(),
7354                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7355    
7356                    Session session = null;
7357    
7358                    try {
7359                            session = openSession();
7360    
7361                            SQLQuery q = session.createSQLQuery(sql);
7362    
7363                            if (getDB().isSupportsInlineDistinct()) {
7364                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
7365                            }
7366                            else {
7367                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
7368                            }
7369    
7370                            QueryPos qPos = QueryPos.getInstance(q);
7371    
7372                            qPos.add(groupId);
7373    
7374                            qPos.add(userId);
7375    
7376                            qPos.add(folderId);
7377    
7378                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
7379                    }
7380                    catch (Exception e) {
7381                            throw processException(e);
7382                    }
7383                    finally {
7384                            closeSession(session);
7385                    }
7386            }
7387    
7388            /**
7389             * 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;.
7390             *
7391             * @param fileEntryId the primary key of the current document library file entry
7392             * @param groupId the group ID
7393             * @param userId the user ID
7394             * @param folderId the folder ID
7395             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7396             * @return the previous, current, and next document library file entry
7397             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
7398             * @throws SystemException if a system exception occurred
7399             */
7400            @Override
7401            public DLFileEntry[] filterFindByG_U_F_PrevAndNext(long fileEntryId,
7402                    long groupId, long userId, long folderId,
7403                    OrderByComparator orderByComparator)
7404                    throws NoSuchFileEntryException, SystemException {
7405                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7406                            return findByG_U_F_PrevAndNext(fileEntryId, groupId, userId,
7407                                    folderId, orderByComparator);
7408                    }
7409    
7410                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
7411    
7412                    Session session = null;
7413    
7414                    try {
7415                            session = openSession();
7416    
7417                            DLFileEntry[] array = new DLFileEntryImpl[3];
7418    
7419                            array[0] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
7420                                            groupId, userId, folderId, orderByComparator, true);
7421    
7422                            array[1] = dlFileEntry;
7423    
7424                            array[2] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
7425                                            groupId, userId, folderId, orderByComparator, false);
7426    
7427                            return array;
7428                    }
7429                    catch (Exception e) {
7430                            throw processException(e);
7431                    }
7432                    finally {
7433                            closeSession(session);
7434                    }
7435            }
7436    
7437            protected DLFileEntry filterGetByG_U_F_PrevAndNext(Session session,
7438                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
7439                    OrderByComparator orderByComparator, boolean previous) {
7440                    StringBundler query = null;
7441    
7442                    if (orderByComparator != null) {
7443                            query = new StringBundler(6 +
7444                                            (orderByComparator.getOrderByFields().length * 6));
7445                    }
7446                    else {
7447                            query = new StringBundler(3);
7448                    }
7449    
7450                    if (getDB().isSupportsInlineDistinct()) {
7451                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
7452                    }
7453                    else {
7454                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
7455                    }
7456    
7457                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7458    
7459                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7460    
7461                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7462    
7463                    if (!getDB().isSupportsInlineDistinct()) {
7464                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
7465                    }
7466    
7467                    if (orderByComparator != null) {
7468                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7469    
7470                            if (orderByConditionFields.length > 0) {
7471                                    query.append(WHERE_AND);
7472                            }
7473    
7474                            for (int i = 0; i < orderByConditionFields.length; i++) {
7475                                    if (getDB().isSupportsInlineDistinct()) {
7476                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7477                                    }
7478                                    else {
7479                                            query.append(_ORDER_BY_ENTITY_TABLE);
7480                                    }
7481    
7482                                    query.append(orderByConditionFields[i]);
7483    
7484                                    if ((i + 1) < orderByConditionFields.length) {
7485                                            if (orderByComparator.isAscending() ^ previous) {
7486                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7487                                            }
7488                                            else {
7489                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7490                                            }
7491                                    }
7492                                    else {
7493                                            if (orderByComparator.isAscending() ^ previous) {
7494                                                    query.append(WHERE_GREATER_THAN);
7495                                            }
7496                                            else {
7497                                                    query.append(WHERE_LESSER_THAN);
7498                                            }
7499                                    }
7500                            }
7501    
7502                            query.append(ORDER_BY_CLAUSE);
7503    
7504                            String[] orderByFields = orderByComparator.getOrderByFields();
7505    
7506                            for (int i = 0; i < orderByFields.length; i++) {
7507                                    if (getDB().isSupportsInlineDistinct()) {
7508                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7509                                    }
7510                                    else {
7511                                            query.append(_ORDER_BY_ENTITY_TABLE);
7512                                    }
7513    
7514                                    query.append(orderByFields[i]);
7515    
7516                                    if ((i + 1) < orderByFields.length) {
7517                                            if (orderByComparator.isAscending() ^ previous) {
7518                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7519                                            }
7520                                            else {
7521                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7522                                            }
7523                                    }
7524                                    else {
7525                                            if (orderByComparator.isAscending() ^ previous) {
7526                                                    query.append(ORDER_BY_ASC);
7527                                            }
7528                                            else {
7529                                                    query.append(ORDER_BY_DESC);
7530                                            }
7531                                    }
7532                            }
7533                    }
7534                    else {
7535                            if (getDB().isSupportsInlineDistinct()) {
7536                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7537                            }
7538                            else {
7539                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
7540                            }
7541                    }
7542    
7543                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7544                                    DLFileEntry.class.getName(),
7545                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7546    
7547                    SQLQuery q = session.createSQLQuery(sql);
7548    
7549                    q.setFirstResult(0);
7550                    q.setMaxResults(2);
7551    
7552                    if (getDB().isSupportsInlineDistinct()) {
7553                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
7554                    }
7555                    else {
7556                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
7557                    }
7558    
7559                    QueryPos qPos = QueryPos.getInstance(q);
7560    
7561                    qPos.add(groupId);
7562    
7563                    qPos.add(userId);
7564    
7565                    qPos.add(folderId);
7566    
7567                    if (orderByComparator != null) {
7568                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
7569    
7570                            for (Object value : values) {
7571                                    qPos.add(value);
7572                            }
7573                    }
7574    
7575                    List<DLFileEntry> list = q.list();
7576    
7577                    if (list.size() == 2) {
7578                            return list.get(1);
7579                    }
7580                    else {
7581                            return null;
7582                    }
7583            }
7584    
7585            /**
7586             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
7587             *
7588             * @param groupId the group ID
7589             * @param userId the user ID
7590             * @param folderIds the folder IDs
7591             * @return the matching document library file entries that the user has permission to view
7592             * @throws SystemException if a system exception occurred
7593             */
7594            @Override
7595            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
7596                    long[] folderIds) throws SystemException {
7597                    return filterFindByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
7598                            QueryUtil.ALL_POS, null);
7599            }
7600    
7601            /**
7602             * 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;.
7603             *
7604             * <p>
7605             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7606             * </p>
7607             *
7608             * @param groupId the group ID
7609             * @param userId the user ID
7610             * @param folderIds the folder IDs
7611             * @param start the lower bound of the range of document library file entries
7612             * @param end the upper bound of the range of document library file entries (not inclusive)
7613             * @return the range of matching document library file entries that the user has permission to view
7614             * @throws SystemException if a system exception occurred
7615             */
7616            @Override
7617            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
7618                    long[] folderIds, int start, int end) throws SystemException {
7619                    return filterFindByG_U_F(groupId, userId, folderIds, start, end, null);
7620            }
7621    
7622            /**
7623             * 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;.
7624             *
7625             * <p>
7626             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7627             * </p>
7628             *
7629             * @param groupId the group ID
7630             * @param userId the user ID
7631             * @param folderIds the folder IDs
7632             * @param start the lower bound of the range of document library file entries
7633             * @param end the upper bound of the range of document library file entries (not inclusive)
7634             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7635             * @return the ordered range of matching document library file entries that the user has permission to view
7636             * @throws SystemException if a system exception occurred
7637             */
7638            @Override
7639            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
7640                    long[] folderIds, int start, int end,
7641                    OrderByComparator orderByComparator) throws SystemException {
7642                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7643                            return findByG_U_F(groupId, userId, folderIds, start, end,
7644                                    orderByComparator);
7645                    }
7646    
7647                    StringBundler query = new StringBundler();
7648    
7649                    if (getDB().isSupportsInlineDistinct()) {
7650                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
7651                    }
7652                    else {
7653                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
7654                    }
7655    
7656                    boolean conjunctionable = false;
7657    
7658                    if (conjunctionable) {
7659                            query.append(WHERE_AND);
7660                    }
7661    
7662                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
7663    
7664                    conjunctionable = true;
7665    
7666                    if (conjunctionable) {
7667                            query.append(WHERE_AND);
7668                    }
7669    
7670                    query.append(_FINDER_COLUMN_G_U_F_USERID_5);
7671    
7672                    conjunctionable = true;
7673    
7674                    if ((folderIds == null) || (folderIds.length > 0)) {
7675                            if (conjunctionable) {
7676                                    query.append(WHERE_AND);
7677                            }
7678    
7679                            query.append(StringPool.OPEN_PARENTHESIS);
7680    
7681                            for (int i = 0; i < folderIds.length; i++) {
7682                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
7683    
7684                                    if ((i + 1) < folderIds.length) {
7685                                            query.append(WHERE_OR);
7686                                    }
7687                            }
7688    
7689                            query.append(StringPool.CLOSE_PARENTHESIS);
7690    
7691                            conjunctionable = true;
7692                    }
7693    
7694                    if (!getDB().isSupportsInlineDistinct()) {
7695                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
7696                    }
7697    
7698                    if (orderByComparator != null) {
7699                            if (getDB().isSupportsInlineDistinct()) {
7700                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7701                                            orderByComparator, true);
7702                            }
7703                            else {
7704                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7705                                            orderByComparator, true);
7706                            }
7707                    }
7708                    else {
7709                            if (getDB().isSupportsInlineDistinct()) {
7710                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7711                            }
7712                            else {
7713                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
7714                            }
7715                    }
7716    
7717                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7718                                    DLFileEntry.class.getName(),
7719                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7720    
7721                    Session session = null;
7722    
7723                    try {
7724                            session = openSession();
7725    
7726                            SQLQuery q = session.createSQLQuery(sql);
7727    
7728                            if (getDB().isSupportsInlineDistinct()) {
7729                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
7730                            }
7731                            else {
7732                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
7733                            }
7734    
7735                            QueryPos qPos = QueryPos.getInstance(q);
7736    
7737                            qPos.add(groupId);
7738    
7739                            qPos.add(userId);
7740    
7741                            if (folderIds != null) {
7742                                    qPos.add(folderIds);
7743                            }
7744    
7745                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
7746                    }
7747                    catch (Exception e) {
7748                            throw processException(e);
7749                    }
7750                    finally {
7751                            closeSession(session);
7752                    }
7753            }
7754    
7755            /**
7756             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
7757             *
7758             * <p>
7759             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7760             * </p>
7761             *
7762             * @param groupId the group ID
7763             * @param userId the user ID
7764             * @param folderIds the folder IDs
7765             * @return the matching document library file entries
7766             * @throws SystemException if a system exception occurred
7767             */
7768            @Override
7769            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7770                    long[] folderIds) throws SystemException {
7771                    return findByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
7772                            QueryUtil.ALL_POS, null);
7773            }
7774    
7775            /**
7776             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
7777             *
7778             * <p>
7779             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7780             * </p>
7781             *
7782             * @param groupId the group ID
7783             * @param userId the user ID
7784             * @param folderIds the folder IDs
7785             * @param start the lower bound of the range of document library file entries
7786             * @param end the upper bound of the range of document library file entries (not inclusive)
7787             * @return the range of matching document library file entries
7788             * @throws SystemException if a system exception occurred
7789             */
7790            @Override
7791            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7792                    long[] folderIds, int start, int end) throws SystemException {
7793                    return findByG_U_F(groupId, userId, folderIds, start, end, null);
7794            }
7795    
7796            /**
7797             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
7798             *
7799             * <p>
7800             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7801             * </p>
7802             *
7803             * @param groupId the group ID
7804             * @param userId the user ID
7805             * @param folderIds the folder IDs
7806             * @param start the lower bound of the range of document library file entries
7807             * @param end the upper bound of the range of document library file entries (not inclusive)
7808             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7809             * @return the ordered range of matching document library file entries
7810             * @throws SystemException if a system exception occurred
7811             */
7812            @Override
7813            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7814                    long[] folderIds, int start, int end,
7815                    OrderByComparator orderByComparator) throws SystemException {
7816                    if ((folderIds != null) && (folderIds.length == 1)) {
7817                            return findByG_U_F(groupId, userId, folderIds[0], start, end,
7818                                    orderByComparator);
7819                    }
7820    
7821                    boolean pagination = true;
7822                    Object[] finderArgs = null;
7823    
7824                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7825                                    (orderByComparator == null)) {
7826                            pagination = false;
7827                            finderArgs = new Object[] {
7828                                            groupId, userId, StringUtil.merge(folderIds)
7829                                    };
7830                    }
7831                    else {
7832                            finderArgs = new Object[] {
7833                                            groupId, userId, StringUtil.merge(folderIds),
7834                                            
7835                                            start, end, orderByComparator
7836                                    };
7837                    }
7838    
7839                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
7840                                    finderArgs, this);
7841    
7842                    if ((list != null) && !list.isEmpty()) {
7843                            for (DLFileEntry dlFileEntry : list) {
7844                                    if ((groupId != dlFileEntry.getGroupId()) ||
7845                                                    (userId != dlFileEntry.getUserId()) ||
7846                                                    !ArrayUtil.contains(folderIds, dlFileEntry.getFolderId())) {
7847                                            list = null;
7848    
7849                                            break;
7850                                    }
7851                            }
7852                    }
7853    
7854                    if (list == null) {
7855                            StringBundler query = new StringBundler();
7856    
7857                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7858    
7859                            boolean conjunctionable = false;
7860    
7861                            if (conjunctionable) {
7862                                    query.append(WHERE_AND);
7863                            }
7864    
7865                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
7866    
7867                            conjunctionable = true;
7868    
7869                            if (conjunctionable) {
7870                                    query.append(WHERE_AND);
7871                            }
7872    
7873                            query.append(_FINDER_COLUMN_G_U_F_USERID_5);
7874    
7875                            conjunctionable = true;
7876    
7877                            if ((folderIds == null) || (folderIds.length > 0)) {
7878                                    if (conjunctionable) {
7879                                            query.append(WHERE_AND);
7880                                    }
7881    
7882                                    query.append(StringPool.OPEN_PARENTHESIS);
7883    
7884                                    for (int i = 0; i < folderIds.length; i++) {
7885                                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
7886    
7887                                            if ((i + 1) < folderIds.length) {
7888                                                    query.append(WHERE_OR);
7889                                            }
7890                                    }
7891    
7892                                    query.append(StringPool.CLOSE_PARENTHESIS);
7893    
7894                                    conjunctionable = true;
7895                            }
7896    
7897                            if (orderByComparator != null) {
7898                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7899                                            orderByComparator);
7900                            }
7901                            else
7902                             if (pagination) {
7903                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7904                            }
7905    
7906                            String sql = query.toString();
7907    
7908                            Session session = null;
7909    
7910                            try {
7911                                    session = openSession();
7912    
7913                                    Query q = session.createQuery(sql);
7914    
7915                                    QueryPos qPos = QueryPos.getInstance(q);
7916    
7917                                    qPos.add(groupId);
7918    
7919                                    qPos.add(userId);
7920    
7921                                    if (folderIds != null) {
7922                                            qPos.add(folderIds);
7923                                    }
7924    
7925                                    if (!pagination) {
7926                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
7927                                                            start, end, false);
7928    
7929                                            Collections.sort(list);
7930    
7931                                            list = new UnmodifiableList<DLFileEntry>(list);
7932                                    }
7933                                    else {
7934                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
7935                                                            start, end);
7936                                    }
7937    
7938                                    cacheResult(list);
7939    
7940                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
7941                                            finderArgs, list);
7942                            }
7943                            catch (Exception e) {
7944                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
7945                                            finderArgs);
7946    
7947                                    throw processException(e);
7948                            }
7949                            finally {
7950                                    closeSession(session);
7951                            }
7952                    }
7953    
7954                    return list;
7955            }
7956    
7957            /**
7958             * Removes all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63; from the database.
7959             *
7960             * @param groupId the group ID
7961             * @param userId the user ID
7962             * @param folderId the folder ID
7963             * @throws SystemException if a system exception occurred
7964             */
7965            @Override
7966            public void removeByG_U_F(long groupId, long userId, long folderId)
7967                    throws SystemException {
7968                    for (DLFileEntry dlFileEntry : findByG_U_F(groupId, userId, folderId,
7969                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7970                            remove(dlFileEntry);
7971                    }
7972            }
7973    
7974            /**
7975             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7976             *
7977             * @param groupId the group ID
7978             * @param userId the user ID
7979             * @param folderId the folder ID
7980             * @return the number of matching document library file entries
7981             * @throws SystemException if a system exception occurred
7982             */
7983            @Override
7984            public int countByG_U_F(long groupId, long userId, long folderId)
7985                    throws SystemException {
7986                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_F;
7987    
7988                    Object[] finderArgs = new Object[] { groupId, userId, folderId };
7989    
7990                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7991                                    this);
7992    
7993                    if (count == null) {
7994                            StringBundler query = new StringBundler(4);
7995    
7996                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7997    
7998                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7999    
8000                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8001    
8002                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8003    
8004                            String sql = query.toString();
8005    
8006                            Session session = null;
8007    
8008                            try {
8009                                    session = openSession();
8010    
8011                                    Query q = session.createQuery(sql);
8012    
8013                                    QueryPos qPos = QueryPos.getInstance(q);
8014    
8015                                    qPos.add(groupId);
8016    
8017                                    qPos.add(userId);
8018    
8019                                    qPos.add(folderId);
8020    
8021                                    count = (Long)q.uniqueResult();
8022    
8023                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8024                            }
8025                            catch (Exception e) {
8026                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8027    
8028                                    throw processException(e);
8029                            }
8030                            finally {
8031                                    closeSession(session);
8032                            }
8033                    }
8034    
8035                    return count.intValue();
8036            }
8037    
8038            /**
8039             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8040             *
8041             * @param groupId the group ID
8042             * @param userId the user ID
8043             * @param folderIds the folder IDs
8044             * @return the number of matching document library file entries
8045             * @throws SystemException if a system exception occurred
8046             */
8047            @Override
8048            public int countByG_U_F(long groupId, long userId, long[] folderIds)
8049                    throws SystemException {
8050                    Object[] finderArgs = new Object[] {
8051                                    groupId, userId, StringUtil.merge(folderIds)
8052                            };
8053    
8054                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
8055                                    finderArgs, this);
8056    
8057                    if (count == null) {
8058                            StringBundler query = new StringBundler();
8059    
8060                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8061    
8062                            boolean conjunctionable = false;
8063    
8064                            if (conjunctionable) {
8065                                    query.append(WHERE_AND);
8066                            }
8067    
8068                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
8069    
8070                            conjunctionable = true;
8071    
8072                            if (conjunctionable) {
8073                                    query.append(WHERE_AND);
8074                            }
8075    
8076                            query.append(_FINDER_COLUMN_G_U_F_USERID_5);
8077    
8078                            conjunctionable = true;
8079    
8080                            if ((folderIds == null) || (folderIds.length > 0)) {
8081                                    if (conjunctionable) {
8082                                            query.append(WHERE_AND);
8083                                    }
8084    
8085                                    query.append(StringPool.OPEN_PARENTHESIS);
8086    
8087                                    for (int i = 0; i < folderIds.length; i++) {
8088                                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
8089    
8090                                            if ((i + 1) < folderIds.length) {
8091                                                    query.append(WHERE_OR);
8092                                            }
8093                                    }
8094    
8095                                    query.append(StringPool.CLOSE_PARENTHESIS);
8096    
8097                                    conjunctionable = true;
8098                            }
8099    
8100                            String sql = query.toString();
8101    
8102                            Session session = null;
8103    
8104                            try {
8105                                    session = openSession();
8106    
8107                                    Query q = session.createQuery(sql);
8108    
8109                                    QueryPos qPos = QueryPos.getInstance(q);
8110    
8111                                    qPos.add(groupId);
8112    
8113                                    qPos.add(userId);
8114    
8115                                    if (folderIds != null) {
8116                                            qPos.add(folderIds);
8117                                    }
8118    
8119                                    count = (Long)q.uniqueResult();
8120    
8121                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
8122                                            finderArgs, count);
8123                            }
8124                            catch (Exception e) {
8125                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
8126                                            finderArgs);
8127    
8128                                    throw processException(e);
8129                            }
8130                            finally {
8131                                    closeSession(session);
8132                            }
8133                    }
8134    
8135                    return count.intValue();
8136            }
8137    
8138            /**
8139             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
8140             *
8141             * @param groupId the group ID
8142             * @param userId the user ID
8143             * @param folderId the folder ID
8144             * @return the number of matching document library file entries that the user has permission to view
8145             * @throws SystemException if a system exception occurred
8146             */
8147            @Override
8148            public int filterCountByG_U_F(long groupId, long userId, long folderId)
8149                    throws SystemException {
8150                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8151                            return countByG_U_F(groupId, userId, folderId);
8152                    }
8153    
8154                    StringBundler query = new StringBundler(4);
8155    
8156                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
8157    
8158                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8159    
8160                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8161    
8162                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8163    
8164                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8165                                    DLFileEntry.class.getName(),
8166                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8167    
8168                    Session session = null;
8169    
8170                    try {
8171                            session = openSession();
8172    
8173                            SQLQuery q = session.createSQLQuery(sql);
8174    
8175                            q.addScalar(COUNT_COLUMN_NAME,
8176                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8177    
8178                            QueryPos qPos = QueryPos.getInstance(q);
8179    
8180                            qPos.add(groupId);
8181    
8182                            qPos.add(userId);
8183    
8184                            qPos.add(folderId);
8185    
8186                            Long count = (Long)q.uniqueResult();
8187    
8188                            return count.intValue();
8189                    }
8190                    catch (Exception e) {
8191                            throw processException(e);
8192                    }
8193                    finally {
8194                            closeSession(session);
8195                    }
8196            }
8197    
8198            /**
8199             * 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;.
8200             *
8201             * @param groupId the group ID
8202             * @param userId the user ID
8203             * @param folderIds the folder IDs
8204             * @return the number of matching document library file entries that the user has permission to view
8205             * @throws SystemException if a system exception occurred
8206             */
8207            @Override
8208            public int filterCountByG_U_F(long groupId, long userId, long[] folderIds)
8209                    throws SystemException {
8210                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8211                            return countByG_U_F(groupId, userId, folderIds);
8212                    }
8213    
8214                    StringBundler query = new StringBundler();
8215    
8216                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
8217    
8218                    boolean conjunctionable = false;
8219    
8220                    if (conjunctionable) {
8221                            query.append(WHERE_AND);
8222                    }
8223    
8224                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
8225    
8226                    conjunctionable = true;
8227    
8228                    if (conjunctionable) {
8229                            query.append(WHERE_AND);
8230                    }
8231    
8232                    query.append(_FINDER_COLUMN_G_U_F_USERID_5);
8233    
8234                    conjunctionable = true;
8235    
8236                    if ((folderIds == null) || (folderIds.length > 0)) {
8237                            if (conjunctionable) {
8238                                    query.append(WHERE_AND);
8239                            }
8240    
8241                            query.append(StringPool.OPEN_PARENTHESIS);
8242    
8243                            for (int i = 0; i < folderIds.length; i++) {
8244                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
8245    
8246                                    if ((i + 1) < folderIds.length) {
8247                                            query.append(WHERE_OR);
8248                                    }
8249                            }
8250    
8251                            query.append(StringPool.CLOSE_PARENTHESIS);
8252    
8253                            conjunctionable = true;
8254                    }
8255    
8256                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8257                                    DLFileEntry.class.getName(),
8258                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8259    
8260                    Session session = null;
8261    
8262                    try {
8263                            session = openSession();
8264    
8265                            SQLQuery q = session.createSQLQuery(sql);
8266    
8267                            q.addScalar(COUNT_COLUMN_NAME,
8268                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8269    
8270                            QueryPos qPos = QueryPos.getInstance(q);
8271    
8272                            qPos.add(groupId);
8273    
8274                            qPos.add(userId);
8275    
8276                            if (folderIds != null) {
8277                                    qPos.add(folderIds);
8278                            }
8279    
8280                            Long count = (Long)q.uniqueResult();
8281    
8282                            return count.intValue();
8283                    }
8284                    catch (Exception e) {
8285                            throw processException(e);
8286                    }
8287                    finally {
8288                            closeSession(session);
8289                    }
8290            }
8291    
8292            private static final String _FINDER_COLUMN_G_U_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8293            private static final String _FINDER_COLUMN_G_U_F_GROUPID_5 = "(" +
8294                    removeConjunction(_FINDER_COLUMN_G_U_F_GROUPID_2) + ")";
8295            private static final String _FINDER_COLUMN_G_U_F_USERID_2 = "dlFileEntry.userId = ? AND ";
8296            private static final String _FINDER_COLUMN_G_U_F_USERID_5 = "(" +
8297                    removeConjunction(_FINDER_COLUMN_G_U_F_USERID_2) + ")";
8298            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
8299            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_5 = "(" +
8300                    removeConjunction(_FINDER_COLUMN_G_U_F_FOLDERID_2) + ")";
8301            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
8302                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
8303                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_N",
8304                            new String[] {
8305                                    Long.class.getName(), Long.class.getName(),
8306                                    String.class.getName()
8307                            },
8308                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
8309                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
8310                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
8311            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
8312                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8313                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_N",
8314                            new String[] {
8315                                    Long.class.getName(), Long.class.getName(),
8316                                    String.class.getName()
8317                            });
8318    
8319            /**
8320             * 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.
8321             *
8322             * @param groupId the group ID
8323             * @param folderId the folder ID
8324             * @param name the name
8325             * @return the matching document library file entry
8326             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
8327             * @throws SystemException if a system exception occurred
8328             */
8329            @Override
8330            public DLFileEntry findByG_F_N(long groupId, long folderId, String name)
8331                    throws NoSuchFileEntryException, SystemException {
8332                    DLFileEntry dlFileEntry = fetchByG_F_N(groupId, folderId, name);
8333    
8334                    if (dlFileEntry == null) {
8335                            StringBundler msg = new StringBundler(8);
8336    
8337                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8338    
8339                            msg.append("groupId=");
8340                            msg.append(groupId);
8341    
8342                            msg.append(", folderId=");
8343                            msg.append(folderId);
8344    
8345                            msg.append(", name=");
8346                            msg.append(name);
8347    
8348                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8349    
8350                            if (_log.isWarnEnabled()) {
8351                                    _log.warn(msg.toString());
8352                            }
8353    
8354                            throw new NoSuchFileEntryException(msg.toString());
8355                    }
8356    
8357                    return dlFileEntry;
8358            }
8359    
8360            /**
8361             * 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.
8362             *
8363             * @param groupId the group ID
8364             * @param folderId the folder ID
8365             * @param name the name
8366             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
8367             * @throws SystemException if a system exception occurred
8368             */
8369            @Override
8370            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name)
8371                    throws SystemException {
8372                    return fetchByG_F_N(groupId, folderId, name, true);
8373            }
8374    
8375            /**
8376             * 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.
8377             *
8378             * @param groupId the group ID
8379             * @param folderId the folder ID
8380             * @param name the name
8381             * @param retrieveFromCache whether to use the finder cache
8382             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
8383             * @throws SystemException if a system exception occurred
8384             */
8385            @Override
8386            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name,
8387                    boolean retrieveFromCache) throws SystemException {
8388                    Object[] finderArgs = new Object[] { groupId, folderId, name };
8389    
8390                    Object result = null;
8391    
8392                    if (retrieveFromCache) {
8393                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_N,
8394                                            finderArgs, this);
8395                    }
8396    
8397                    if (result instanceof DLFileEntry) {
8398                            DLFileEntry dlFileEntry = (DLFileEntry)result;
8399    
8400                            if ((groupId != dlFileEntry.getGroupId()) ||
8401                                            (folderId != dlFileEntry.getFolderId()) ||
8402                                            !Validator.equals(name, dlFileEntry.getName())) {
8403                                    result = null;
8404                            }
8405                    }
8406    
8407                    if (result == null) {
8408                            StringBundler query = new StringBundler(5);
8409    
8410                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
8411    
8412                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
8413    
8414                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
8415    
8416                            boolean bindName = false;
8417    
8418                            if (name == null) {
8419                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
8420                            }
8421                            else if (name.equals(StringPool.BLANK)) {
8422                                    query.append(_FINDER_COLUMN_G_F_N_NAME_3);
8423                            }
8424                            else {
8425                                    bindName = true;
8426    
8427                                    query.append(_FINDER_COLUMN_G_F_N_NAME_2);
8428                            }
8429    
8430                            String sql = query.toString();
8431    
8432                            Session session = null;
8433    
8434                            try {
8435                                    session = openSession();
8436    
8437                                    Query q = session.createQuery(sql);
8438    
8439                                    QueryPos qPos = QueryPos.getInstance(q);
8440    
8441                                    qPos.add(groupId);
8442    
8443                                    qPos.add(folderId);
8444    
8445                                    if (bindName) {
8446                                            qPos.add(name);
8447                                    }
8448    
8449                                    List<DLFileEntry> list = q.list();
8450    
8451                                    if (list.isEmpty()) {
8452                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
8453                                                    finderArgs, list);
8454                                    }
8455                                    else {
8456                                            DLFileEntry dlFileEntry = list.get(0);
8457    
8458                                            result = dlFileEntry;
8459    
8460                                            cacheResult(dlFileEntry);
8461    
8462                                            if ((dlFileEntry.getGroupId() != groupId) ||
8463                                                            (dlFileEntry.getFolderId() != folderId) ||
8464                                                            (dlFileEntry.getName() == null) ||
8465                                                            !dlFileEntry.getName().equals(name)) {
8466                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
8467                                                            finderArgs, dlFileEntry);
8468                                            }
8469                                    }
8470                            }
8471                            catch (Exception e) {
8472                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
8473                                            finderArgs);
8474    
8475                                    throw processException(e);
8476                            }
8477                            finally {
8478                                    closeSession(session);
8479                            }
8480                    }
8481    
8482                    if (result instanceof List<?>) {
8483                            return null;
8484                    }
8485                    else {
8486                            return (DLFileEntry)result;
8487                    }
8488            }
8489    
8490            /**
8491             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; from the database.
8492             *
8493             * @param groupId the group ID
8494             * @param folderId the folder ID
8495             * @param name the name
8496             * @return the document library file entry that was removed
8497             * @throws SystemException if a system exception occurred
8498             */
8499            @Override
8500            public DLFileEntry removeByG_F_N(long groupId, long folderId, String name)
8501                    throws NoSuchFileEntryException, SystemException {
8502                    DLFileEntry dlFileEntry = findByG_F_N(groupId, folderId, name);
8503    
8504                    return remove(dlFileEntry);
8505            }
8506    
8507            /**
8508             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and name = &#63;.
8509             *
8510             * @param groupId the group ID
8511             * @param folderId the folder ID
8512             * @param name the name
8513             * @return the number of matching document library file entries
8514             * @throws SystemException if a system exception occurred
8515             */
8516            @Override
8517            public int countByG_F_N(long groupId, long folderId, String name)
8518                    throws SystemException {
8519                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_N;
8520    
8521                    Object[] finderArgs = new Object[] { groupId, folderId, name };
8522    
8523                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8524                                    this);
8525    
8526                    if (count == null) {
8527                            StringBundler query = new StringBundler(4);
8528    
8529                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8530    
8531                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
8532    
8533                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
8534    
8535                            boolean bindName = false;
8536    
8537                            if (name == null) {
8538                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
8539                            }
8540                            else if (name.equals(StringPool.BLANK)) {
8541                                    query.append(_FINDER_COLUMN_G_F_N_NAME_3);
8542                            }
8543                            else {
8544                                    bindName = true;
8545    
8546                                    query.append(_FINDER_COLUMN_G_F_N_NAME_2);
8547                            }
8548    
8549                            String sql = query.toString();
8550    
8551                            Session session = null;
8552    
8553                            try {
8554                                    session = openSession();
8555    
8556                                    Query q = session.createQuery(sql);
8557    
8558                                    QueryPos qPos = QueryPos.getInstance(q);
8559    
8560                                    qPos.add(groupId);
8561    
8562                                    qPos.add(folderId);
8563    
8564                                    if (bindName) {
8565                                            qPos.add(name);
8566                                    }
8567    
8568                                    count = (Long)q.uniqueResult();
8569    
8570                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8571                            }
8572                            catch (Exception e) {
8573                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8574    
8575                                    throw processException(e);
8576                            }
8577                            finally {
8578                                    closeSession(session);
8579                            }
8580                    }
8581    
8582                    return count.intValue();
8583            }
8584    
8585            private static final String _FINDER_COLUMN_G_F_N_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8586            private static final String _FINDER_COLUMN_G_F_N_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
8587            private static final String _FINDER_COLUMN_G_F_N_NAME_1 = "dlFileEntry.name IS NULL";
8588            private static final String _FINDER_COLUMN_G_F_N_NAME_2 = "dlFileEntry.name = ?";
8589            private static final String _FINDER_COLUMN_G_F_N_NAME_3 = "(dlFileEntry.name IS NULL OR dlFileEntry.name = '')";
8590            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
8591                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
8592                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_T",
8593                            new String[] {
8594                                    Long.class.getName(), Long.class.getName(),
8595                                    String.class.getName()
8596                            },
8597                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
8598                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
8599                            DLFileEntryModelImpl.TITLE_COLUMN_BITMASK);
8600            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
8601                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8602                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_T",
8603                            new String[] {
8604                                    Long.class.getName(), Long.class.getName(),
8605                                    String.class.getName()
8606                            });
8607    
8608            /**
8609             * 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.
8610             *
8611             * @param groupId the group ID
8612             * @param folderId the folder ID
8613             * @param title the title
8614             * @return the matching document library file entry
8615             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
8616             * @throws SystemException if a system exception occurred
8617             */
8618            @Override
8619            public DLFileEntry findByG_F_T(long groupId, long folderId, String title)
8620                    throws NoSuchFileEntryException, SystemException {
8621                    DLFileEntry dlFileEntry = fetchByG_F_T(groupId, folderId, title);
8622    
8623                    if (dlFileEntry == null) {
8624                            StringBundler msg = new StringBundler(8);
8625    
8626                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8627    
8628                            msg.append("groupId=");
8629                            msg.append(groupId);
8630    
8631                            msg.append(", folderId=");
8632                            msg.append(folderId);
8633    
8634                            msg.append(", title=");
8635                            msg.append(title);
8636    
8637                            msg.append(StringPool.CLOSE_CURLY_BRACE);
8638    
8639                            if (_log.isWarnEnabled()) {
8640                                    _log.warn(msg.toString());
8641                            }
8642    
8643                            throw new NoSuchFileEntryException(msg.toString());
8644                    }
8645    
8646                    return dlFileEntry;
8647            }
8648    
8649            /**
8650             * 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.
8651             *
8652             * @param groupId the group ID
8653             * @param folderId the folder ID
8654             * @param title the title
8655             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
8656             * @throws SystemException if a system exception occurred
8657             */
8658            @Override
8659            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title)
8660                    throws SystemException {
8661                    return fetchByG_F_T(groupId, folderId, title, true);
8662            }
8663    
8664            /**
8665             * 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.
8666             *
8667             * @param groupId the group ID
8668             * @param folderId the folder ID
8669             * @param title the title
8670             * @param retrieveFromCache whether to use the finder cache
8671             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
8672             * @throws SystemException if a system exception occurred
8673             */
8674            @Override
8675            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title,
8676                    boolean retrieveFromCache) throws SystemException {
8677                    Object[] finderArgs = new Object[] { groupId, folderId, title };
8678    
8679                    Object result = null;
8680    
8681                    if (retrieveFromCache) {
8682                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_T,
8683                                            finderArgs, this);
8684                    }
8685    
8686                    if (result instanceof DLFileEntry) {
8687                            DLFileEntry dlFileEntry = (DLFileEntry)result;
8688    
8689                            if ((groupId != dlFileEntry.getGroupId()) ||
8690                                            (folderId != dlFileEntry.getFolderId()) ||
8691                                            !Validator.equals(title, dlFileEntry.getTitle())) {
8692                                    result = null;
8693                            }
8694                    }
8695    
8696                    if (result == null) {
8697                            StringBundler query = new StringBundler(5);
8698    
8699                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
8700    
8701                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
8702    
8703                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
8704    
8705                            boolean bindTitle = false;
8706    
8707                            if (title == null) {
8708                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
8709                            }
8710                            else if (title.equals(StringPool.BLANK)) {
8711                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
8712                            }
8713                            else {
8714                                    bindTitle = true;
8715    
8716                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
8717                            }
8718    
8719                            String sql = query.toString();
8720    
8721                            Session session = null;
8722    
8723                            try {
8724                                    session = openSession();
8725    
8726                                    Query q = session.createQuery(sql);
8727    
8728                                    QueryPos qPos = QueryPos.getInstance(q);
8729    
8730                                    qPos.add(groupId);
8731    
8732                                    qPos.add(folderId);
8733    
8734                                    if (bindTitle) {
8735                                            qPos.add(title);
8736                                    }
8737    
8738                                    List<DLFileEntry> list = q.list();
8739    
8740                                    if (list.isEmpty()) {
8741                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
8742                                                    finderArgs, list);
8743                                    }
8744                                    else {
8745                                            DLFileEntry dlFileEntry = list.get(0);
8746    
8747                                            result = dlFileEntry;
8748    
8749                                            cacheResult(dlFileEntry);
8750    
8751                                            if ((dlFileEntry.getGroupId() != groupId) ||
8752                                                            (dlFileEntry.getFolderId() != folderId) ||
8753                                                            (dlFileEntry.getTitle() == null) ||
8754                                                            !dlFileEntry.getTitle().equals(title)) {
8755                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
8756                                                            finderArgs, dlFileEntry);
8757                                            }
8758                                    }
8759                            }
8760                            catch (Exception e) {
8761                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
8762                                            finderArgs);
8763    
8764                                    throw processException(e);
8765                            }
8766                            finally {
8767                                    closeSession(session);
8768                            }
8769                    }
8770    
8771                    if (result instanceof List<?>) {
8772                            return null;
8773                    }
8774                    else {
8775                            return (DLFileEntry)result;
8776                    }
8777            }
8778    
8779            /**
8780             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; from the database.
8781             *
8782             * @param groupId the group ID
8783             * @param folderId the folder ID
8784             * @param title the title
8785             * @return the document library file entry that was removed
8786             * @throws SystemException if a system exception occurred
8787             */
8788            @Override
8789            public DLFileEntry removeByG_F_T(long groupId, long folderId, String title)
8790                    throws NoSuchFileEntryException, SystemException {
8791                    DLFileEntry dlFileEntry = findByG_F_T(groupId, folderId, title);
8792    
8793                    return remove(dlFileEntry);
8794            }
8795    
8796            /**
8797             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and title = &#63;.
8798             *
8799             * @param groupId the group ID
8800             * @param folderId the folder ID
8801             * @param title the title
8802             * @return the number of matching document library file entries
8803             * @throws SystemException if a system exception occurred
8804             */
8805            @Override
8806            public int countByG_F_T(long groupId, long folderId, String title)
8807                    throws SystemException {
8808                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_T;
8809    
8810                    Object[] finderArgs = new Object[] { groupId, folderId, title };
8811    
8812                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8813                                    this);
8814    
8815                    if (count == null) {
8816                            StringBundler query = new StringBundler(4);
8817    
8818                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8819    
8820                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
8821    
8822                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
8823    
8824                            boolean bindTitle = false;
8825    
8826                            if (title == null) {
8827                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
8828                            }
8829                            else if (title.equals(StringPool.BLANK)) {
8830                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
8831                            }
8832                            else {
8833                                    bindTitle = true;
8834    
8835                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
8836                            }
8837    
8838                            String sql = query.toString();
8839    
8840                            Session session = null;
8841    
8842                            try {
8843                                    session = openSession();
8844    
8845                                    Query q = session.createQuery(sql);
8846    
8847                                    QueryPos qPos = QueryPos.getInstance(q);
8848    
8849                                    qPos.add(groupId);
8850    
8851                                    qPos.add(folderId);
8852    
8853                                    if (bindTitle) {
8854                                            qPos.add(title);
8855                                    }
8856    
8857                                    count = (Long)q.uniqueResult();
8858    
8859                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8860                            }
8861                            catch (Exception e) {
8862                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8863    
8864                                    throw processException(e);
8865                            }
8866                            finally {
8867                                    closeSession(session);
8868                            }
8869                    }
8870    
8871                    return count.intValue();
8872            }
8873    
8874            private static final String _FINDER_COLUMN_G_F_T_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8875            private static final String _FINDER_COLUMN_G_F_T_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
8876            private static final String _FINDER_COLUMN_G_F_T_TITLE_1 = "dlFileEntry.title IS NULL";
8877            private static final String _FINDER_COLUMN_G_F_T_TITLE_2 = "dlFileEntry.title = ?";
8878            private static final String _FINDER_COLUMN_G_F_T_TITLE_3 = "(dlFileEntry.title IS NULL OR dlFileEntry.title = '')";
8879            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
8880                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
8881                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F_F",
8882                            new String[] {
8883                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
8884                                    
8885                            Integer.class.getName(), Integer.class.getName(),
8886                                    OrderByComparator.class.getName()
8887                            });
8888            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
8889                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
8890                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_F",
8891                            new String[] {
8892                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
8893                            },
8894                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
8895                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
8896                            DLFileEntryModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK |
8897                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
8898            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
8899                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8900                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_F",
8901                            new String[] {
8902                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
8903                            });
8904            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
8905                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8906                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_F",
8907                            new String[] {
8908                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
8909                            });
8910    
8911            /**
8912             * Returns all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
8913             *
8914             * @param groupId the group ID
8915             * @param folderId the folder ID
8916             * @param fileEntryTypeId the file entry type ID
8917             * @return the matching document library file entries
8918             * @throws SystemException if a system exception occurred
8919             */
8920            @Override
8921            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
8922                    long fileEntryTypeId) throws SystemException {
8923                    return findByG_F_F(groupId, folderId, fileEntryTypeId,
8924                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8925            }
8926    
8927            /**
8928             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
8929             *
8930             * <p>
8931             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8932             * </p>
8933             *
8934             * @param groupId the group ID
8935             * @param folderId the folder ID
8936             * @param fileEntryTypeId the file entry type ID
8937             * @param start the lower bound of the range of document library file entries
8938             * @param end the upper bound of the range of document library file entries (not inclusive)
8939             * @return the range of matching document library file entries
8940             * @throws SystemException if a system exception occurred
8941             */
8942            @Override
8943            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
8944                    long fileEntryTypeId, int start, int end) throws SystemException {
8945                    return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end, null);
8946            }
8947    
8948            /**
8949             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
8950             *
8951             * <p>
8952             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8953             * </p>
8954             *
8955             * @param groupId the group ID
8956             * @param folderId the folder ID
8957             * @param fileEntryTypeId the file entry type ID
8958             * @param start the lower bound of the range of document library file entries
8959             * @param end the upper bound of the range of document library file entries (not inclusive)
8960             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8961             * @return the ordered range of matching document library file entries
8962             * @throws SystemException if a system exception occurred
8963             */
8964            @Override
8965            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
8966                    long fileEntryTypeId, int start, int end,
8967                    OrderByComparator orderByComparator) throws SystemException {
8968                    boolean pagination = true;
8969                    FinderPath finderPath = null;
8970                    Object[] finderArgs = null;
8971    
8972                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8973                                    (orderByComparator == null)) {
8974                            pagination = false;
8975                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F;
8976                            finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
8977                    }
8978                    else {
8979                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F;
8980                            finderArgs = new Object[] {
8981                                            groupId, folderId, fileEntryTypeId,
8982                                            
8983                                            start, end, orderByComparator
8984                                    };
8985                    }
8986    
8987                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
8988                                    finderArgs, this);
8989    
8990                    if ((list != null) && !list.isEmpty()) {
8991                            for (DLFileEntry dlFileEntry : list) {
8992                                    if ((groupId != dlFileEntry.getGroupId()) ||
8993                                                    (folderId != dlFileEntry.getFolderId()) ||
8994                                                    (fileEntryTypeId != dlFileEntry.getFileEntryTypeId())) {
8995                                            list = null;
8996    
8997                                            break;
8998                                    }
8999                            }
9000                    }
9001    
9002                    if (list == null) {
9003                            StringBundler query = null;
9004    
9005                            if (orderByComparator != null) {
9006                                    query = new StringBundler(5 +
9007                                                    (orderByComparator.getOrderByFields().length * 3));
9008                            }
9009                            else {
9010                                    query = new StringBundler(5);
9011                            }
9012    
9013                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9014    
9015                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
9016    
9017                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
9018    
9019                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
9020    
9021                            if (orderByComparator != null) {
9022                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9023                                            orderByComparator);
9024                            }
9025                            else
9026                             if (pagination) {
9027                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
9028                            }
9029    
9030                            String sql = query.toString();
9031    
9032                            Session session = null;
9033    
9034                            try {
9035                                    session = openSession();
9036    
9037                                    Query q = session.createQuery(sql);
9038    
9039                                    QueryPos qPos = QueryPos.getInstance(q);
9040    
9041                                    qPos.add(groupId);
9042    
9043                                    qPos.add(folderId);
9044    
9045                                    qPos.add(fileEntryTypeId);
9046    
9047                                    if (!pagination) {
9048                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
9049                                                            start, end, false);
9050    
9051                                            Collections.sort(list);
9052    
9053                                            list = new UnmodifiableList<DLFileEntry>(list);
9054                                    }
9055                                    else {
9056                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
9057                                                            start, end);
9058                                    }
9059    
9060                                    cacheResult(list);
9061    
9062                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9063                            }
9064                            catch (Exception e) {
9065                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9066    
9067                                    throw processException(e);
9068                            }
9069                            finally {
9070                                    closeSession(session);
9071                            }
9072                    }
9073    
9074                    return list;
9075            }
9076    
9077            /**
9078             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
9079             *
9080             * @param groupId the group ID
9081             * @param folderId the folder ID
9082             * @param fileEntryTypeId the file entry type ID
9083             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9084             * @return the first matching document library file entry
9085             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
9086             * @throws SystemException if a system exception occurred
9087             */
9088            @Override
9089            public DLFileEntry findByG_F_F_First(long groupId, long folderId,
9090                    long fileEntryTypeId, OrderByComparator orderByComparator)
9091                    throws NoSuchFileEntryException, SystemException {
9092                    DLFileEntry dlFileEntry = fetchByG_F_F_First(groupId, folderId,
9093                                    fileEntryTypeId, orderByComparator);
9094    
9095                    if (dlFileEntry != null) {
9096                            return dlFileEntry;
9097                    }
9098    
9099                    StringBundler msg = new StringBundler(8);
9100    
9101                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9102    
9103                    msg.append("groupId=");
9104                    msg.append(groupId);
9105    
9106                    msg.append(", folderId=");
9107                    msg.append(folderId);
9108    
9109                    msg.append(", fileEntryTypeId=");
9110                    msg.append(fileEntryTypeId);
9111    
9112                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9113    
9114                    throw new NoSuchFileEntryException(msg.toString());
9115            }
9116    
9117            /**
9118             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
9119             *
9120             * @param groupId the group ID
9121             * @param folderId the folder ID
9122             * @param fileEntryTypeId the file entry type ID
9123             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9124             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9125             * @throws SystemException if a system exception occurred
9126             */
9127            @Override
9128            public DLFileEntry fetchByG_F_F_First(long groupId, long folderId,
9129                    long fileEntryTypeId, OrderByComparator orderByComparator)
9130                    throws SystemException {
9131                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
9132                                    fileEntryTypeId, 0, 1, orderByComparator);
9133    
9134                    if (!list.isEmpty()) {
9135                            return list.get(0);
9136                    }
9137    
9138                    return null;
9139            }
9140    
9141            /**
9142             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
9143             *
9144             * @param groupId the group ID
9145             * @param folderId the folder ID
9146             * @param fileEntryTypeId the file entry type ID
9147             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9148             * @return the last matching document library file entry
9149             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
9150             * @throws SystemException if a system exception occurred
9151             */
9152            @Override
9153            public DLFileEntry findByG_F_F_Last(long groupId, long folderId,
9154                    long fileEntryTypeId, OrderByComparator orderByComparator)
9155                    throws NoSuchFileEntryException, SystemException {
9156                    DLFileEntry dlFileEntry = fetchByG_F_F_Last(groupId, folderId,
9157                                    fileEntryTypeId, orderByComparator);
9158    
9159                    if (dlFileEntry != null) {
9160                            return dlFileEntry;
9161                    }
9162    
9163                    StringBundler msg = new StringBundler(8);
9164    
9165                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9166    
9167                    msg.append("groupId=");
9168                    msg.append(groupId);
9169    
9170                    msg.append(", folderId=");
9171                    msg.append(folderId);
9172    
9173                    msg.append(", fileEntryTypeId=");
9174                    msg.append(fileEntryTypeId);
9175    
9176                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9177    
9178                    throw new NoSuchFileEntryException(msg.toString());
9179            }
9180    
9181            /**
9182             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
9183             *
9184             * @param groupId the group ID
9185             * @param folderId the folder ID
9186             * @param fileEntryTypeId the file entry type ID
9187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9188             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9189             * @throws SystemException if a system exception occurred
9190             */
9191            @Override
9192            public DLFileEntry fetchByG_F_F_Last(long groupId, long folderId,
9193                    long fileEntryTypeId, OrderByComparator orderByComparator)
9194                    throws SystemException {
9195                    int count = countByG_F_F(groupId, folderId, fileEntryTypeId);
9196    
9197                    if (count == 0) {
9198                            return null;
9199                    }
9200    
9201                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
9202                                    fileEntryTypeId, count - 1, count, orderByComparator);
9203    
9204                    if (!list.isEmpty()) {
9205                            return list.get(0);
9206                    }
9207    
9208                    return null;
9209            }
9210    
9211            /**
9212             * 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;.
9213             *
9214             * @param fileEntryId the primary key of the current document library file entry
9215             * @param groupId the group ID
9216             * @param folderId the folder ID
9217             * @param fileEntryTypeId the file entry type ID
9218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9219             * @return the previous, current, and next document library file entry
9220             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
9221             * @throws SystemException if a system exception occurred
9222             */
9223            @Override
9224            public DLFileEntry[] findByG_F_F_PrevAndNext(long fileEntryId,
9225                    long groupId, long folderId, long fileEntryTypeId,
9226                    OrderByComparator orderByComparator)
9227                    throws NoSuchFileEntryException, SystemException {
9228                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
9229    
9230                    Session session = null;
9231    
9232                    try {
9233                            session = openSession();
9234    
9235                            DLFileEntry[] array = new DLFileEntryImpl[3];
9236    
9237                            array[0] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
9238                                            folderId, fileEntryTypeId, orderByComparator, true);
9239    
9240                            array[1] = dlFileEntry;
9241    
9242                            array[2] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
9243                                            folderId, fileEntryTypeId, orderByComparator, false);
9244    
9245                            return array;
9246                    }
9247                    catch (Exception e) {
9248                            throw processException(e);
9249                    }
9250                    finally {
9251                            closeSession(session);
9252                    }
9253            }
9254    
9255            protected DLFileEntry getByG_F_F_PrevAndNext(Session session,
9256                    DLFileEntry dlFileEntry, long groupId, long folderId,
9257                    long fileEntryTypeId, OrderByComparator orderByComparator,
9258                    boolean previous) {
9259                    StringBundler query = null;
9260    
9261                    if (orderByComparator != null) {
9262                            query = new StringBundler(6 +
9263                                            (orderByComparator.getOrderByFields().length * 6));
9264                    }
9265                    else {
9266                            query = new StringBundler(3);
9267                    }
9268    
9269                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9270    
9271                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
9272    
9273                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
9274    
9275                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
9276    
9277                    if (orderByComparator != null) {
9278                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9279    
9280                            if (orderByConditionFields.length > 0) {
9281                                    query.append(WHERE_AND);
9282                            }
9283    
9284                            for (int i = 0; i < orderByConditionFields.length; i++) {
9285                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9286                                    query.append(orderByConditionFields[i]);
9287    
9288                                    if ((i + 1) < orderByConditionFields.length) {
9289                                            if (orderByComparator.isAscending() ^ previous) {
9290                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9291                                            }
9292                                            else {
9293                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9294                                            }
9295                                    }
9296                                    else {
9297                                            if (orderByComparator.isAscending() ^ previous) {
9298                                                    query.append(WHERE_GREATER_THAN);
9299                                            }
9300                                            else {
9301                                                    query.append(WHERE_LESSER_THAN);
9302                                            }
9303                                    }
9304                            }
9305    
9306                            query.append(ORDER_BY_CLAUSE);
9307    
9308                            String[] orderByFields = orderByComparator.getOrderByFields();
9309    
9310                            for (int i = 0; i < orderByFields.length; i++) {
9311                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9312                                    query.append(orderByFields[i]);
9313    
9314                                    if ((i + 1) < orderByFields.length) {
9315                                            if (orderByComparator.isAscending() ^ previous) {
9316                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9317                                            }
9318                                            else {
9319                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9320                                            }
9321                                    }
9322                                    else {
9323                                            if (orderByComparator.isAscending() ^ previous) {
9324                                                    query.append(ORDER_BY_ASC);
9325                                            }
9326                                            else {
9327                                                    query.append(ORDER_BY_DESC);
9328                                            }
9329                                    }
9330                            }
9331                    }
9332                    else {
9333                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
9334                    }
9335    
9336                    String sql = query.toString();
9337    
9338                    Query q = session.createQuery(sql);
9339    
9340                    q.setFirstResult(0);
9341                    q.setMaxResults(2);
9342    
9343                    QueryPos qPos = QueryPos.getInstance(q);
9344    
9345                    qPos.add(groupId);
9346    
9347                    qPos.add(folderId);
9348    
9349                    qPos.add(fileEntryTypeId);
9350    
9351                    if (orderByComparator != null) {
9352                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
9353    
9354                            for (Object value : values) {
9355                                    qPos.add(value);
9356                            }
9357                    }
9358    
9359                    List<DLFileEntry> list = q.list();
9360    
9361                    if (list.size() == 2) {
9362                            return list.get(1);
9363                    }
9364                    else {
9365                            return null;
9366                    }
9367            }
9368    
9369            /**
9370             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
9371             *
9372             * @param groupId the group ID
9373             * @param folderId the folder ID
9374             * @param fileEntryTypeId the file entry type ID
9375             * @return the matching document library file entries that the user has permission to view
9376             * @throws SystemException if a system exception occurred
9377             */
9378            @Override
9379            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
9380                    long fileEntryTypeId) throws SystemException {
9381                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId,
9382                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9383            }
9384    
9385            /**
9386             * 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;.
9387             *
9388             * <p>
9389             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9390             * </p>
9391             *
9392             * @param groupId the group ID
9393             * @param folderId the folder ID
9394             * @param fileEntryTypeId the file entry type ID
9395             * @param start the lower bound of the range of document library file entries
9396             * @param end the upper bound of the range of document library file entries (not inclusive)
9397             * @return the range of matching document library file entries that the user has permission to view
9398             * @throws SystemException if a system exception occurred
9399             */
9400            @Override
9401            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
9402                    long fileEntryTypeId, int start, int end) throws SystemException {
9403                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId, start,
9404                            end, null);
9405            }
9406    
9407            /**
9408             * 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;.
9409             *
9410             * <p>
9411             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9412             * </p>
9413             *
9414             * @param groupId the group ID
9415             * @param folderId the folder ID
9416             * @param fileEntryTypeId the file entry type ID
9417             * @param start the lower bound of the range of document library file entries
9418             * @param end the upper bound of the range of document library file entries (not inclusive)
9419             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9420             * @return the ordered range of matching document library file entries that the user has permission to view
9421             * @throws SystemException if a system exception occurred
9422             */
9423            @Override
9424            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
9425                    long fileEntryTypeId, int start, int end,
9426                    OrderByComparator orderByComparator) throws SystemException {
9427                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9428                            return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end,
9429                                    orderByComparator);
9430                    }
9431    
9432                    StringBundler query = null;
9433    
9434                    if (orderByComparator != null) {
9435                            query = new StringBundler(5 +
9436                                            (orderByComparator.getOrderByFields().length * 3));
9437                    }
9438                    else {
9439                            query = new StringBundler(5);
9440                    }
9441    
9442                    if (getDB().isSupportsInlineDistinct()) {
9443                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
9444                    }
9445                    else {
9446                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
9447                    }
9448    
9449                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
9450    
9451                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
9452    
9453                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
9454    
9455                    if (!getDB().isSupportsInlineDistinct()) {
9456                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
9457                    }
9458    
9459                    if (orderByComparator != null) {
9460                            if (getDB().isSupportsInlineDistinct()) {
9461                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9462                                            orderByComparator, true);
9463                            }
9464                            else {
9465                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9466                                            orderByComparator, true);
9467                            }
9468                    }
9469                    else {
9470                            if (getDB().isSupportsInlineDistinct()) {
9471                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
9472                            }
9473                            else {
9474                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
9475                            }
9476                    }
9477    
9478                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9479                                    DLFileEntry.class.getName(),
9480                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9481    
9482                    Session session = null;
9483    
9484                    try {
9485                            session = openSession();
9486    
9487                            SQLQuery q = session.createSQLQuery(sql);
9488    
9489                            if (getDB().isSupportsInlineDistinct()) {
9490                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
9491                            }
9492                            else {
9493                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
9494                            }
9495    
9496                            QueryPos qPos = QueryPos.getInstance(q);
9497    
9498                            qPos.add(groupId);
9499    
9500                            qPos.add(folderId);
9501    
9502                            qPos.add(fileEntryTypeId);
9503    
9504                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
9505                    }
9506                    catch (Exception e) {
9507                            throw processException(e);
9508                    }
9509                    finally {
9510                            closeSession(session);
9511                    }
9512            }
9513    
9514            /**
9515             * 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;.
9516             *
9517             * @param fileEntryId the primary key of the current document library file entry
9518             * @param groupId the group ID
9519             * @param folderId the folder ID
9520             * @param fileEntryTypeId the file entry type ID
9521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9522             * @return the previous, current, and next document library file entry
9523             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
9524             * @throws SystemException if a system exception occurred
9525             */
9526            @Override
9527            public DLFileEntry[] filterFindByG_F_F_PrevAndNext(long fileEntryId,
9528                    long groupId, long folderId, long fileEntryTypeId,
9529                    OrderByComparator orderByComparator)
9530                    throws NoSuchFileEntryException, SystemException {
9531                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9532                            return findByG_F_F_PrevAndNext(fileEntryId, groupId, folderId,
9533                                    fileEntryTypeId, orderByComparator);
9534                    }
9535    
9536                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
9537    
9538                    Session session = null;
9539    
9540                    try {
9541                            session = openSession();
9542    
9543                            DLFileEntry[] array = new DLFileEntryImpl[3];
9544    
9545                            array[0] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
9546                                            groupId, folderId, fileEntryTypeId, orderByComparator, true);
9547    
9548                            array[1] = dlFileEntry;
9549    
9550                            array[2] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
9551                                            groupId, folderId, fileEntryTypeId, orderByComparator, false);
9552    
9553                            return array;
9554                    }
9555                    catch (Exception e) {
9556                            throw processException(e);
9557                    }
9558                    finally {
9559                            closeSession(session);
9560                    }
9561            }
9562    
9563            protected DLFileEntry filterGetByG_F_F_PrevAndNext(Session session,
9564                    DLFileEntry dlFileEntry, long groupId, long folderId,
9565                    long fileEntryTypeId, OrderByComparator orderByComparator,
9566                    boolean previous) {
9567                    StringBundler query = null;
9568    
9569                    if (orderByComparator != null) {
9570                            query = new StringBundler(6 +
9571                                            (orderByComparator.getOrderByFields().length * 6));
9572                    }
9573                    else {
9574                            query = new StringBundler(3);
9575                    }
9576    
9577                    if (getDB().isSupportsInlineDistinct()) {
9578                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
9579                    }
9580                    else {
9581                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
9582                    }
9583    
9584                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
9585    
9586                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
9587    
9588                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
9589    
9590                    if (!getDB().isSupportsInlineDistinct()) {
9591                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
9592                    }
9593    
9594                    if (orderByComparator != null) {
9595                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9596    
9597                            if (orderByConditionFields.length > 0) {
9598                                    query.append(WHERE_AND);
9599                            }
9600    
9601                            for (int i = 0; i < orderByConditionFields.length; i++) {
9602                                    if (getDB().isSupportsInlineDistinct()) {
9603                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9604                                    }
9605                                    else {
9606                                            query.append(_ORDER_BY_ENTITY_TABLE);
9607                                    }
9608    
9609                                    query.append(orderByConditionFields[i]);
9610    
9611                                    if ((i + 1) < orderByConditionFields.length) {
9612                                            if (orderByComparator.isAscending() ^ previous) {
9613                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9614                                            }
9615                                            else {
9616                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9617                                            }
9618                                    }
9619                                    else {
9620                                            if (orderByComparator.isAscending() ^ previous) {
9621                                                    query.append(WHERE_GREATER_THAN);
9622                                            }
9623                                            else {
9624                                                    query.append(WHERE_LESSER_THAN);
9625                                            }
9626                                    }
9627                            }
9628    
9629                            query.append(ORDER_BY_CLAUSE);
9630    
9631                            String[] orderByFields = orderByComparator.getOrderByFields();
9632    
9633                            for (int i = 0; i < orderByFields.length; i++) {
9634                                    if (getDB().isSupportsInlineDistinct()) {
9635                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9636                                    }
9637                                    else {
9638                                            query.append(_ORDER_BY_ENTITY_TABLE);
9639                                    }
9640    
9641                                    query.append(orderByFields[i]);
9642    
9643                                    if ((i + 1) < orderByFields.length) {
9644                                            if (orderByComparator.isAscending() ^ previous) {
9645                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9646                                            }
9647                                            else {
9648                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9649                                            }
9650                                    }
9651                                    else {
9652                                            if (orderByComparator.isAscending() ^ previous) {
9653                                                    query.append(ORDER_BY_ASC);
9654                                            }
9655                                            else {
9656                                                    query.append(ORDER_BY_DESC);
9657                                            }
9658                                    }
9659                            }
9660                    }
9661                    else {
9662                            if (getDB().isSupportsInlineDistinct()) {
9663                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
9664                            }
9665                            else {
9666                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
9667                            }
9668                    }
9669    
9670                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9671                                    DLFileEntry.class.getName(),
9672                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9673    
9674                    SQLQuery q = session.createSQLQuery(sql);
9675    
9676                    q.setFirstResult(0);
9677                    q.setMaxResults(2);
9678    
9679                    if (getDB().isSupportsInlineDistinct()) {
9680                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
9681                    }
9682                    else {
9683                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
9684                    }
9685    
9686                    QueryPos qPos = QueryPos.getInstance(q);
9687    
9688                    qPos.add(groupId);
9689    
9690                    qPos.add(folderId);
9691    
9692                    qPos.add(fileEntryTypeId);
9693    
9694                    if (orderByComparator != null) {
9695                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
9696    
9697                            for (Object value : values) {
9698                                    qPos.add(value);
9699                            }
9700                    }
9701    
9702                    List<DLFileEntry> list = q.list();
9703    
9704                    if (list.size() == 2) {
9705                            return list.get(1);
9706                    }
9707                    else {
9708                            return null;
9709                    }
9710            }
9711    
9712            /**
9713             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
9714             *
9715             * @param groupId the group ID
9716             * @param folderIds the folder IDs
9717             * @param fileEntryTypeId the file entry type ID
9718             * @return the matching document library file entries that the user has permission to view
9719             * @throws SystemException if a system exception occurred
9720             */
9721            @Override
9722            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
9723                    long fileEntryTypeId) throws SystemException {
9724                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId,
9725                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9726            }
9727    
9728            /**
9729             * 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;.
9730             *
9731             * <p>
9732             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9733             * </p>
9734             *
9735             * @param groupId the group ID
9736             * @param folderIds the folder IDs
9737             * @param fileEntryTypeId the file entry type ID
9738             * @param start the lower bound of the range of document library file entries
9739             * @param end the upper bound of the range of document library file entries (not inclusive)
9740             * @return the range of matching document library file entries that the user has permission to view
9741             * @throws SystemException if a system exception occurred
9742             */
9743            @Override
9744            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
9745                    long fileEntryTypeId, int start, int end) throws SystemException {
9746                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId, start,
9747                            end, null);
9748            }
9749    
9750            /**
9751             * 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;.
9752             *
9753             * <p>
9754             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9755             * </p>
9756             *
9757             * @param groupId the group ID
9758             * @param folderIds the folder IDs
9759             * @param fileEntryTypeId the file entry type ID
9760             * @param start the lower bound of the range of document library file entries
9761             * @param end the upper bound of the range of document library file entries (not inclusive)
9762             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9763             * @return the ordered range of matching document library file entries that the user has permission to view
9764             * @throws SystemException if a system exception occurred
9765             */
9766            @Override
9767            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
9768                    long fileEntryTypeId, int start, int end,
9769                    OrderByComparator orderByComparator) throws SystemException {
9770                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9771                            return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end,
9772                                    orderByComparator);
9773                    }
9774    
9775                    StringBundler query = new StringBundler();
9776    
9777                    if (getDB().isSupportsInlineDistinct()) {
9778                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
9779                    }
9780                    else {
9781                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
9782                    }
9783    
9784                    boolean conjunctionable = false;
9785    
9786                    if (conjunctionable) {
9787                            query.append(WHERE_AND);
9788                    }
9789    
9790                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
9791    
9792                    conjunctionable = true;
9793    
9794                    if ((folderIds == null) || (folderIds.length > 0)) {
9795                            if (conjunctionable) {
9796                                    query.append(WHERE_AND);
9797                            }
9798    
9799                            query.append(StringPool.OPEN_PARENTHESIS);
9800    
9801                            for (int i = 0; i < folderIds.length; i++) {
9802                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
9803    
9804                                    if ((i + 1) < folderIds.length) {
9805                                            query.append(WHERE_OR);
9806                                    }
9807                            }
9808    
9809                            query.append(StringPool.CLOSE_PARENTHESIS);
9810    
9811                            conjunctionable = true;
9812                    }
9813    
9814                    if (conjunctionable) {
9815                            query.append(WHERE_AND);
9816                    }
9817    
9818                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
9819    
9820                    conjunctionable = true;
9821    
9822                    if (!getDB().isSupportsInlineDistinct()) {
9823                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
9824                    }
9825    
9826                    if (orderByComparator != null) {
9827                            if (getDB().isSupportsInlineDistinct()) {
9828                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9829                                            orderByComparator, true);
9830                            }
9831                            else {
9832                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9833                                            orderByComparator, true);
9834                            }
9835                    }
9836                    else {
9837                            if (getDB().isSupportsInlineDistinct()) {
9838                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
9839                            }
9840                            else {
9841                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
9842                            }
9843                    }
9844    
9845                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9846                                    DLFileEntry.class.getName(),
9847                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9848    
9849                    Session session = null;
9850    
9851                    try {
9852                            session = openSession();
9853    
9854                            SQLQuery q = session.createSQLQuery(sql);
9855    
9856                            if (getDB().isSupportsInlineDistinct()) {
9857                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
9858                            }
9859                            else {
9860                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
9861                            }
9862    
9863                            QueryPos qPos = QueryPos.getInstance(q);
9864    
9865                            qPos.add(groupId);
9866    
9867                            if (folderIds != null) {
9868                                    qPos.add(folderIds);
9869                            }
9870    
9871                            qPos.add(fileEntryTypeId);
9872    
9873                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
9874                    }
9875                    catch (Exception e) {
9876                            throw processException(e);
9877                    }
9878                    finally {
9879                            closeSession(session);
9880                    }
9881            }
9882    
9883            /**
9884             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
9885             *
9886             * <p>
9887             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9888             * </p>
9889             *
9890             * @param groupId the group ID
9891             * @param folderIds the folder IDs
9892             * @param fileEntryTypeId the file entry type ID
9893             * @return the matching document library file entries
9894             * @throws SystemException if a system exception occurred
9895             */
9896            @Override
9897            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
9898                    long fileEntryTypeId) throws SystemException {
9899                    return findByG_F_F(groupId, folderIds, fileEntryTypeId,
9900                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9901            }
9902    
9903            /**
9904             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
9905             *
9906             * <p>
9907             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9908             * </p>
9909             *
9910             * @param groupId the group ID
9911             * @param folderIds the folder IDs
9912             * @param fileEntryTypeId the file entry type ID
9913             * @param start the lower bound of the range of document library file entries
9914             * @param end the upper bound of the range of document library file entries (not inclusive)
9915             * @return the range of matching document library file entries
9916             * @throws SystemException if a system exception occurred
9917             */
9918            @Override
9919            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
9920                    long fileEntryTypeId, int start, int end) throws SystemException {
9921                    return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end, null);
9922            }
9923    
9924            /**
9925             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
9926             *
9927             * <p>
9928             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9929             * </p>
9930             *
9931             * @param groupId the group ID
9932             * @param folderIds the folder IDs
9933             * @param fileEntryTypeId the file entry type ID
9934             * @param start the lower bound of the range of document library file entries
9935             * @param end the upper bound of the range of document library file entries (not inclusive)
9936             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9937             * @return the ordered range of matching document library file entries
9938             * @throws SystemException if a system exception occurred
9939             */
9940            @Override
9941            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
9942                    long fileEntryTypeId, int start, int end,
9943                    OrderByComparator orderByComparator) throws SystemException {
9944                    if ((folderIds != null) && (folderIds.length == 1)) {
9945                            return findByG_F_F(groupId, folderIds[0], fileEntryTypeId, start,
9946                                    end, orderByComparator);
9947                    }
9948    
9949                    boolean pagination = true;
9950                    Object[] finderArgs = null;
9951    
9952                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9953                                    (orderByComparator == null)) {
9954                            pagination = false;
9955                            finderArgs = new Object[] {
9956                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId
9957                                    };
9958                    }
9959                    else {
9960                            finderArgs = new Object[] {
9961                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId,
9962                                            
9963                                            start, end, orderByComparator
9964                                    };
9965                    }
9966    
9967                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
9968                                    finderArgs, this);
9969    
9970                    if ((list != null) && !list.isEmpty()) {
9971                            for (DLFileEntry dlFileEntry : list) {
9972                                    if ((groupId != dlFileEntry.getGroupId()) ||
9973                                                    !ArrayUtil.contains(folderIds, dlFileEntry.getFolderId()) ||
9974                                                    (fileEntryTypeId != dlFileEntry.getFileEntryTypeId())) {
9975                                            list = null;
9976    
9977                                            break;
9978                                    }
9979                            }
9980                    }
9981    
9982                    if (list == null) {
9983                            StringBundler query = new StringBundler();
9984    
9985                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9986    
9987                            boolean conjunctionable = false;
9988    
9989                            if (conjunctionable) {
9990                                    query.append(WHERE_AND);
9991                            }
9992    
9993                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
9994    
9995                            conjunctionable = true;
9996    
9997                            if ((folderIds == null) || (folderIds.length > 0)) {
9998                                    if (conjunctionable) {
9999                                            query.append(WHERE_AND);
10000                                    }
10001    
10002                                    query.append(StringPool.OPEN_PARENTHESIS);
10003    
10004                                    for (int i = 0; i < folderIds.length; i++) {
10005                                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
10006    
10007                                            if ((i + 1) < folderIds.length) {
10008                                                    query.append(WHERE_OR);
10009                                            }
10010                                    }
10011    
10012                                    query.append(StringPool.CLOSE_PARENTHESIS);
10013    
10014                                    conjunctionable = true;
10015                            }
10016    
10017                            if (conjunctionable) {
10018                                    query.append(WHERE_AND);
10019                            }
10020    
10021                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
10022    
10023                            conjunctionable = true;
10024    
10025                            if (orderByComparator != null) {
10026                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10027                                            orderByComparator);
10028                            }
10029                            else
10030                             if (pagination) {
10031                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10032                            }
10033    
10034                            String sql = query.toString();
10035    
10036                            Session session = null;
10037    
10038                            try {
10039                                    session = openSession();
10040    
10041                                    Query q = session.createQuery(sql);
10042    
10043                                    QueryPos qPos = QueryPos.getInstance(q);
10044    
10045                                    qPos.add(groupId);
10046    
10047                                    if (folderIds != null) {
10048                                            qPos.add(folderIds);
10049                                    }
10050    
10051                                    qPos.add(fileEntryTypeId);
10052    
10053                                    if (!pagination) {
10054                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
10055                                                            start, end, false);
10056    
10057                                            Collections.sort(list);
10058    
10059                                            list = new UnmodifiableList<DLFileEntry>(list);
10060                                    }
10061                                    else {
10062                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
10063                                                            start, end);
10064                                    }
10065    
10066                                    cacheResult(list);
10067    
10068                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
10069                                            finderArgs, list);
10070                            }
10071                            catch (Exception e) {
10072                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
10073                                            finderArgs);
10074    
10075                                    throw processException(e);
10076                            }
10077                            finally {
10078                                    closeSession(session);
10079                            }
10080                    }
10081    
10082                    return list;
10083            }
10084    
10085            /**
10086             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63; from the database.
10087             *
10088             * @param groupId the group ID
10089             * @param folderId the folder ID
10090             * @param fileEntryTypeId the file entry type ID
10091             * @throws SystemException if a system exception occurred
10092             */
10093            @Override
10094            public void removeByG_F_F(long groupId, long folderId, long fileEntryTypeId)
10095                    throws SystemException {
10096                    for (DLFileEntry dlFileEntry : findByG_F_F(groupId, folderId,
10097                                    fileEntryTypeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10098                            remove(dlFileEntry);
10099                    }
10100            }
10101    
10102            /**
10103             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10104             *
10105             * @param groupId the group ID
10106             * @param folderId the folder ID
10107             * @param fileEntryTypeId the file entry type ID
10108             * @return the number of matching document library file entries
10109             * @throws SystemException if a system exception occurred
10110             */
10111            @Override
10112            public int countByG_F_F(long groupId, long folderId, long fileEntryTypeId)
10113                    throws SystemException {
10114                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_F;
10115    
10116                    Object[] finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
10117    
10118                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10119                                    this);
10120    
10121                    if (count == null) {
10122                            StringBundler query = new StringBundler(4);
10123    
10124                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
10125    
10126                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10127    
10128                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10129    
10130                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10131    
10132                            String sql = query.toString();
10133    
10134                            Session session = null;
10135    
10136                            try {
10137                                    session = openSession();
10138    
10139                                    Query q = session.createQuery(sql);
10140    
10141                                    QueryPos qPos = QueryPos.getInstance(q);
10142    
10143                                    qPos.add(groupId);
10144    
10145                                    qPos.add(folderId);
10146    
10147                                    qPos.add(fileEntryTypeId);
10148    
10149                                    count = (Long)q.uniqueResult();
10150    
10151                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10152                            }
10153                            catch (Exception e) {
10154                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10155    
10156                                    throw processException(e);
10157                            }
10158                            finally {
10159                                    closeSession(session);
10160                            }
10161                    }
10162    
10163                    return count.intValue();
10164            }
10165    
10166            /**
10167             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
10168             *
10169             * @param groupId the group ID
10170             * @param folderIds the folder IDs
10171             * @param fileEntryTypeId the file entry type ID
10172             * @return the number of matching document library file entries
10173             * @throws SystemException if a system exception occurred
10174             */
10175            @Override
10176            public int countByG_F_F(long groupId, long[] folderIds, long fileEntryTypeId)
10177                    throws SystemException {
10178                    Object[] finderArgs = new Object[] {
10179                                    groupId, StringUtil.merge(folderIds), fileEntryTypeId
10180                            };
10181    
10182                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
10183                                    finderArgs, this);
10184    
10185                    if (count == null) {
10186                            StringBundler query = new StringBundler();
10187    
10188                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
10189    
10190                            boolean conjunctionable = false;
10191    
10192                            if (conjunctionable) {
10193                                    query.append(WHERE_AND);
10194                            }
10195    
10196                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
10197    
10198                            conjunctionable = true;
10199    
10200                            if ((folderIds == null) || (folderIds.length > 0)) {
10201                                    if (conjunctionable) {
10202                                            query.append(WHERE_AND);
10203                                    }
10204    
10205                                    query.append(StringPool.OPEN_PARENTHESIS);
10206    
10207                                    for (int i = 0; i < folderIds.length; i++) {
10208                                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
10209    
10210                                            if ((i + 1) < folderIds.length) {
10211                                                    query.append(WHERE_OR);
10212                                            }
10213                                    }
10214    
10215                                    query.append(StringPool.CLOSE_PARENTHESIS);
10216    
10217                                    conjunctionable = true;
10218                            }
10219    
10220                            if (conjunctionable) {
10221                                    query.append(WHERE_AND);
10222                            }
10223    
10224                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
10225    
10226                            conjunctionable = true;
10227    
10228                            String sql = query.toString();
10229    
10230                            Session session = null;
10231    
10232                            try {
10233                                    session = openSession();
10234    
10235                                    Query q = session.createQuery(sql);
10236    
10237                                    QueryPos qPos = QueryPos.getInstance(q);
10238    
10239                                    qPos.add(groupId);
10240    
10241                                    if (folderIds != null) {
10242                                            qPos.add(folderIds);
10243                                    }
10244    
10245                                    qPos.add(fileEntryTypeId);
10246    
10247                                    count = (Long)q.uniqueResult();
10248    
10249                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
10250                                            finderArgs, count);
10251                            }
10252                            catch (Exception e) {
10253                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
10254                                            finderArgs);
10255    
10256                                    throw processException(e);
10257                            }
10258                            finally {
10259                                    closeSession(session);
10260                            }
10261                    }
10262    
10263                    return count.intValue();
10264            }
10265    
10266            /**
10267             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10268             *
10269             * @param groupId the group ID
10270             * @param folderId the folder ID
10271             * @param fileEntryTypeId the file entry type ID
10272             * @return the number of matching document library file entries that the user has permission to view
10273             * @throws SystemException if a system exception occurred
10274             */
10275            @Override
10276            public int filterCountByG_F_F(long groupId, long folderId,
10277                    long fileEntryTypeId) throws SystemException {
10278                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10279                            return countByG_F_F(groupId, folderId, fileEntryTypeId);
10280                    }
10281    
10282                    StringBundler query = new StringBundler(4);
10283    
10284                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
10285    
10286                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10287    
10288                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10289    
10290                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10291    
10292                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10293                                    DLFileEntry.class.getName(),
10294                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10295    
10296                    Session session = null;
10297    
10298                    try {
10299                            session = openSession();
10300    
10301                            SQLQuery q = session.createSQLQuery(sql);
10302    
10303                            q.addScalar(COUNT_COLUMN_NAME,
10304                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10305    
10306                            QueryPos qPos = QueryPos.getInstance(q);
10307    
10308                            qPos.add(groupId);
10309    
10310                            qPos.add(folderId);
10311    
10312                            qPos.add(fileEntryTypeId);
10313    
10314                            Long count = (Long)q.uniqueResult();
10315    
10316                            return count.intValue();
10317                    }
10318                    catch (Exception e) {
10319                            throw processException(e);
10320                    }
10321                    finally {
10322                            closeSession(session);
10323                    }
10324            }
10325    
10326            /**
10327             * 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;.
10328             *
10329             * @param groupId the group ID
10330             * @param folderIds the folder IDs
10331             * @param fileEntryTypeId the file entry type ID
10332             * @return the number of matching document library file entries that the user has permission to view
10333             * @throws SystemException if a system exception occurred
10334             */
10335            @Override
10336            public int filterCountByG_F_F(long groupId, long[] folderIds,
10337                    long fileEntryTypeId) throws SystemException {
10338                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10339                            return countByG_F_F(groupId, folderIds, fileEntryTypeId);
10340                    }
10341    
10342                    StringBundler query = new StringBundler();
10343    
10344                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
10345    
10346                    boolean conjunctionable = false;
10347    
10348                    if (conjunctionable) {
10349                            query.append(WHERE_AND);
10350                    }
10351    
10352                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
10353    
10354                    conjunctionable = true;
10355    
10356                    if ((folderIds == null) || (folderIds.length > 0)) {
10357                            if (conjunctionable) {
10358                                    query.append(WHERE_AND);
10359                            }
10360    
10361                            query.append(StringPool.OPEN_PARENTHESIS);
10362    
10363                            for (int i = 0; i < folderIds.length; i++) {
10364                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
10365    
10366                                    if ((i + 1) < folderIds.length) {
10367                                            query.append(WHERE_OR);
10368                                    }
10369                            }
10370    
10371                            query.append(StringPool.CLOSE_PARENTHESIS);
10372    
10373                            conjunctionable = true;
10374                    }
10375    
10376                    if (conjunctionable) {
10377                            query.append(WHERE_AND);
10378                    }
10379    
10380                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
10381    
10382                    conjunctionable = true;
10383    
10384                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10385                                    DLFileEntry.class.getName(),
10386                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10387    
10388                    Session session = null;
10389    
10390                    try {
10391                            session = openSession();
10392    
10393                            SQLQuery q = session.createSQLQuery(sql);
10394    
10395                            q.addScalar(COUNT_COLUMN_NAME,
10396                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10397    
10398                            QueryPos qPos = QueryPos.getInstance(q);
10399    
10400                            qPos.add(groupId);
10401    
10402                            if (folderIds != null) {
10403                                    qPos.add(folderIds);
10404                            }
10405    
10406                            qPos.add(fileEntryTypeId);
10407    
10408                            Long count = (Long)q.uniqueResult();
10409    
10410                            return count.intValue();
10411                    }
10412                    catch (Exception e) {
10413                            throw processException(e);
10414                    }
10415                    finally {
10416                            closeSession(session);
10417                    }
10418            }
10419    
10420            private static final String _FINDER_COLUMN_G_F_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
10421            private static final String _FINDER_COLUMN_G_F_F_GROUPID_5 = "(" +
10422                    removeConjunction(_FINDER_COLUMN_G_F_F_GROUPID_2) + ")";
10423            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
10424            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_5 = "(" +
10425                    removeConjunction(_FINDER_COLUMN_G_F_F_FOLDERID_2) + ")";
10426            private static final String _FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2 = "dlFileEntry.fileEntryTypeId = ?";
10427            private static final String _FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5 = "(" +
10428                    removeConjunction(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2) + ")";
10429    
10430            public DLFileEntryPersistenceImpl() {
10431                    setModelClass(DLFileEntry.class);
10432            }
10433    
10434            /**
10435             * Caches the document library file entry in the entity cache if it is enabled.
10436             *
10437             * @param dlFileEntry the document library file entry
10438             */
10439            @Override
10440            public void cacheResult(DLFileEntry dlFileEntry) {
10441                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
10442                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
10443    
10444                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
10445                            new Object[] { dlFileEntry.getUuid(), dlFileEntry.getGroupId() },
10446                            dlFileEntry);
10447    
10448                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
10449                            new Object[] {
10450                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
10451                                    dlFileEntry.getName()
10452                            }, dlFileEntry);
10453    
10454                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
10455                            new Object[] {
10456                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
10457                                    dlFileEntry.getTitle()
10458                            }, dlFileEntry);
10459    
10460                    dlFileEntry.resetOriginalValues();
10461            }
10462    
10463            /**
10464             * Caches the document library file entries in the entity cache if it is enabled.
10465             *
10466             * @param dlFileEntries the document library file entries
10467             */
10468            @Override
10469            public void cacheResult(List<DLFileEntry> dlFileEntries) {
10470                    for (DLFileEntry dlFileEntry : dlFileEntries) {
10471                            if (EntityCacheUtil.getResult(
10472                                                    DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
10473                                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey()) == null) {
10474                                    cacheResult(dlFileEntry);
10475                            }
10476                            else {
10477                                    dlFileEntry.resetOriginalValues();
10478                            }
10479                    }
10480            }
10481    
10482            /**
10483             * Clears the cache for all document library file entries.
10484             *
10485             * <p>
10486             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
10487             * </p>
10488             */
10489            @Override
10490            public void clearCache() {
10491                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
10492                            CacheRegistryUtil.clear(DLFileEntryImpl.class.getName());
10493                    }
10494    
10495                    EntityCacheUtil.clearCache(DLFileEntryImpl.class.getName());
10496    
10497                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
10498                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10499                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10500            }
10501    
10502            /**
10503             * Clears the cache for the document library file entry.
10504             *
10505             * <p>
10506             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
10507             * </p>
10508             */
10509            @Override
10510            public void clearCache(DLFileEntry dlFileEntry) {
10511                    EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
10512                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
10513    
10514                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10515                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10516    
10517                    clearUniqueFindersCache(dlFileEntry);
10518            }
10519    
10520            @Override
10521            public void clearCache(List<DLFileEntry> dlFileEntries) {
10522                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10523                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10524    
10525                    for (DLFileEntry dlFileEntry : dlFileEntries) {
10526                            EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
10527                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
10528    
10529                            clearUniqueFindersCache(dlFileEntry);
10530                    }
10531            }
10532    
10533            protected void cacheUniqueFindersCache(DLFileEntry dlFileEntry) {
10534                    if (dlFileEntry.isNew()) {
10535                            Object[] args = new Object[] {
10536                                            dlFileEntry.getUuid(), dlFileEntry.getGroupId()
10537                                    };
10538    
10539                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10540                                    Long.valueOf(1));
10541                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10542                                    dlFileEntry);
10543    
10544                            args = new Object[] {
10545                                            dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
10546                                            dlFileEntry.getName()
10547                                    };
10548    
10549                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N, args,
10550                                    Long.valueOf(1));
10551                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N, args,
10552                                    dlFileEntry);
10553    
10554                            args = new Object[] {
10555                                            dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
10556                                            dlFileEntry.getTitle()
10557                                    };
10558    
10559                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_T, args,
10560                                    Long.valueOf(1));
10561                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T, args,
10562                                    dlFileEntry);
10563                    }
10564                    else {
10565                            DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
10566    
10567                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10568                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10569                                    Object[] args = new Object[] {
10570                                                    dlFileEntry.getUuid(), dlFileEntry.getGroupId()
10571                                            };
10572    
10573                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10574                                            Long.valueOf(1));
10575                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10576                                            dlFileEntry);
10577                            }
10578    
10579                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10580                                            FINDER_PATH_FETCH_BY_G_F_N.getColumnBitmask()) != 0) {
10581                                    Object[] args = new Object[] {
10582                                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
10583                                                    dlFileEntry.getName()
10584                                            };
10585    
10586                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N, args,
10587                                            Long.valueOf(1));
10588                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N, args,
10589                                            dlFileEntry);
10590                            }
10591    
10592                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10593                                            FINDER_PATH_FETCH_BY_G_F_T.getColumnBitmask()) != 0) {
10594                                    Object[] args = new Object[] {
10595                                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
10596                                                    dlFileEntry.getTitle()
10597                                            };
10598    
10599                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_T, args,
10600                                            Long.valueOf(1));
10601                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T, args,
10602                                            dlFileEntry);
10603                            }
10604                    }
10605            }
10606    
10607            protected void clearUniqueFindersCache(DLFileEntry dlFileEntry) {
10608                    DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
10609    
10610                    Object[] args = new Object[] {
10611                                    dlFileEntry.getUuid(), dlFileEntry.getGroupId()
10612                            };
10613    
10614                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10615                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10616    
10617                    if ((dlFileEntryModelImpl.getColumnBitmask() &
10618                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10619                            args = new Object[] {
10620                                            dlFileEntryModelImpl.getOriginalUuid(),
10621                                            dlFileEntryModelImpl.getOriginalGroupId()
10622                                    };
10623    
10624                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10625                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10626                    }
10627    
10628                    args = new Object[] {
10629                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
10630                                    dlFileEntry.getName()
10631                            };
10632    
10633                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_N, args);
10634                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N, args);
10635    
10636                    if ((dlFileEntryModelImpl.getColumnBitmask() &
10637                                    FINDER_PATH_FETCH_BY_G_F_N.getColumnBitmask()) != 0) {
10638                            args = new Object[] {
10639                                            dlFileEntryModelImpl.getOriginalGroupId(),
10640                                            dlFileEntryModelImpl.getOriginalFolderId(),
10641                                            dlFileEntryModelImpl.getOriginalName()
10642                                    };
10643    
10644                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_N, args);
10645                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N, args);
10646                    }
10647    
10648                    args = new Object[] {
10649                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
10650                                    dlFileEntry.getTitle()
10651                            };
10652    
10653                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_T, args);
10654                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T, args);
10655    
10656                    if ((dlFileEntryModelImpl.getColumnBitmask() &
10657                                    FINDER_PATH_FETCH_BY_G_F_T.getColumnBitmask()) != 0) {
10658                            args = new Object[] {
10659                                            dlFileEntryModelImpl.getOriginalGroupId(),
10660                                            dlFileEntryModelImpl.getOriginalFolderId(),
10661                                            dlFileEntryModelImpl.getOriginalTitle()
10662                                    };
10663    
10664                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_T, args);
10665                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T, args);
10666                    }
10667            }
10668    
10669            /**
10670             * Creates a new document library file entry with the primary key. Does not add the document library file entry to the database.
10671             *
10672             * @param fileEntryId the primary key for the new document library file entry
10673             * @return the new document library file entry
10674             */
10675            @Override
10676            public DLFileEntry create(long fileEntryId) {
10677                    DLFileEntry dlFileEntry = new DLFileEntryImpl();
10678    
10679                    dlFileEntry.setNew(true);
10680                    dlFileEntry.setPrimaryKey(fileEntryId);
10681    
10682                    String uuid = PortalUUIDUtil.generate();
10683    
10684                    dlFileEntry.setUuid(uuid);
10685    
10686                    return dlFileEntry;
10687            }
10688    
10689            /**
10690             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
10691             *
10692             * @param fileEntryId the primary key of the document library file entry
10693             * @return the document library file entry that was removed
10694             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
10695             * @throws SystemException if a system exception occurred
10696             */
10697            @Override
10698            public DLFileEntry remove(long fileEntryId)
10699                    throws NoSuchFileEntryException, SystemException {
10700                    return remove((Serializable)fileEntryId);
10701            }
10702    
10703            /**
10704             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
10705             *
10706             * @param primaryKey the primary key of the document library file entry
10707             * @return the document library file entry that was removed
10708             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
10709             * @throws SystemException if a system exception occurred
10710             */
10711            @Override
10712            public DLFileEntry remove(Serializable primaryKey)
10713                    throws NoSuchFileEntryException, SystemException {
10714                    Session session = null;
10715    
10716                    try {
10717                            session = openSession();
10718    
10719                            DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
10720                                            primaryKey);
10721    
10722                            if (dlFileEntry == null) {
10723                                    if (_log.isWarnEnabled()) {
10724                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10725                                    }
10726    
10727                                    throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10728                                            primaryKey);
10729                            }
10730    
10731                            return remove(dlFileEntry);
10732                    }
10733                    catch (NoSuchFileEntryException nsee) {
10734                            throw nsee;
10735                    }
10736                    catch (Exception e) {
10737                            throw processException(e);
10738                    }
10739                    finally {
10740                            closeSession(session);
10741                    }
10742            }
10743    
10744            @Override
10745            protected DLFileEntry removeImpl(DLFileEntry dlFileEntry)
10746                    throws SystemException {
10747                    dlFileEntry = toUnwrappedModel(dlFileEntry);
10748    
10749                    Session session = null;
10750    
10751                    try {
10752                            session = openSession();
10753    
10754                            if (!session.contains(dlFileEntry)) {
10755                                    dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
10756                                                    dlFileEntry.getPrimaryKeyObj());
10757                            }
10758    
10759                            if (dlFileEntry != null) {
10760                                    session.delete(dlFileEntry);
10761                            }
10762                    }
10763                    catch (Exception e) {
10764                            throw processException(e);
10765                    }
10766                    finally {
10767                            closeSession(session);
10768                    }
10769    
10770                    if (dlFileEntry != null) {
10771                            clearCache(dlFileEntry);
10772                    }
10773    
10774                    return dlFileEntry;
10775            }
10776    
10777            @Override
10778            public DLFileEntry updateImpl(
10779                    com.liferay.portlet.documentlibrary.model.DLFileEntry dlFileEntry)
10780                    throws SystemException {
10781                    dlFileEntry = toUnwrappedModel(dlFileEntry);
10782    
10783                    boolean isNew = dlFileEntry.isNew();
10784    
10785                    DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
10786    
10787                    if (Validator.isNull(dlFileEntry.getUuid())) {
10788                            String uuid = PortalUUIDUtil.generate();
10789    
10790                            dlFileEntry.setUuid(uuid);
10791                    }
10792    
10793                    Session session = null;
10794    
10795                    try {
10796                            session = openSession();
10797    
10798                            if (dlFileEntry.isNew()) {
10799                                    session.save(dlFileEntry);
10800    
10801                                    dlFileEntry.setNew(false);
10802                            }
10803                            else {
10804                                    session.merge(dlFileEntry);
10805                            }
10806                    }
10807                    catch (Exception e) {
10808                            throw processException(e);
10809                    }
10810                    finally {
10811                            closeSession(session);
10812                    }
10813    
10814                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10815    
10816                    if (isNew || !DLFileEntryModelImpl.COLUMN_BITMASK_ENABLED) {
10817                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10818                    }
10819    
10820                    else {
10821                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10822                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
10823                                    Object[] args = new Object[] {
10824                                                    dlFileEntryModelImpl.getOriginalUuid()
10825                                            };
10826    
10827                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10828                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10829                                            args);
10830    
10831                                    args = new Object[] { dlFileEntryModelImpl.getUuid() };
10832    
10833                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10834                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10835                                            args);
10836                            }
10837    
10838                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10839                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
10840                                    Object[] args = new Object[] {
10841                                                    dlFileEntryModelImpl.getOriginalUuid(),
10842                                                    dlFileEntryModelImpl.getOriginalCompanyId()
10843                                            };
10844    
10845                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10846                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10847                                            args);
10848    
10849                                    args = new Object[] {
10850                                                    dlFileEntryModelImpl.getUuid(),
10851                                                    dlFileEntryModelImpl.getCompanyId()
10852                                            };
10853    
10854                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10855                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10856                                            args);
10857                            }
10858    
10859                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10860                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
10861                                    Object[] args = new Object[] {
10862                                                    dlFileEntryModelImpl.getOriginalGroupId()
10863                                            };
10864    
10865                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10866                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10867                                            args);
10868    
10869                                    args = new Object[] { dlFileEntryModelImpl.getGroupId() };
10870    
10871                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10872                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10873                                            args);
10874                            }
10875    
10876                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10877                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
10878                                    Object[] args = new Object[] {
10879                                                    dlFileEntryModelImpl.getOriginalCompanyId()
10880                                            };
10881    
10882                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
10883                                            args);
10884                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
10885                                            args);
10886    
10887                                    args = new Object[] { dlFileEntryModelImpl.getCompanyId() };
10888    
10889                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
10890                                            args);
10891                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
10892                                            args);
10893                            }
10894    
10895                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10896                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE.getColumnBitmask()) != 0) {
10897                                    Object[] args = new Object[] {
10898                                                    dlFileEntryModelImpl.getOriginalMimeType()
10899                                            };
10900    
10901                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MIMETYPE, args);
10902                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE,
10903                                            args);
10904    
10905                                    args = new Object[] { dlFileEntryModelImpl.getMimeType() };
10906    
10907                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MIMETYPE, args);
10908                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE,
10909                                            args);
10910                            }
10911    
10912                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10913                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID.getColumnBitmask()) != 0) {
10914                                    Object[] args = new Object[] {
10915                                                    dlFileEntryModelImpl.getOriginalFileEntryTypeId()
10916                                            };
10917    
10918                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
10919                                            args);
10920                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
10921                                            args);
10922    
10923                                    args = new Object[] { dlFileEntryModelImpl.getFileEntryTypeId() };
10924    
10925                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
10926                                            args);
10927                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
10928                                            args);
10929                            }
10930    
10931                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10932                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N.getColumnBitmask()) != 0) {
10933                                    Object[] args = new Object[] {
10934                                                    dlFileEntryModelImpl.getOriginalFolderId(),
10935                                                    dlFileEntryModelImpl.getOriginalName()
10936                                            };
10937    
10938                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_N, args);
10939                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N,
10940                                            args);
10941    
10942                                    args = new Object[] {
10943                                                    dlFileEntryModelImpl.getFolderId(),
10944                                                    dlFileEntryModelImpl.getName()
10945                                            };
10946    
10947                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_N, args);
10948                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N,
10949                                            args);
10950                            }
10951    
10952                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10953                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
10954                                    Object[] args = new Object[] {
10955                                                    dlFileEntryModelImpl.getOriginalGroupId(),
10956                                                    dlFileEntryModelImpl.getOriginalUserId()
10957                                            };
10958    
10959                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
10960                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
10961                                            args);
10962    
10963                                    args = new Object[] {
10964                                                    dlFileEntryModelImpl.getGroupId(),
10965                                                    dlFileEntryModelImpl.getUserId()
10966                                            };
10967    
10968                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
10969                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
10970                                            args);
10971                            }
10972    
10973                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10974                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
10975                                    Object[] args = new Object[] {
10976                                                    dlFileEntryModelImpl.getOriginalGroupId(),
10977                                                    dlFileEntryModelImpl.getOriginalFolderId()
10978                                            };
10979    
10980                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
10981                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
10982                                            args);
10983    
10984                                    args = new Object[] {
10985                                                    dlFileEntryModelImpl.getGroupId(),
10986                                                    dlFileEntryModelImpl.getFolderId()
10987                                            };
10988    
10989                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
10990                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
10991                                            args);
10992                            }
10993    
10994                            if ((dlFileEntryModelImpl.getColumnBitmask() &
10995                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F.getColumnBitmask()) != 0) {
10996                                    Object[] args = new Object[] {
10997                                                    dlFileEntryModelImpl.getOriginalGroupId(),
10998                                                    dlFileEntryModelImpl.getOriginalUserId(),
10999                                                    dlFileEntryModelImpl.getOriginalFolderId()
11000                                            };
11001    
11002                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
11003                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
11004                                            args);
11005    
11006                                    args = new Object[] {
11007                                                    dlFileEntryModelImpl.getGroupId(),
11008                                                    dlFileEntryModelImpl.getUserId(),
11009                                                    dlFileEntryModelImpl.getFolderId()
11010                                            };
11011    
11012                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
11013                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
11014                                            args);
11015                            }
11016    
11017                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11018                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F.getColumnBitmask()) != 0) {
11019                                    Object[] args = new Object[] {
11020                                                    dlFileEntryModelImpl.getOriginalGroupId(),
11021                                                    dlFileEntryModelImpl.getOriginalFolderId(),
11022                                                    dlFileEntryModelImpl.getOriginalFileEntryTypeId()
11023                                            };
11024    
11025                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
11026                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
11027                                            args);
11028    
11029                                    args = new Object[] {
11030                                                    dlFileEntryModelImpl.getGroupId(),
11031                                                    dlFileEntryModelImpl.getFolderId(),
11032                                                    dlFileEntryModelImpl.getFileEntryTypeId()
11033                                            };
11034    
11035                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
11036                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
11037                                            args);
11038                            }
11039                    }
11040    
11041                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11042                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
11043    
11044                    clearUniqueFindersCache(dlFileEntry);
11045                    cacheUniqueFindersCache(dlFileEntry);
11046    
11047                    return dlFileEntry;
11048            }
11049    
11050            protected DLFileEntry toUnwrappedModel(DLFileEntry dlFileEntry) {
11051                    if (dlFileEntry instanceof DLFileEntryImpl) {
11052                            return dlFileEntry;
11053                    }
11054    
11055                    DLFileEntryImpl dlFileEntryImpl = new DLFileEntryImpl();
11056    
11057                    dlFileEntryImpl.setNew(dlFileEntry.isNew());
11058                    dlFileEntryImpl.setPrimaryKey(dlFileEntry.getPrimaryKey());
11059    
11060                    dlFileEntryImpl.setUuid(dlFileEntry.getUuid());
11061                    dlFileEntryImpl.setFileEntryId(dlFileEntry.getFileEntryId());
11062                    dlFileEntryImpl.setGroupId(dlFileEntry.getGroupId());
11063                    dlFileEntryImpl.setCompanyId(dlFileEntry.getCompanyId());
11064                    dlFileEntryImpl.setUserId(dlFileEntry.getUserId());
11065                    dlFileEntryImpl.setUserName(dlFileEntry.getUserName());
11066                    dlFileEntryImpl.setCreateDate(dlFileEntry.getCreateDate());
11067                    dlFileEntryImpl.setModifiedDate(dlFileEntry.getModifiedDate());
11068                    dlFileEntryImpl.setClassNameId(dlFileEntry.getClassNameId());
11069                    dlFileEntryImpl.setClassPK(dlFileEntry.getClassPK());
11070                    dlFileEntryImpl.setRepositoryId(dlFileEntry.getRepositoryId());
11071                    dlFileEntryImpl.setFolderId(dlFileEntry.getFolderId());
11072                    dlFileEntryImpl.setTreePath(dlFileEntry.getTreePath());
11073                    dlFileEntryImpl.setName(dlFileEntry.getName());
11074                    dlFileEntryImpl.setExtension(dlFileEntry.getExtension());
11075                    dlFileEntryImpl.setMimeType(dlFileEntry.getMimeType());
11076                    dlFileEntryImpl.setTitle(dlFileEntry.getTitle());
11077                    dlFileEntryImpl.setDescription(dlFileEntry.getDescription());
11078                    dlFileEntryImpl.setExtraSettings(dlFileEntry.getExtraSettings());
11079                    dlFileEntryImpl.setFileEntryTypeId(dlFileEntry.getFileEntryTypeId());
11080                    dlFileEntryImpl.setVersion(dlFileEntry.getVersion());
11081                    dlFileEntryImpl.setSize(dlFileEntry.getSize());
11082                    dlFileEntryImpl.setReadCount(dlFileEntry.getReadCount());
11083                    dlFileEntryImpl.setSmallImageId(dlFileEntry.getSmallImageId());
11084                    dlFileEntryImpl.setLargeImageId(dlFileEntry.getLargeImageId());
11085                    dlFileEntryImpl.setCustom1ImageId(dlFileEntry.getCustom1ImageId());
11086                    dlFileEntryImpl.setCustom2ImageId(dlFileEntry.getCustom2ImageId());
11087                    dlFileEntryImpl.setManualCheckInRequired(dlFileEntry.isManualCheckInRequired());
11088    
11089                    return dlFileEntryImpl;
11090            }
11091    
11092            /**
11093             * Returns the document library file entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
11094             *
11095             * @param primaryKey the primary key of the document library file entry
11096             * @return the document library file entry
11097             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
11098             * @throws SystemException if a system exception occurred
11099             */
11100            @Override
11101            public DLFileEntry findByPrimaryKey(Serializable primaryKey)
11102                    throws NoSuchFileEntryException, SystemException {
11103                    DLFileEntry dlFileEntry = fetchByPrimaryKey(primaryKey);
11104    
11105                    if (dlFileEntry == null) {
11106                            if (_log.isWarnEnabled()) {
11107                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
11108                            }
11109    
11110                            throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
11111                                    primaryKey);
11112                    }
11113    
11114                    return dlFileEntry;
11115            }
11116    
11117            /**
11118             * 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.
11119             *
11120             * @param fileEntryId the primary key of the document library file entry
11121             * @return the document library file entry
11122             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
11123             * @throws SystemException if a system exception occurred
11124             */
11125            @Override
11126            public DLFileEntry findByPrimaryKey(long fileEntryId)
11127                    throws NoSuchFileEntryException, SystemException {
11128                    return findByPrimaryKey((Serializable)fileEntryId);
11129            }
11130    
11131            /**
11132             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
11133             *
11134             * @param primaryKey the primary key of the document library file entry
11135             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
11136             * @throws SystemException if a system exception occurred
11137             */
11138            @Override
11139            public DLFileEntry fetchByPrimaryKey(Serializable primaryKey)
11140                    throws SystemException {
11141                    DLFileEntry dlFileEntry = (DLFileEntry)EntityCacheUtil.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11142                                    DLFileEntryImpl.class, primaryKey);
11143    
11144                    if (dlFileEntry == _nullDLFileEntry) {
11145                            return null;
11146                    }
11147    
11148                    if (dlFileEntry == null) {
11149                            Session session = null;
11150    
11151                            try {
11152                                    session = openSession();
11153    
11154                                    dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
11155                                                    primaryKey);
11156    
11157                                    if (dlFileEntry != null) {
11158                                            cacheResult(dlFileEntry);
11159                                    }
11160                                    else {
11161                                            EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11162                                                    DLFileEntryImpl.class, primaryKey, _nullDLFileEntry);
11163                                    }
11164                            }
11165                            catch (Exception e) {
11166                                    EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11167                                            DLFileEntryImpl.class, primaryKey);
11168    
11169                                    throw processException(e);
11170                            }
11171                            finally {
11172                                    closeSession(session);
11173                            }
11174                    }
11175    
11176                    return dlFileEntry;
11177            }
11178    
11179            /**
11180             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
11181             *
11182             * @param fileEntryId the primary key of the document library file entry
11183             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
11184             * @throws SystemException if a system exception occurred
11185             */
11186            @Override
11187            public DLFileEntry fetchByPrimaryKey(long fileEntryId)
11188                    throws SystemException {
11189                    return fetchByPrimaryKey((Serializable)fileEntryId);
11190            }
11191    
11192            /**
11193             * Returns all the document library file entries.
11194             *
11195             * @return the document library file entries
11196             * @throws SystemException if a system exception occurred
11197             */
11198            @Override
11199            public List<DLFileEntry> findAll() throws SystemException {
11200                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11201            }
11202    
11203            /**
11204             * Returns a range of all the document library file entries.
11205             *
11206             * <p>
11207             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11208             * </p>
11209             *
11210             * @param start the lower bound of the range of document library file entries
11211             * @param end the upper bound of the range of document library file entries (not inclusive)
11212             * @return the range of document library file entries
11213             * @throws SystemException if a system exception occurred
11214             */
11215            @Override
11216            public List<DLFileEntry> findAll(int start, int end)
11217                    throws SystemException {
11218                    return findAll(start, end, null);
11219            }
11220    
11221            /**
11222             * Returns an ordered range of all the document library file entries.
11223             *
11224             * <p>
11225             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11226             * </p>
11227             *
11228             * @param start the lower bound of the range of document library file entries
11229             * @param end the upper bound of the range of document library file entries (not inclusive)
11230             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11231             * @return the ordered range of document library file entries
11232             * @throws SystemException if a system exception occurred
11233             */
11234            @Override
11235            public List<DLFileEntry> findAll(int start, int end,
11236                    OrderByComparator orderByComparator) throws SystemException {
11237                    boolean pagination = true;
11238                    FinderPath finderPath = null;
11239                    Object[] finderArgs = null;
11240    
11241                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11242                                    (orderByComparator == null)) {
11243                            pagination = false;
11244                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
11245                            finderArgs = FINDER_ARGS_EMPTY;
11246                    }
11247                    else {
11248                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
11249                            finderArgs = new Object[] { start, end, orderByComparator };
11250                    }
11251    
11252                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
11253                                    finderArgs, this);
11254    
11255                    if (list == null) {
11256                            StringBundler query = null;
11257                            String sql = null;
11258    
11259                            if (orderByComparator != null) {
11260                                    query = new StringBundler(2 +
11261                                                    (orderByComparator.getOrderByFields().length * 3));
11262    
11263                                    query.append(_SQL_SELECT_DLFILEENTRY);
11264    
11265                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11266                                            orderByComparator);
11267    
11268                                    sql = query.toString();
11269                            }
11270                            else {
11271                                    sql = _SQL_SELECT_DLFILEENTRY;
11272    
11273                                    if (pagination) {
11274                                            sql = sql.concat(DLFileEntryModelImpl.ORDER_BY_JPQL);
11275                                    }
11276                            }
11277    
11278                            Session session = null;
11279    
11280                            try {
11281                                    session = openSession();
11282    
11283                                    Query q = session.createQuery(sql);
11284    
11285                                    if (!pagination) {
11286                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
11287                                                            start, end, false);
11288    
11289                                            Collections.sort(list);
11290    
11291                                            list = new UnmodifiableList<DLFileEntry>(list);
11292                                    }
11293                                    else {
11294                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
11295                                                            start, end);
11296                                    }
11297    
11298                                    cacheResult(list);
11299    
11300                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11301                            }
11302                            catch (Exception e) {
11303                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11304    
11305                                    throw processException(e);
11306                            }
11307                            finally {
11308                                    closeSession(session);
11309                            }
11310                    }
11311    
11312                    return list;
11313            }
11314    
11315            /**
11316             * Removes all the document library file entries from the database.
11317             *
11318             * @throws SystemException if a system exception occurred
11319             */
11320            @Override
11321            public void removeAll() throws SystemException {
11322                    for (DLFileEntry dlFileEntry : findAll()) {
11323                            remove(dlFileEntry);
11324                    }
11325            }
11326    
11327            /**
11328             * Returns the number of document library file entries.
11329             *
11330             * @return the number of document library file entries
11331             * @throws SystemException if a system exception occurred
11332             */
11333            @Override
11334            public int countAll() throws SystemException {
11335                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
11336                                    FINDER_ARGS_EMPTY, this);
11337    
11338                    if (count == null) {
11339                            Session session = null;
11340    
11341                            try {
11342                                    session = openSession();
11343    
11344                                    Query q = session.createQuery(_SQL_COUNT_DLFILEENTRY);
11345    
11346                                    count = (Long)q.uniqueResult();
11347    
11348                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
11349                                            FINDER_ARGS_EMPTY, count);
11350                            }
11351                            catch (Exception e) {
11352                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
11353                                            FINDER_ARGS_EMPTY);
11354    
11355                                    throw processException(e);
11356                            }
11357                            finally {
11358                                    closeSession(session);
11359                            }
11360                    }
11361    
11362                    return count.intValue();
11363            }
11364    
11365            @Override
11366            protected Set<String> getBadColumnNames() {
11367                    return _badColumnNames;
11368            }
11369    
11370            /**
11371             * Initializes the document library file entry persistence.
11372             */
11373            public void afterPropertiesSet() {
11374                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
11375                                            com.liferay.portal.util.PropsUtil.get(
11376                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry")));
11377    
11378                    if (listenerClassNames.length > 0) {
11379                            try {
11380                                    List<ModelListener<DLFileEntry>> listenersList = new ArrayList<ModelListener<DLFileEntry>>();
11381    
11382                                    for (String listenerClassName : listenerClassNames) {
11383                                            listenersList.add((ModelListener<DLFileEntry>)InstanceFactory.newInstance(
11384                                                            getClassLoader(), listenerClassName));
11385                                    }
11386    
11387                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
11388                            }
11389                            catch (Exception e) {
11390                                    _log.error(e);
11391                            }
11392                    }
11393            }
11394    
11395            public void destroy() {
11396                    EntityCacheUtil.removeCache(DLFileEntryImpl.class.getName());
11397                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
11398                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11399                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11400            }
11401    
11402            private static final String _SQL_SELECT_DLFILEENTRY = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry";
11403            private static final String _SQL_SELECT_DLFILEENTRY_WHERE = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ";
11404            private static final String _SQL_COUNT_DLFILEENTRY = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry";
11405            private static final String _SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry WHERE ";
11406            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntry.fileEntryId";
11407            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_WHERE = "SELECT DISTINCT {dlFileEntry.*} FROM DLFileEntry dlFileEntry WHERE ";
11408            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1 =
11409                    "SELECT {DLFileEntry.*} FROM (SELECT DISTINCT dlFileEntry.fileEntryId FROM DLFileEntry dlFileEntry WHERE ";
11410            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2 =
11411                    ") TEMP_TABLE INNER JOIN DLFileEntry ON TEMP_TABLE.fileEntryId = DLFileEntry.fileEntryId";
11412            private static final String _FILTER_SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(DISTINCT dlFileEntry.fileEntryId) AS COUNT_VALUE FROM DLFileEntry dlFileEntry WHERE ";
11413            private static final String _FILTER_ENTITY_ALIAS = "dlFileEntry";
11414            private static final String _FILTER_ENTITY_TABLE = "DLFileEntry";
11415            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntry.";
11416            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntry.";
11417            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntry exists with the primary key ";
11418            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntry exists with the key {";
11419            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
11420            private static Log _log = LogFactoryUtil.getLog(DLFileEntryPersistenceImpl.class);
11421            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
11422                                    "uuid", "size"
11423                            });
11424            private static DLFileEntry _nullDLFileEntry = new DLFileEntryImpl() {
11425                            @Override
11426                            public Object clone() {
11427                                    return this;
11428                            }
11429    
11430                            @Override
11431                            public CacheModel<DLFileEntry> toCacheModel() {
11432                                    return _nullDLFileEntryCacheModel;
11433                            }
11434                    };
11435    
11436            private static CacheModel<DLFileEntry> _nullDLFileEntryCacheModel = new CacheModel<DLFileEntry>() {
11437                            @Override
11438                            public DLFileEntry toEntityModel() {
11439                                    return _nullDLFileEntry;
11440                            }
11441                    };
11442    }