001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.SQLQuery;
029    import com.liferay.portal.kernel.dao.orm.Session;
030    import com.liferay.portal.kernel.log.Log;
031    import com.liferay.portal.kernel.log.LogFactoryUtil;
032    import com.liferay.portal.kernel.util.ArrayUtil;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.SetUtil;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.StringUtil;
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.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.ServiceContext;
043    import com.liferay.portal.service.ServiceContextThreadLocal;
044    import com.liferay.portal.service.persistence.CompanyProvider;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
048    import com.liferay.portlet.documentlibrary.model.DLFileEntry;
049    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
050    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryModelImpl;
051    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence;
052    
053    import java.io.Serializable;
054    
055    import java.util.Arrays;
056    import java.util.Collections;
057    import java.util.Date;
058    import java.util.HashMap;
059    import java.util.HashSet;
060    import java.util.Iterator;
061    import java.util.List;
062    import java.util.Map;
063    import java.util.Set;
064    
065    /**
066     * The persistence implementation for the document library file entry service.
067     *
068     * <p>
069     * Caching information and settings can be found in <code>portal.properties</code>
070     * </p>
071     *
072     * @author Brian Wing Shun Chan
073     * @see DLFileEntryPersistence
074     * @see com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryUtil
075     * @generated
076     */
077    @ProviderType
078    public class DLFileEntryPersistenceImpl extends BasePersistenceImpl<DLFileEntry>
079            implements DLFileEntryPersistence {
080            /*
081             * NOTE FOR DEVELOPERS:
082             *
083             * 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.
084             */
085            public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryImpl.class.getName();
086            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087                    ".List1";
088            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089                    ".List2";
090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
091                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
092                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
093            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
094                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
096            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
097                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
099            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
100                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
102                            new String[] {
103                                    String.class.getName(),
104                                    
105                            Integer.class.getName(), Integer.class.getName(),
106                                    OrderByComparator.class.getName()
107                            });
108            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
109                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
111                            new String[] { String.class.getName() },
112                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK |
113                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
114                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
115            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
116                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
118                            new String[] { String.class.getName() });
119    
120            /**
121             * Returns all the document library file entries where uuid = &#63;.
122             *
123             * @param uuid the uuid
124             * @return the matching document library file entries
125             */
126            @Override
127            public List<DLFileEntry> findByUuid(String uuid) {
128                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
129            }
130    
131            /**
132             * Returns a range of all the document library file entries where uuid = &#63;.
133             *
134             * <p>
135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
136             * </p>
137             *
138             * @param uuid the uuid
139             * @param start the lower bound of the range of document library file entries
140             * @param end the upper bound of the range of document library file entries (not inclusive)
141             * @return the range of matching document library file entries
142             */
143            @Override
144            public List<DLFileEntry> findByUuid(String uuid, int start, int end) {
145                    return findByUuid(uuid, start, end, null);
146            }
147    
148            /**
149             * Returns an ordered range of all the document library file entries where uuid = &#63;.
150             *
151             * <p>
152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
153             * </p>
154             *
155             * @param uuid the uuid
156             * @param start the lower bound of the range of document library file entries
157             * @param end the upper bound of the range of document library file entries (not inclusive)
158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
159             * @return the ordered range of matching document library file entries
160             */
161            @Override
162            public List<DLFileEntry> findByUuid(String uuid, int start, int end,
163                    OrderByComparator<DLFileEntry> orderByComparator) {
164                    return findByUuid(uuid, start, end, orderByComparator, true);
165            }
166    
167            /**
168             * Returns an ordered range of all the document library file entries where uuid = &#63;.
169             *
170             * <p>
171             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
172             * </p>
173             *
174             * @param uuid the uuid
175             * @param start the lower bound of the range of document library file entries
176             * @param end the upper bound of the range of document library file entries (not inclusive)
177             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
178             * @param retrieveFromCache whether to retrieve from the finder cache
179             * @return the ordered range of matching document library file entries
180             */
181            @Override
182            public List<DLFileEntry> findByUuid(String uuid, int start, int end,
183                    OrderByComparator<DLFileEntry> orderByComparator,
184                    boolean retrieveFromCache) {
185                    boolean pagination = true;
186                    FinderPath finderPath = null;
187                    Object[] finderArgs = null;
188    
189                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
190                                    (orderByComparator == null)) {
191                            pagination = false;
192                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
193                            finderArgs = new Object[] { uuid };
194                    }
195                    else {
196                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
197                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
198                    }
199    
200                    List<DLFileEntry> list = null;
201    
202                    if (retrieveFromCache) {
203                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
204                                            finderArgs, this);
205    
206                            if ((list != null) && !list.isEmpty()) {
207                                    for (DLFileEntry dlFileEntry : list) {
208                                            if (!Validator.equals(uuid, dlFileEntry.getUuid())) {
209                                                    list = null;
210    
211                                                    break;
212                                            }
213                                    }
214                            }
215                    }
216    
217                    if (list == null) {
218                            StringBundler query = null;
219    
220                            if (orderByComparator != null) {
221                                    query = new StringBundler(3 +
222                                                    (orderByComparator.getOrderByFields().length * 3));
223                            }
224                            else {
225                                    query = new StringBundler(3);
226                            }
227    
228                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
229    
230                            boolean bindUuid = false;
231    
232                            if (uuid == null) {
233                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
234                            }
235                            else if (uuid.equals(StringPool.BLANK)) {
236                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
237                            }
238                            else {
239                                    bindUuid = true;
240    
241                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
242                            }
243    
244                            if (orderByComparator != null) {
245                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
246                                            orderByComparator);
247                            }
248                            else
249                             if (pagination) {
250                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
251                            }
252    
253                            String sql = query.toString();
254    
255                            Session session = null;
256    
257                            try {
258                                    session = openSession();
259    
260                                    Query q = session.createQuery(sql);
261    
262                                    QueryPos qPos = QueryPos.getInstance(q);
263    
264                                    if (bindUuid) {
265                                            qPos.add(uuid);
266                                    }
267    
268                                    if (!pagination) {
269                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
270                                                            start, end, false);
271    
272                                            Collections.sort(list);
273    
274                                            list = Collections.unmodifiableList(list);
275                                    }
276                                    else {
277                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
278                                                            start, end);
279                                    }
280    
281                                    cacheResult(list);
282    
283                                    finderCache.putResult(finderPath, finderArgs, list);
284                            }
285                            catch (Exception e) {
286                                    finderCache.removeResult(finderPath, finderArgs);
287    
288                                    throw processException(e);
289                            }
290                            finally {
291                                    closeSession(session);
292                            }
293                    }
294    
295                    return list;
296            }
297    
298            /**
299             * Returns the first document library file entry in the ordered set where uuid = &#63;.
300             *
301             * @param uuid the uuid
302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
303             * @return the first matching document library file entry
304             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
305             */
306            @Override
307            public DLFileEntry findByUuid_First(String uuid,
308                    OrderByComparator<DLFileEntry> orderByComparator)
309                    throws NoSuchFileEntryException {
310                    DLFileEntry dlFileEntry = fetchByUuid_First(uuid, orderByComparator);
311    
312                    if (dlFileEntry != null) {
313                            return dlFileEntry;
314                    }
315    
316                    StringBundler msg = new StringBundler(4);
317    
318                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
319    
320                    msg.append("uuid=");
321                    msg.append(uuid);
322    
323                    msg.append(StringPool.CLOSE_CURLY_BRACE);
324    
325                    throw new NoSuchFileEntryException(msg.toString());
326            }
327    
328            /**
329             * Returns the first document library file entry in the ordered set where uuid = &#63;.
330             *
331             * @param uuid the uuid
332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
333             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
334             */
335            @Override
336            public DLFileEntry fetchByUuid_First(String uuid,
337                    OrderByComparator<DLFileEntry> orderByComparator) {
338                    List<DLFileEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
339    
340                    if (!list.isEmpty()) {
341                            return list.get(0);
342                    }
343    
344                    return null;
345            }
346    
347            /**
348             * Returns the last document library file entry in the ordered set where uuid = &#63;.
349             *
350             * @param uuid the uuid
351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
352             * @return the last matching document library file entry
353             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
354             */
355            @Override
356            public DLFileEntry findByUuid_Last(String uuid,
357                    OrderByComparator<DLFileEntry> orderByComparator)
358                    throws NoSuchFileEntryException {
359                    DLFileEntry dlFileEntry = fetchByUuid_Last(uuid, orderByComparator);
360    
361                    if (dlFileEntry != null) {
362                            return dlFileEntry;
363                    }
364    
365                    StringBundler msg = new StringBundler(4);
366    
367                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
368    
369                    msg.append("uuid=");
370                    msg.append(uuid);
371    
372                    msg.append(StringPool.CLOSE_CURLY_BRACE);
373    
374                    throw new NoSuchFileEntryException(msg.toString());
375            }
376    
377            /**
378             * Returns the last document library file entry in the ordered set where uuid = &#63;.
379             *
380             * @param uuid the uuid
381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
382             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
383             */
384            @Override
385            public DLFileEntry fetchByUuid_Last(String uuid,
386                    OrderByComparator<DLFileEntry> orderByComparator) {
387                    int count = countByUuid(uuid);
388    
389                    if (count == 0) {
390                            return null;
391                    }
392    
393                    List<DLFileEntry> list = findByUuid(uuid, count - 1, count,
394                                    orderByComparator);
395    
396                    if (!list.isEmpty()) {
397                            return list.get(0);
398                    }
399    
400                    return null;
401            }
402    
403            /**
404             * Returns the document library file entries before and after the current document library file entry in the ordered set where uuid = &#63;.
405             *
406             * @param fileEntryId the primary key of the current document library file entry
407             * @param uuid the uuid
408             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
409             * @return the previous, current, and next document library file entry
410             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
411             */
412            @Override
413            public DLFileEntry[] findByUuid_PrevAndNext(long fileEntryId, String uuid,
414                    OrderByComparator<DLFileEntry> orderByComparator)
415                    throws NoSuchFileEntryException {
416                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
417    
418                    Session session = null;
419    
420                    try {
421                            session = openSession();
422    
423                            DLFileEntry[] array = new DLFileEntryImpl[3];
424    
425                            array[0] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
426                                            orderByComparator, true);
427    
428                            array[1] = dlFileEntry;
429    
430                            array[2] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
431                                            orderByComparator, false);
432    
433                            return array;
434                    }
435                    catch (Exception e) {
436                            throw processException(e);
437                    }
438                    finally {
439                            closeSession(session);
440                    }
441            }
442    
443            protected DLFileEntry getByUuid_PrevAndNext(Session session,
444                    DLFileEntry dlFileEntry, String uuid,
445                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
446                    StringBundler query = null;
447    
448                    if (orderByComparator != null) {
449                            query = new StringBundler(6 +
450                                            (orderByComparator.getOrderByFields().length * 6));
451                    }
452                    else {
453                            query = new StringBundler(3);
454                    }
455    
456                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
457    
458                    boolean bindUuid = false;
459    
460                    if (uuid == null) {
461                            query.append(_FINDER_COLUMN_UUID_UUID_1);
462                    }
463                    else if (uuid.equals(StringPool.BLANK)) {
464                            query.append(_FINDER_COLUMN_UUID_UUID_3);
465                    }
466                    else {
467                            bindUuid = true;
468    
469                            query.append(_FINDER_COLUMN_UUID_UUID_2);
470                    }
471    
472                    if (orderByComparator != null) {
473                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
474    
475                            if (orderByConditionFields.length > 0) {
476                                    query.append(WHERE_AND);
477                            }
478    
479                            for (int i = 0; i < orderByConditionFields.length; i++) {
480                                    query.append(_ORDER_BY_ENTITY_ALIAS);
481                                    query.append(orderByConditionFields[i]);
482    
483                                    if ((i + 1) < orderByConditionFields.length) {
484                                            if (orderByComparator.isAscending() ^ previous) {
485                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
486                                            }
487                                            else {
488                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
489                                            }
490                                    }
491                                    else {
492                                            if (orderByComparator.isAscending() ^ previous) {
493                                                    query.append(WHERE_GREATER_THAN);
494                                            }
495                                            else {
496                                                    query.append(WHERE_LESSER_THAN);
497                                            }
498                                    }
499                            }
500    
501                            query.append(ORDER_BY_CLAUSE);
502    
503                            String[] orderByFields = orderByComparator.getOrderByFields();
504    
505                            for (int i = 0; i < orderByFields.length; i++) {
506                                    query.append(_ORDER_BY_ENTITY_ALIAS);
507                                    query.append(orderByFields[i]);
508    
509                                    if ((i + 1) < orderByFields.length) {
510                                            if (orderByComparator.isAscending() ^ previous) {
511                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
512                                            }
513                                            else {
514                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
515                                            }
516                                    }
517                                    else {
518                                            if (orderByComparator.isAscending() ^ previous) {
519                                                    query.append(ORDER_BY_ASC);
520                                            }
521                                            else {
522                                                    query.append(ORDER_BY_DESC);
523                                            }
524                                    }
525                            }
526                    }
527                    else {
528                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
529                    }
530    
531                    String sql = query.toString();
532    
533                    Query q = session.createQuery(sql);
534    
535                    q.setFirstResult(0);
536                    q.setMaxResults(2);
537    
538                    QueryPos qPos = QueryPos.getInstance(q);
539    
540                    if (bindUuid) {
541                            qPos.add(uuid);
542                    }
543    
544                    if (orderByComparator != null) {
545                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
546    
547                            for (Object value : values) {
548                                    qPos.add(value);
549                            }
550                    }
551    
552                    List<DLFileEntry> list = q.list();
553    
554                    if (list.size() == 2) {
555                            return list.get(1);
556                    }
557                    else {
558                            return null;
559                    }
560            }
561    
562            /**
563             * Removes all the document library file entries where uuid = &#63; from the database.
564             *
565             * @param uuid the uuid
566             */
567            @Override
568            public void removeByUuid(String uuid) {
569                    for (DLFileEntry dlFileEntry : findByUuid(uuid, QueryUtil.ALL_POS,
570                                    QueryUtil.ALL_POS, null)) {
571                            remove(dlFileEntry);
572                    }
573            }
574    
575            /**
576             * Returns the number of document library file entries where uuid = &#63;.
577             *
578             * @param uuid the uuid
579             * @return the number of matching document library file entries
580             */
581            @Override
582            public int countByUuid(String uuid) {
583                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
584    
585                    Object[] finderArgs = new Object[] { uuid };
586    
587                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
588    
589                    if (count == null) {
590                            StringBundler query = new StringBundler(2);
591    
592                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
593    
594                            boolean bindUuid = false;
595    
596                            if (uuid == null) {
597                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
598                            }
599                            else if (uuid.equals(StringPool.BLANK)) {
600                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
601                            }
602                            else {
603                                    bindUuid = true;
604    
605                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
606                            }
607    
608                            String sql = query.toString();
609    
610                            Session session = null;
611    
612                            try {
613                                    session = openSession();
614    
615                                    Query q = session.createQuery(sql);
616    
617                                    QueryPos qPos = QueryPos.getInstance(q);
618    
619                                    if (bindUuid) {
620                                            qPos.add(uuid);
621                                    }
622    
623                                    count = (Long)q.uniqueResult();
624    
625                                    finderCache.putResult(finderPath, finderArgs, count);
626                            }
627                            catch (Exception e) {
628                                    finderCache.removeResult(finderPath, finderArgs);
629    
630                                    throw processException(e);
631                            }
632                            finally {
633                                    closeSession(session);
634                            }
635                    }
636    
637                    return count.intValue();
638            }
639    
640            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntry.uuid IS NULL";
641            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntry.uuid = ?";
642            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = '')";
643            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
644                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
645                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
646                            new String[] { String.class.getName(), Long.class.getName() },
647                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK |
648                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK);
649            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
650                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
651                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
652                            new String[] { String.class.getName(), Long.class.getName() });
653    
654            /**
655             * Returns the document library file entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchFileEntryException} if it could not be found.
656             *
657             * @param uuid the uuid
658             * @param groupId the group ID
659             * @return the matching document library file entry
660             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
661             */
662            @Override
663            public DLFileEntry findByUUID_G(String uuid, long groupId)
664                    throws NoSuchFileEntryException {
665                    DLFileEntry dlFileEntry = fetchByUUID_G(uuid, groupId);
666    
667                    if (dlFileEntry == null) {
668                            StringBundler msg = new StringBundler(6);
669    
670                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
671    
672                            msg.append("uuid=");
673                            msg.append(uuid);
674    
675                            msg.append(", groupId=");
676                            msg.append(groupId);
677    
678                            msg.append(StringPool.CLOSE_CURLY_BRACE);
679    
680                            if (_log.isWarnEnabled()) {
681                                    _log.warn(msg.toString());
682                            }
683    
684                            throw new NoSuchFileEntryException(msg.toString());
685                    }
686    
687                    return dlFileEntry;
688            }
689    
690            /**
691             * 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.
692             *
693             * @param uuid the uuid
694             * @param groupId the group ID
695             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
696             */
697            @Override
698            public DLFileEntry fetchByUUID_G(String uuid, long groupId) {
699                    return fetchByUUID_G(uuid, groupId, true);
700            }
701    
702            /**
703             * 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.
704             *
705             * @param uuid the uuid
706             * @param groupId the group ID
707             * @param retrieveFromCache whether to retrieve from the finder cache
708             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
709             */
710            @Override
711            public DLFileEntry fetchByUUID_G(String uuid, long groupId,
712                    boolean retrieveFromCache) {
713                    Object[] finderArgs = new Object[] { uuid, groupId };
714    
715                    Object result = null;
716    
717                    if (retrieveFromCache) {
718                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
719                                            finderArgs, this);
720                    }
721    
722                    if (result instanceof DLFileEntry) {
723                            DLFileEntry dlFileEntry = (DLFileEntry)result;
724    
725                            if (!Validator.equals(uuid, dlFileEntry.getUuid()) ||
726                                            (groupId != dlFileEntry.getGroupId())) {
727                                    result = null;
728                            }
729                    }
730    
731                    if (result == null) {
732                            StringBundler query = new StringBundler(4);
733    
734                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
735    
736                            boolean bindUuid = false;
737    
738                            if (uuid == null) {
739                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
740                            }
741                            else if (uuid.equals(StringPool.BLANK)) {
742                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
743                            }
744                            else {
745                                    bindUuid = true;
746    
747                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
748                            }
749    
750                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
751    
752                            String sql = query.toString();
753    
754                            Session session = null;
755    
756                            try {
757                                    session = openSession();
758    
759                                    Query q = session.createQuery(sql);
760    
761                                    QueryPos qPos = QueryPos.getInstance(q);
762    
763                                    if (bindUuid) {
764                                            qPos.add(uuid);
765                                    }
766    
767                                    qPos.add(groupId);
768    
769                                    List<DLFileEntry> list = q.list();
770    
771                                    if (list.isEmpty()) {
772                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
773                                                    finderArgs, list);
774                                    }
775                                    else {
776                                            DLFileEntry dlFileEntry = list.get(0);
777    
778                                            result = dlFileEntry;
779    
780                                            cacheResult(dlFileEntry);
781    
782                                            if ((dlFileEntry.getUuid() == null) ||
783                                                            !dlFileEntry.getUuid().equals(uuid) ||
784                                                            (dlFileEntry.getGroupId() != groupId)) {
785                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
786                                                            finderArgs, dlFileEntry);
787                                            }
788                                    }
789                            }
790                            catch (Exception e) {
791                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
792    
793                                    throw processException(e);
794                            }
795                            finally {
796                                    closeSession(session);
797                            }
798                    }
799    
800                    if (result instanceof List<?>) {
801                            return null;
802                    }
803                    else {
804                            return (DLFileEntry)result;
805                    }
806            }
807    
808            /**
809             * Removes the document library file entry where uuid = &#63; and groupId = &#63; from the database.
810             *
811             * @param uuid the uuid
812             * @param groupId the group ID
813             * @return the document library file entry that was removed
814             */
815            @Override
816            public DLFileEntry removeByUUID_G(String uuid, long groupId)
817                    throws NoSuchFileEntryException {
818                    DLFileEntry dlFileEntry = findByUUID_G(uuid, groupId);
819    
820                    return remove(dlFileEntry);
821            }
822    
823            /**
824             * Returns the number of document library file entries where uuid = &#63; and groupId = &#63;.
825             *
826             * @param uuid the uuid
827             * @param groupId the group ID
828             * @return the number of matching document library file entries
829             */
830            @Override
831            public int countByUUID_G(String uuid, long groupId) {
832                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
833    
834                    Object[] finderArgs = new Object[] { uuid, groupId };
835    
836                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
837    
838                    if (count == null) {
839                            StringBundler query = new StringBundler(3);
840    
841                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
842    
843                            boolean bindUuid = false;
844    
845                            if (uuid == null) {
846                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
847                            }
848                            else if (uuid.equals(StringPool.BLANK)) {
849                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
850                            }
851                            else {
852                                    bindUuid = true;
853    
854                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
855                            }
856    
857                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
858    
859                            String sql = query.toString();
860    
861                            Session session = null;
862    
863                            try {
864                                    session = openSession();
865    
866                                    Query q = session.createQuery(sql);
867    
868                                    QueryPos qPos = QueryPos.getInstance(q);
869    
870                                    if (bindUuid) {
871                                            qPos.add(uuid);
872                                    }
873    
874                                    qPos.add(groupId);
875    
876                                    count = (Long)q.uniqueResult();
877    
878                                    finderCache.putResult(finderPath, finderArgs, count);
879                            }
880                            catch (Exception e) {
881                                    finderCache.removeResult(finderPath, finderArgs);
882    
883                                    throw processException(e);
884                            }
885                            finally {
886                                    closeSession(session);
887                            }
888                    }
889    
890                    return count.intValue();
891            }
892    
893            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntry.uuid IS NULL AND ";
894            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntry.uuid = ? AND ";
895            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = '') AND ";
896            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntry.groupId = ?";
897            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
898                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
899                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
900                            new String[] {
901                                    String.class.getName(), Long.class.getName(),
902                                    
903                            Integer.class.getName(), Integer.class.getName(),
904                                    OrderByComparator.class.getName()
905                            });
906            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
907                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
908                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
909                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
910                            new String[] { String.class.getName(), Long.class.getName() },
911                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK |
912                            DLFileEntryModelImpl.COMPANYID_COLUMN_BITMASK |
913                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
914                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
915            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
916                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
917                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
918                            new String[] { String.class.getName(), Long.class.getName() });
919    
920            /**
921             * Returns all the document library file entries where uuid = &#63; and companyId = &#63;.
922             *
923             * @param uuid the uuid
924             * @param companyId the company ID
925             * @return the matching document library file entries
926             */
927            @Override
928            public List<DLFileEntry> findByUuid_C(String uuid, long companyId) {
929                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
930                            QueryUtil.ALL_POS, null);
931            }
932    
933            /**
934             * Returns a range of all the document library file entries where uuid = &#63; and companyId = &#63;.
935             *
936             * <p>
937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
938             * </p>
939             *
940             * @param uuid the uuid
941             * @param companyId the company ID
942             * @param start the lower bound of the range of document library file entries
943             * @param end the upper bound of the range of document library file entries (not inclusive)
944             * @return the range of matching document library file entries
945             */
946            @Override
947            public List<DLFileEntry> findByUuid_C(String uuid, long companyId,
948                    int start, int end) {
949                    return findByUuid_C(uuid, companyId, start, end, null);
950            }
951    
952            /**
953             * Returns an ordered range of all the document library file entries where uuid = &#63; and companyId = &#63;.
954             *
955             * <p>
956             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
957             * </p>
958             *
959             * @param uuid the uuid
960             * @param companyId the company ID
961             * @param start the lower bound of the range of document library file entries
962             * @param end the upper bound of the range of document library file entries (not inclusive)
963             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
964             * @return the ordered range of matching document library file entries
965             */
966            @Override
967            public List<DLFileEntry> findByUuid_C(String uuid, long companyId,
968                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
969                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
970            }
971    
972            /**
973             * Returns an ordered range of all the document library file entries where uuid = &#63; and companyId = &#63;.
974             *
975             * <p>
976             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
977             * </p>
978             *
979             * @param uuid the uuid
980             * @param companyId the company ID
981             * @param start the lower bound of the range of document library file entries
982             * @param end the upper bound of the range of document library file entries (not inclusive)
983             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
984             * @param retrieveFromCache whether to retrieve from the finder cache
985             * @return the ordered range of matching document library file entries
986             */
987            @Override
988            public List<DLFileEntry> findByUuid_C(String uuid, long companyId,
989                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator,
990                    boolean retrieveFromCache) {
991                    boolean pagination = true;
992                    FinderPath finderPath = null;
993                    Object[] finderArgs = null;
994    
995                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
996                                    (orderByComparator == null)) {
997                            pagination = false;
998                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
999                            finderArgs = new Object[] { uuid, companyId };
1000                    }
1001                    else {
1002                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1003                            finderArgs = new Object[] {
1004                                            uuid, companyId,
1005                                            
1006                                            start, end, orderByComparator
1007                                    };
1008                    }
1009    
1010                    List<DLFileEntry> list = null;
1011    
1012                    if (retrieveFromCache) {
1013                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
1014                                            finderArgs, this);
1015    
1016                            if ((list != null) && !list.isEmpty()) {
1017                                    for (DLFileEntry dlFileEntry : list) {
1018                                            if (!Validator.equals(uuid, dlFileEntry.getUuid()) ||
1019                                                            (companyId != dlFileEntry.getCompanyId())) {
1020                                                    list = null;
1021    
1022                                                    break;
1023                                            }
1024                                    }
1025                            }
1026                    }
1027    
1028                    if (list == null) {
1029                            StringBundler query = null;
1030    
1031                            if (orderByComparator != null) {
1032                                    query = new StringBundler(4 +
1033                                                    (orderByComparator.getOrderByFields().length * 3));
1034                            }
1035                            else {
1036                                    query = new StringBundler(4);
1037                            }
1038    
1039                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1040    
1041                            boolean bindUuid = false;
1042    
1043                            if (uuid == null) {
1044                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1045                            }
1046                            else if (uuid.equals(StringPool.BLANK)) {
1047                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1048                            }
1049                            else {
1050                                    bindUuid = true;
1051    
1052                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1053                            }
1054    
1055                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1056    
1057                            if (orderByComparator != null) {
1058                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1059                                            orderByComparator);
1060                            }
1061                            else
1062                             if (pagination) {
1063                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1064                            }
1065    
1066                            String sql = query.toString();
1067    
1068                            Session session = null;
1069    
1070                            try {
1071                                    session = openSession();
1072    
1073                                    Query q = session.createQuery(sql);
1074    
1075                                    QueryPos qPos = QueryPos.getInstance(q);
1076    
1077                                    if (bindUuid) {
1078                                            qPos.add(uuid);
1079                                    }
1080    
1081                                    qPos.add(companyId);
1082    
1083                                    if (!pagination) {
1084                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1085                                                            start, end, false);
1086    
1087                                            Collections.sort(list);
1088    
1089                                            list = Collections.unmodifiableList(list);
1090                                    }
1091                                    else {
1092                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1093                                                            start, end);
1094                                    }
1095    
1096                                    cacheResult(list);
1097    
1098                                    finderCache.putResult(finderPath, finderArgs, list);
1099                            }
1100                            catch (Exception e) {
1101                                    finderCache.removeResult(finderPath, finderArgs);
1102    
1103                                    throw processException(e);
1104                            }
1105                            finally {
1106                                    closeSession(session);
1107                            }
1108                    }
1109    
1110                    return list;
1111            }
1112    
1113            /**
1114             * Returns the first document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1115             *
1116             * @param uuid the uuid
1117             * @param companyId the company ID
1118             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1119             * @return the first matching document library file entry
1120             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
1121             */
1122            @Override
1123            public DLFileEntry findByUuid_C_First(String uuid, long companyId,
1124                    OrderByComparator<DLFileEntry> orderByComparator)
1125                    throws NoSuchFileEntryException {
1126                    DLFileEntry dlFileEntry = fetchByUuid_C_First(uuid, companyId,
1127                                    orderByComparator);
1128    
1129                    if (dlFileEntry != null) {
1130                            return dlFileEntry;
1131                    }
1132    
1133                    StringBundler msg = new StringBundler(6);
1134    
1135                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1136    
1137                    msg.append("uuid=");
1138                    msg.append(uuid);
1139    
1140                    msg.append(", companyId=");
1141                    msg.append(companyId);
1142    
1143                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1144    
1145                    throw new NoSuchFileEntryException(msg.toString());
1146            }
1147    
1148            /**
1149             * Returns the first document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1150             *
1151             * @param uuid the uuid
1152             * @param companyId the company ID
1153             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1154             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1155             */
1156            @Override
1157            public DLFileEntry fetchByUuid_C_First(String uuid, long companyId,
1158                    OrderByComparator<DLFileEntry> orderByComparator) {
1159                    List<DLFileEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1160                                    orderByComparator);
1161    
1162                    if (!list.isEmpty()) {
1163                            return list.get(0);
1164                    }
1165    
1166                    return null;
1167            }
1168    
1169            /**
1170             * Returns the last document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1171             *
1172             * @param uuid the uuid
1173             * @param companyId the company ID
1174             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1175             * @return the last matching document library file entry
1176             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
1177             */
1178            @Override
1179            public DLFileEntry findByUuid_C_Last(String uuid, long companyId,
1180                    OrderByComparator<DLFileEntry> orderByComparator)
1181                    throws NoSuchFileEntryException {
1182                    DLFileEntry dlFileEntry = fetchByUuid_C_Last(uuid, companyId,
1183                                    orderByComparator);
1184    
1185                    if (dlFileEntry != null) {
1186                            return dlFileEntry;
1187                    }
1188    
1189                    StringBundler msg = new StringBundler(6);
1190    
1191                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1192    
1193                    msg.append("uuid=");
1194                    msg.append(uuid);
1195    
1196                    msg.append(", companyId=");
1197                    msg.append(companyId);
1198    
1199                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1200    
1201                    throw new NoSuchFileEntryException(msg.toString());
1202            }
1203    
1204            /**
1205             * Returns the last document library file entry in the ordered set where uuid = &#63; and companyId = &#63;.
1206             *
1207             * @param uuid the uuid
1208             * @param companyId the company ID
1209             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1210             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1211             */
1212            @Override
1213            public DLFileEntry fetchByUuid_C_Last(String uuid, long companyId,
1214                    OrderByComparator<DLFileEntry> orderByComparator) {
1215                    int count = countByUuid_C(uuid, companyId);
1216    
1217                    if (count == 0) {
1218                            return null;
1219                    }
1220    
1221                    List<DLFileEntry> list = findByUuid_C(uuid, companyId, count - 1,
1222                                    count, orderByComparator);
1223    
1224                    if (!list.isEmpty()) {
1225                            return list.get(0);
1226                    }
1227    
1228                    return null;
1229            }
1230    
1231            /**
1232             * 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;.
1233             *
1234             * @param fileEntryId the primary key of the current document library file entry
1235             * @param uuid the uuid
1236             * @param companyId the company ID
1237             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1238             * @return the previous, current, and next document library file entry
1239             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
1240             */
1241            @Override
1242            public DLFileEntry[] findByUuid_C_PrevAndNext(long fileEntryId,
1243                    String uuid, long companyId,
1244                    OrderByComparator<DLFileEntry> orderByComparator)
1245                    throws NoSuchFileEntryException {
1246                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1247    
1248                    Session session = null;
1249    
1250                    try {
1251                            session = openSession();
1252    
1253                            DLFileEntry[] array = new DLFileEntryImpl[3];
1254    
1255                            array[0] = getByUuid_C_PrevAndNext(session, dlFileEntry, uuid,
1256                                            companyId, orderByComparator, true);
1257    
1258                            array[1] = dlFileEntry;
1259    
1260                            array[2] = getByUuid_C_PrevAndNext(session, dlFileEntry, uuid,
1261                                            companyId, orderByComparator, false);
1262    
1263                            return array;
1264                    }
1265                    catch (Exception e) {
1266                            throw processException(e);
1267                    }
1268                    finally {
1269                            closeSession(session);
1270                    }
1271            }
1272    
1273            protected DLFileEntry getByUuid_C_PrevAndNext(Session session,
1274                    DLFileEntry dlFileEntry, String uuid, long companyId,
1275                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
1276                    StringBundler query = null;
1277    
1278                    if (orderByComparator != null) {
1279                            query = new StringBundler(6 +
1280                                            (orderByComparator.getOrderByFields().length * 6));
1281                    }
1282                    else {
1283                            query = new StringBundler(3);
1284                    }
1285    
1286                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1287    
1288                    boolean bindUuid = false;
1289    
1290                    if (uuid == null) {
1291                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1292                    }
1293                    else if (uuid.equals(StringPool.BLANK)) {
1294                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1295                    }
1296                    else {
1297                            bindUuid = true;
1298    
1299                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1300                    }
1301    
1302                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1303    
1304                    if (orderByComparator != null) {
1305                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1306    
1307                            if (orderByConditionFields.length > 0) {
1308                                    query.append(WHERE_AND);
1309                            }
1310    
1311                            for (int i = 0; i < orderByConditionFields.length; i++) {
1312                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1313                                    query.append(orderByConditionFields[i]);
1314    
1315                                    if ((i + 1) < orderByConditionFields.length) {
1316                                            if (orderByComparator.isAscending() ^ previous) {
1317                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1318                                            }
1319                                            else {
1320                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1321                                            }
1322                                    }
1323                                    else {
1324                                            if (orderByComparator.isAscending() ^ previous) {
1325                                                    query.append(WHERE_GREATER_THAN);
1326                                            }
1327                                            else {
1328                                                    query.append(WHERE_LESSER_THAN);
1329                                            }
1330                                    }
1331                            }
1332    
1333                            query.append(ORDER_BY_CLAUSE);
1334    
1335                            String[] orderByFields = orderByComparator.getOrderByFields();
1336    
1337                            for (int i = 0; i < orderByFields.length; i++) {
1338                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1339                                    query.append(orderByFields[i]);
1340    
1341                                    if ((i + 1) < orderByFields.length) {
1342                                            if (orderByComparator.isAscending() ^ previous) {
1343                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1344                                            }
1345                                            else {
1346                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1347                                            }
1348                                    }
1349                                    else {
1350                                            if (orderByComparator.isAscending() ^ previous) {
1351                                                    query.append(ORDER_BY_ASC);
1352                                            }
1353                                            else {
1354                                                    query.append(ORDER_BY_DESC);
1355                                            }
1356                                    }
1357                            }
1358                    }
1359                    else {
1360                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1361                    }
1362    
1363                    String sql = query.toString();
1364    
1365                    Query q = session.createQuery(sql);
1366    
1367                    q.setFirstResult(0);
1368                    q.setMaxResults(2);
1369    
1370                    QueryPos qPos = QueryPos.getInstance(q);
1371    
1372                    if (bindUuid) {
1373                            qPos.add(uuid);
1374                    }
1375    
1376                    qPos.add(companyId);
1377    
1378                    if (orderByComparator != null) {
1379                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
1380    
1381                            for (Object value : values) {
1382                                    qPos.add(value);
1383                            }
1384                    }
1385    
1386                    List<DLFileEntry> list = q.list();
1387    
1388                    if (list.size() == 2) {
1389                            return list.get(1);
1390                    }
1391                    else {
1392                            return null;
1393                    }
1394            }
1395    
1396            /**
1397             * Removes all the document library file entries where uuid = &#63; and companyId = &#63; from the database.
1398             *
1399             * @param uuid the uuid
1400             * @param companyId the company ID
1401             */
1402            @Override
1403            public void removeByUuid_C(String uuid, long companyId) {
1404                    for (DLFileEntry dlFileEntry : findByUuid_C(uuid, companyId,
1405                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1406                            remove(dlFileEntry);
1407                    }
1408            }
1409    
1410            /**
1411             * Returns the number of document library file entries where uuid = &#63; and companyId = &#63;.
1412             *
1413             * @param uuid the uuid
1414             * @param companyId the company ID
1415             * @return the number of matching document library file entries
1416             */
1417            @Override
1418            public int countByUuid_C(String uuid, long companyId) {
1419                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1420    
1421                    Object[] finderArgs = new Object[] { uuid, companyId };
1422    
1423                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1424    
1425                    if (count == null) {
1426                            StringBundler query = new StringBundler(3);
1427    
1428                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
1429    
1430                            boolean bindUuid = false;
1431    
1432                            if (uuid == null) {
1433                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1434                            }
1435                            else if (uuid.equals(StringPool.BLANK)) {
1436                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1437                            }
1438                            else {
1439                                    bindUuid = true;
1440    
1441                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1442                            }
1443    
1444                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1445    
1446                            String sql = query.toString();
1447    
1448                            Session session = null;
1449    
1450                            try {
1451                                    session = openSession();
1452    
1453                                    Query q = session.createQuery(sql);
1454    
1455                                    QueryPos qPos = QueryPos.getInstance(q);
1456    
1457                                    if (bindUuid) {
1458                                            qPos.add(uuid);
1459                                    }
1460    
1461                                    qPos.add(companyId);
1462    
1463                                    count = (Long)q.uniqueResult();
1464    
1465                                    finderCache.putResult(finderPath, finderArgs, count);
1466                            }
1467                            catch (Exception e) {
1468                                    finderCache.removeResult(finderPath, finderArgs);
1469    
1470                                    throw processException(e);
1471                            }
1472                            finally {
1473                                    closeSession(session);
1474                            }
1475                    }
1476    
1477                    return count.intValue();
1478            }
1479    
1480            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "dlFileEntry.uuid IS NULL AND ";
1481            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dlFileEntry.uuid = ? AND ";
1482            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = '') AND ";
1483            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dlFileEntry.companyId = ?";
1484            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
1485                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
1486                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1487                            new String[] {
1488                                    Long.class.getName(),
1489                                    
1490                            Integer.class.getName(), Integer.class.getName(),
1491                                    OrderByComparator.class.getName()
1492                            });
1493            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1494                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
1495                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
1496                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1497                            new String[] { Long.class.getName() },
1498                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
1499                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
1500                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
1501            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
1502                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1503                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1504                            new String[] { Long.class.getName() });
1505    
1506            /**
1507             * Returns all the document library file entries where groupId = &#63;.
1508             *
1509             * @param groupId the group ID
1510             * @return the matching document library file entries
1511             */
1512            @Override
1513            public List<DLFileEntry> findByGroupId(long groupId) {
1514                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1515            }
1516    
1517            /**
1518             * Returns a range of all the document library file entries where groupId = &#63;.
1519             *
1520             * <p>
1521             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1522             * </p>
1523             *
1524             * @param groupId the group ID
1525             * @param start the lower bound of the range of document library file entries
1526             * @param end the upper bound of the range of document library file entries (not inclusive)
1527             * @return the range of matching document library file entries
1528             */
1529            @Override
1530            public List<DLFileEntry> findByGroupId(long groupId, int start, int end) {
1531                    return findByGroupId(groupId, start, end, null);
1532            }
1533    
1534            /**
1535             * Returns an ordered range of all the document library file entries where groupId = &#63;.
1536             *
1537             * <p>
1538             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1539             * </p>
1540             *
1541             * @param groupId the group ID
1542             * @param start the lower bound of the range of document library file entries
1543             * @param end the upper bound of the range of document library file entries (not inclusive)
1544             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1545             * @return the ordered range of matching document library file entries
1546             */
1547            @Override
1548            public List<DLFileEntry> findByGroupId(long groupId, int start, int end,
1549                    OrderByComparator<DLFileEntry> orderByComparator) {
1550                    return findByGroupId(groupId, start, end, orderByComparator, true);
1551            }
1552    
1553            /**
1554             * Returns an ordered range of all the document library file entries where groupId = &#63;.
1555             *
1556             * <p>
1557             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1558             * </p>
1559             *
1560             * @param groupId the group ID
1561             * @param start the lower bound of the range of document library file entries
1562             * @param end the upper bound of the range of document library file entries (not inclusive)
1563             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1564             * @param retrieveFromCache whether to retrieve from the finder cache
1565             * @return the ordered range of matching document library file entries
1566             */
1567            @Override
1568            public List<DLFileEntry> findByGroupId(long groupId, int start, int end,
1569                    OrderByComparator<DLFileEntry> orderByComparator,
1570                    boolean retrieveFromCache) {
1571                    boolean pagination = true;
1572                    FinderPath finderPath = null;
1573                    Object[] finderArgs = null;
1574    
1575                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1576                                    (orderByComparator == null)) {
1577                            pagination = false;
1578                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1579                            finderArgs = new Object[] { groupId };
1580                    }
1581                    else {
1582                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1583                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1584                    }
1585    
1586                    List<DLFileEntry> list = null;
1587    
1588                    if (retrieveFromCache) {
1589                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
1590                                            finderArgs, this);
1591    
1592                            if ((list != null) && !list.isEmpty()) {
1593                                    for (DLFileEntry dlFileEntry : list) {
1594                                            if ((groupId != dlFileEntry.getGroupId())) {
1595                                                    list = null;
1596    
1597                                                    break;
1598                                            }
1599                                    }
1600                            }
1601                    }
1602    
1603                    if (list == null) {
1604                            StringBundler query = null;
1605    
1606                            if (orderByComparator != null) {
1607                                    query = new StringBundler(3 +
1608                                                    (orderByComparator.getOrderByFields().length * 3));
1609                            }
1610                            else {
1611                                    query = new StringBundler(3);
1612                            }
1613    
1614                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1615    
1616                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1617    
1618                            if (orderByComparator != null) {
1619                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1620                                            orderByComparator);
1621                            }
1622                            else
1623                             if (pagination) {
1624                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1625                            }
1626    
1627                            String sql = query.toString();
1628    
1629                            Session session = null;
1630    
1631                            try {
1632                                    session = openSession();
1633    
1634                                    Query q = session.createQuery(sql);
1635    
1636                                    QueryPos qPos = QueryPos.getInstance(q);
1637    
1638                                    qPos.add(groupId);
1639    
1640                                    if (!pagination) {
1641                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1642                                                            start, end, false);
1643    
1644                                            Collections.sort(list);
1645    
1646                                            list = Collections.unmodifiableList(list);
1647                                    }
1648                                    else {
1649                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1650                                                            start, end);
1651                                    }
1652    
1653                                    cacheResult(list);
1654    
1655                                    finderCache.putResult(finderPath, finderArgs, list);
1656                            }
1657                            catch (Exception e) {
1658                                    finderCache.removeResult(finderPath, finderArgs);
1659    
1660                                    throw processException(e);
1661                            }
1662                            finally {
1663                                    closeSession(session);
1664                            }
1665                    }
1666    
1667                    return list;
1668            }
1669    
1670            /**
1671             * Returns the first document library file entry in the ordered set where groupId = &#63;.
1672             *
1673             * @param groupId the group ID
1674             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1675             * @return the first matching document library file entry
1676             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
1677             */
1678            @Override
1679            public DLFileEntry findByGroupId_First(long groupId,
1680                    OrderByComparator<DLFileEntry> orderByComparator)
1681                    throws NoSuchFileEntryException {
1682                    DLFileEntry dlFileEntry = fetchByGroupId_First(groupId,
1683                                    orderByComparator);
1684    
1685                    if (dlFileEntry != null) {
1686                            return dlFileEntry;
1687                    }
1688    
1689                    StringBundler msg = new StringBundler(4);
1690    
1691                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1692    
1693                    msg.append("groupId=");
1694                    msg.append(groupId);
1695    
1696                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1697    
1698                    throw new NoSuchFileEntryException(msg.toString());
1699            }
1700    
1701            /**
1702             * Returns the first document library file entry in the ordered set where groupId = &#63;.
1703             *
1704             * @param groupId the group ID
1705             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1706             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1707             */
1708            @Override
1709            public DLFileEntry fetchByGroupId_First(long groupId,
1710                    OrderByComparator<DLFileEntry> orderByComparator) {
1711                    List<DLFileEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1712    
1713                    if (!list.isEmpty()) {
1714                            return list.get(0);
1715                    }
1716    
1717                    return null;
1718            }
1719    
1720            /**
1721             * Returns the last document library file entry in the ordered set where groupId = &#63;.
1722             *
1723             * @param groupId the group ID
1724             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1725             * @return the last matching document library file entry
1726             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
1727             */
1728            @Override
1729            public DLFileEntry findByGroupId_Last(long groupId,
1730                    OrderByComparator<DLFileEntry> orderByComparator)
1731                    throws NoSuchFileEntryException {
1732                    DLFileEntry dlFileEntry = fetchByGroupId_Last(groupId, orderByComparator);
1733    
1734                    if (dlFileEntry != null) {
1735                            return dlFileEntry;
1736                    }
1737    
1738                    StringBundler msg = new StringBundler(4);
1739    
1740                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1741    
1742                    msg.append("groupId=");
1743                    msg.append(groupId);
1744    
1745                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1746    
1747                    throw new NoSuchFileEntryException(msg.toString());
1748            }
1749    
1750            /**
1751             * Returns the last document library file entry in the ordered set where groupId = &#63;.
1752             *
1753             * @param groupId the group ID
1754             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1755             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1756             */
1757            @Override
1758            public DLFileEntry fetchByGroupId_Last(long groupId,
1759                    OrderByComparator<DLFileEntry> orderByComparator) {
1760                    int count = countByGroupId(groupId);
1761    
1762                    if (count == 0) {
1763                            return null;
1764                    }
1765    
1766                    List<DLFileEntry> list = findByGroupId(groupId, count - 1, count,
1767                                    orderByComparator);
1768    
1769                    if (!list.isEmpty()) {
1770                            return list.get(0);
1771                    }
1772    
1773                    return null;
1774            }
1775    
1776            /**
1777             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63;.
1778             *
1779             * @param fileEntryId the primary key of the current document library file entry
1780             * @param groupId the group ID
1781             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1782             * @return the previous, current, and next document library file entry
1783             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
1784             */
1785            @Override
1786            public DLFileEntry[] findByGroupId_PrevAndNext(long fileEntryId,
1787                    long groupId, OrderByComparator<DLFileEntry> orderByComparator)
1788                    throws NoSuchFileEntryException {
1789                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1790    
1791                    Session session = null;
1792    
1793                    try {
1794                            session = openSession();
1795    
1796                            DLFileEntry[] array = new DLFileEntryImpl[3];
1797    
1798                            array[0] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1799                                            orderByComparator, true);
1800    
1801                            array[1] = dlFileEntry;
1802    
1803                            array[2] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1804                                            orderByComparator, false);
1805    
1806                            return array;
1807                    }
1808                    catch (Exception e) {
1809                            throw processException(e);
1810                    }
1811                    finally {
1812                            closeSession(session);
1813                    }
1814            }
1815    
1816            protected DLFileEntry getByGroupId_PrevAndNext(Session session,
1817                    DLFileEntry dlFileEntry, long groupId,
1818                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
1819                    StringBundler query = null;
1820    
1821                    if (orderByComparator != null) {
1822                            query = new StringBundler(6 +
1823                                            (orderByComparator.getOrderByFields().length * 6));
1824                    }
1825                    else {
1826                            query = new StringBundler(3);
1827                    }
1828    
1829                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1830    
1831                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1832    
1833                    if (orderByComparator != null) {
1834                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1835    
1836                            if (orderByConditionFields.length > 0) {
1837                                    query.append(WHERE_AND);
1838                            }
1839    
1840                            for (int i = 0; i < orderByConditionFields.length; i++) {
1841                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1842                                    query.append(orderByConditionFields[i]);
1843    
1844                                    if ((i + 1) < orderByConditionFields.length) {
1845                                            if (orderByComparator.isAscending() ^ previous) {
1846                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1847                                            }
1848                                            else {
1849                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1850                                            }
1851                                    }
1852                                    else {
1853                                            if (orderByComparator.isAscending() ^ previous) {
1854                                                    query.append(WHERE_GREATER_THAN);
1855                                            }
1856                                            else {
1857                                                    query.append(WHERE_LESSER_THAN);
1858                                            }
1859                                    }
1860                            }
1861    
1862                            query.append(ORDER_BY_CLAUSE);
1863    
1864                            String[] orderByFields = orderByComparator.getOrderByFields();
1865    
1866                            for (int i = 0; i < orderByFields.length; i++) {
1867                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1868                                    query.append(orderByFields[i]);
1869    
1870                                    if ((i + 1) < orderByFields.length) {
1871                                            if (orderByComparator.isAscending() ^ previous) {
1872                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1873                                            }
1874                                            else {
1875                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1876                                            }
1877                                    }
1878                                    else {
1879                                            if (orderByComparator.isAscending() ^ previous) {
1880                                                    query.append(ORDER_BY_ASC);
1881                                            }
1882                                            else {
1883                                                    query.append(ORDER_BY_DESC);
1884                                            }
1885                                    }
1886                            }
1887                    }
1888                    else {
1889                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1890                    }
1891    
1892                    String sql = query.toString();
1893    
1894                    Query q = session.createQuery(sql);
1895    
1896                    q.setFirstResult(0);
1897                    q.setMaxResults(2);
1898    
1899                    QueryPos qPos = QueryPos.getInstance(q);
1900    
1901                    qPos.add(groupId);
1902    
1903                    if (orderByComparator != null) {
1904                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
1905    
1906                            for (Object value : values) {
1907                                    qPos.add(value);
1908                            }
1909                    }
1910    
1911                    List<DLFileEntry> list = q.list();
1912    
1913                    if (list.size() == 2) {
1914                            return list.get(1);
1915                    }
1916                    else {
1917                            return null;
1918                    }
1919            }
1920    
1921            /**
1922             * Returns all the document library file entries that the user has permission to view where groupId = &#63;.
1923             *
1924             * @param groupId the group ID
1925             * @return the matching document library file entries that the user has permission to view
1926             */
1927            @Override
1928            public List<DLFileEntry> filterFindByGroupId(long groupId) {
1929                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1930                            QueryUtil.ALL_POS, null);
1931            }
1932    
1933            /**
1934             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63;.
1935             *
1936             * <p>
1937             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1938             * </p>
1939             *
1940             * @param groupId the group ID
1941             * @param start the lower bound of the range of document library file entries
1942             * @param end the upper bound of the range of document library file entries (not inclusive)
1943             * @return the range of matching document library file entries that the user has permission to view
1944             */
1945            @Override
1946            public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1947                    int end) {
1948                    return filterFindByGroupId(groupId, start, end, null);
1949            }
1950    
1951            /**
1952             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63;.
1953             *
1954             * <p>
1955             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1956             * </p>
1957             *
1958             * @param groupId the group ID
1959             * @param start the lower bound of the range of document library file entries
1960             * @param end the upper bound of the range of document library file entries (not inclusive)
1961             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1962             * @return the ordered range of matching document library file entries that the user has permission to view
1963             */
1964            @Override
1965            public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1966                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
1967                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1968                            return findByGroupId(groupId, start, end, orderByComparator);
1969                    }
1970    
1971                    StringBundler query = null;
1972    
1973                    if (orderByComparator != null) {
1974                            query = new StringBundler(3 +
1975                                            (orderByComparator.getOrderByFields().length * 3));
1976                    }
1977                    else {
1978                            query = new StringBundler(3);
1979                    }
1980    
1981                    if (getDB().isSupportsInlineDistinct()) {
1982                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
1983                    }
1984                    else {
1985                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
1986                    }
1987    
1988                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1989    
1990                    if (!getDB().isSupportsInlineDistinct()) {
1991                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
1992                    }
1993    
1994                    if (orderByComparator != null) {
1995                            if (getDB().isSupportsInlineDistinct()) {
1996                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1997                                            orderByComparator, true);
1998                            }
1999                            else {
2000                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2001                                            orderByComparator, true);
2002                            }
2003                    }
2004                    else {
2005                            if (getDB().isSupportsInlineDistinct()) {
2006                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2007                            }
2008                            else {
2009                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
2010                            }
2011                    }
2012    
2013                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2014                                    DLFileEntry.class.getName(),
2015                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2016    
2017                    Session session = null;
2018    
2019                    try {
2020                            session = openSession();
2021    
2022                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2023    
2024                            if (getDB().isSupportsInlineDistinct()) {
2025                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
2026                            }
2027                            else {
2028                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
2029                            }
2030    
2031                            QueryPos qPos = QueryPos.getInstance(q);
2032    
2033                            qPos.add(groupId);
2034    
2035                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
2036                    }
2037                    catch (Exception e) {
2038                            throw processException(e);
2039                    }
2040                    finally {
2041                            closeSession(session);
2042                    }
2043            }
2044    
2045            /**
2046             * 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;.
2047             *
2048             * @param fileEntryId the primary key of the current document library file entry
2049             * @param groupId the group ID
2050             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2051             * @return the previous, current, and next document library file entry
2052             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
2053             */
2054            @Override
2055            public DLFileEntry[] filterFindByGroupId_PrevAndNext(long fileEntryId,
2056                    long groupId, OrderByComparator<DLFileEntry> orderByComparator)
2057                    throws NoSuchFileEntryException {
2058                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2059                            return findByGroupId_PrevAndNext(fileEntryId, groupId,
2060                                    orderByComparator);
2061                    }
2062    
2063                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2064    
2065                    Session session = null;
2066    
2067                    try {
2068                            session = openSession();
2069    
2070                            DLFileEntry[] array = new DLFileEntryImpl[3];
2071    
2072                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFileEntry,
2073                                            groupId, orderByComparator, true);
2074    
2075                            array[1] = dlFileEntry;
2076    
2077                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFileEntry,
2078                                            groupId, orderByComparator, false);
2079    
2080                            return array;
2081                    }
2082                    catch (Exception e) {
2083                            throw processException(e);
2084                    }
2085                    finally {
2086                            closeSession(session);
2087                    }
2088            }
2089    
2090            protected DLFileEntry filterGetByGroupId_PrevAndNext(Session session,
2091                    DLFileEntry dlFileEntry, long groupId,
2092                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
2093                    StringBundler query = null;
2094    
2095                    if (orderByComparator != null) {
2096                            query = new StringBundler(6 +
2097                                            (orderByComparator.getOrderByFields().length * 6));
2098                    }
2099                    else {
2100                            query = new StringBundler(3);
2101                    }
2102    
2103                    if (getDB().isSupportsInlineDistinct()) {
2104                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
2105                    }
2106                    else {
2107                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
2108                    }
2109    
2110                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2111    
2112                    if (!getDB().isSupportsInlineDistinct()) {
2113                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
2114                    }
2115    
2116                    if (orderByComparator != null) {
2117                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2118    
2119                            if (orderByConditionFields.length > 0) {
2120                                    query.append(WHERE_AND);
2121                            }
2122    
2123                            for (int i = 0; i < orderByConditionFields.length; i++) {
2124                                    if (getDB().isSupportsInlineDistinct()) {
2125                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2126                                    }
2127                                    else {
2128                                            query.append(_ORDER_BY_ENTITY_TABLE);
2129                                    }
2130    
2131                                    query.append(orderByConditionFields[i]);
2132    
2133                                    if ((i + 1) < orderByConditionFields.length) {
2134                                            if (orderByComparator.isAscending() ^ previous) {
2135                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2136                                            }
2137                                            else {
2138                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2139                                            }
2140                                    }
2141                                    else {
2142                                            if (orderByComparator.isAscending() ^ previous) {
2143                                                    query.append(WHERE_GREATER_THAN);
2144                                            }
2145                                            else {
2146                                                    query.append(WHERE_LESSER_THAN);
2147                                            }
2148                                    }
2149                            }
2150    
2151                            query.append(ORDER_BY_CLAUSE);
2152    
2153                            String[] orderByFields = orderByComparator.getOrderByFields();
2154    
2155                            for (int i = 0; i < orderByFields.length; i++) {
2156                                    if (getDB().isSupportsInlineDistinct()) {
2157                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2158                                    }
2159                                    else {
2160                                            query.append(_ORDER_BY_ENTITY_TABLE);
2161                                    }
2162    
2163                                    query.append(orderByFields[i]);
2164    
2165                                    if ((i + 1) < orderByFields.length) {
2166                                            if (orderByComparator.isAscending() ^ previous) {
2167                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2168                                            }
2169                                            else {
2170                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2171                                            }
2172                                    }
2173                                    else {
2174                                            if (orderByComparator.isAscending() ^ previous) {
2175                                                    query.append(ORDER_BY_ASC);
2176                                            }
2177                                            else {
2178                                                    query.append(ORDER_BY_DESC);
2179                                            }
2180                                    }
2181                            }
2182                    }
2183                    else {
2184                            if (getDB().isSupportsInlineDistinct()) {
2185                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2186                            }
2187                            else {
2188                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
2189                            }
2190                    }
2191    
2192                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2193                                    DLFileEntry.class.getName(),
2194                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2195    
2196                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2197    
2198                    q.setFirstResult(0);
2199                    q.setMaxResults(2);
2200    
2201                    if (getDB().isSupportsInlineDistinct()) {
2202                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
2203                    }
2204                    else {
2205                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
2206                    }
2207    
2208                    QueryPos qPos = QueryPos.getInstance(q);
2209    
2210                    qPos.add(groupId);
2211    
2212                    if (orderByComparator != null) {
2213                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2214    
2215                            for (Object value : values) {
2216                                    qPos.add(value);
2217                            }
2218                    }
2219    
2220                    List<DLFileEntry> list = q.list();
2221    
2222                    if (list.size() == 2) {
2223                            return list.get(1);
2224                    }
2225                    else {
2226                            return null;
2227                    }
2228            }
2229    
2230            /**
2231             * Removes all the document library file entries where groupId = &#63; from the database.
2232             *
2233             * @param groupId the group ID
2234             */
2235            @Override
2236            public void removeByGroupId(long groupId) {
2237                    for (DLFileEntry dlFileEntry : findByGroupId(groupId,
2238                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2239                            remove(dlFileEntry);
2240                    }
2241            }
2242    
2243            /**
2244             * Returns the number of document library file entries where groupId = &#63;.
2245             *
2246             * @param groupId the group ID
2247             * @return the number of matching document library file entries
2248             */
2249            @Override
2250            public int countByGroupId(long groupId) {
2251                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2252    
2253                    Object[] finderArgs = new Object[] { groupId };
2254    
2255                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2256    
2257                    if (count == null) {
2258                            StringBundler query = new StringBundler(2);
2259    
2260                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
2261    
2262                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2263    
2264                            String sql = query.toString();
2265    
2266                            Session session = null;
2267    
2268                            try {
2269                                    session = openSession();
2270    
2271                                    Query q = session.createQuery(sql);
2272    
2273                                    QueryPos qPos = QueryPos.getInstance(q);
2274    
2275                                    qPos.add(groupId);
2276    
2277                                    count = (Long)q.uniqueResult();
2278    
2279                                    finderCache.putResult(finderPath, finderArgs, count);
2280                            }
2281                            catch (Exception e) {
2282                                    finderCache.removeResult(finderPath, finderArgs);
2283    
2284                                    throw processException(e);
2285                            }
2286                            finally {
2287                                    closeSession(session);
2288                            }
2289                    }
2290    
2291                    return count.intValue();
2292            }
2293    
2294            /**
2295             * Returns the number of document library file entries that the user has permission to view where groupId = &#63;.
2296             *
2297             * @param groupId the group ID
2298             * @return the number of matching document library file entries that the user has permission to view
2299             */
2300            @Override
2301            public int filterCountByGroupId(long groupId) {
2302                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2303                            return countByGroupId(groupId);
2304                    }
2305    
2306                    StringBundler query = new StringBundler(2);
2307    
2308                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
2309    
2310                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2311    
2312                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2313                                    DLFileEntry.class.getName(),
2314                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2315    
2316                    Session session = null;
2317    
2318                    try {
2319                            session = openSession();
2320    
2321                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2322    
2323                            q.addScalar(COUNT_COLUMN_NAME,
2324                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2325    
2326                            QueryPos qPos = QueryPos.getInstance(q);
2327    
2328                            qPos.add(groupId);
2329    
2330                            Long count = (Long)q.uniqueResult();
2331    
2332                            return count.intValue();
2333                    }
2334                    catch (Exception e) {
2335                            throw processException(e);
2336                    }
2337                    finally {
2338                            closeSession(session);
2339                    }
2340            }
2341    
2342            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntry.groupId = ?";
2343            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2344                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2345                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
2346                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2347                            new String[] {
2348                                    Long.class.getName(),
2349                                    
2350                            Integer.class.getName(), Integer.class.getName(),
2351                                    OrderByComparator.class.getName()
2352                            });
2353            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2354                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2355                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
2356                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2357                            new String[] { Long.class.getName() },
2358                            DLFileEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2359                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
2360                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
2361            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2362                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2363                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2364                            new String[] { Long.class.getName() });
2365    
2366            /**
2367             * Returns all the document library file entries where companyId = &#63;.
2368             *
2369             * @param companyId the company ID
2370             * @return the matching document library file entries
2371             */
2372            @Override
2373            public List<DLFileEntry> findByCompanyId(long companyId) {
2374                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2375                            null);
2376            }
2377    
2378            /**
2379             * Returns a range of all the document library file entries where companyId = &#63;.
2380             *
2381             * <p>
2382             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2383             * </p>
2384             *
2385             * @param companyId the company ID
2386             * @param start the lower bound of the range of document library file entries
2387             * @param end the upper bound of the range of document library file entries (not inclusive)
2388             * @return the range of matching document library file entries
2389             */
2390            @Override
2391            public List<DLFileEntry> findByCompanyId(long companyId, int start, int end) {
2392                    return findByCompanyId(companyId, start, end, null);
2393            }
2394    
2395            /**
2396             * Returns an ordered range of all the document library file entries where companyId = &#63;.
2397             *
2398             * <p>
2399             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2400             * </p>
2401             *
2402             * @param companyId the company ID
2403             * @param start the lower bound of the range of document library file entries
2404             * @param end the upper bound of the range of document library file entries (not inclusive)
2405             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2406             * @return the ordered range of matching document library file entries
2407             */
2408            @Override
2409            public List<DLFileEntry> findByCompanyId(long companyId, int start,
2410                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
2411                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2412            }
2413    
2414            /**
2415             * Returns an ordered range of all the document library file entries where companyId = &#63;.
2416             *
2417             * <p>
2418             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2419             * </p>
2420             *
2421             * @param companyId the company ID
2422             * @param start the lower bound of the range of document library file entries
2423             * @param end the upper bound of the range of document library file entries (not inclusive)
2424             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2425             * @param retrieveFromCache whether to retrieve from the finder cache
2426             * @return the ordered range of matching document library file entries
2427             */
2428            @Override
2429            public List<DLFileEntry> findByCompanyId(long companyId, int start,
2430                    int end, OrderByComparator<DLFileEntry> orderByComparator,
2431                    boolean retrieveFromCache) {
2432                    boolean pagination = true;
2433                    FinderPath finderPath = null;
2434                    Object[] finderArgs = null;
2435    
2436                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2437                                    (orderByComparator == null)) {
2438                            pagination = false;
2439                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2440                            finderArgs = new Object[] { companyId };
2441                    }
2442                    else {
2443                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2444                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2445                    }
2446    
2447                    List<DLFileEntry> list = null;
2448    
2449                    if (retrieveFromCache) {
2450                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
2451                                            finderArgs, this);
2452    
2453                            if ((list != null) && !list.isEmpty()) {
2454                                    for (DLFileEntry dlFileEntry : list) {
2455                                            if ((companyId != dlFileEntry.getCompanyId())) {
2456                                                    list = null;
2457    
2458                                                    break;
2459                                            }
2460                                    }
2461                            }
2462                    }
2463    
2464                    if (list == null) {
2465                            StringBundler query = null;
2466    
2467                            if (orderByComparator != null) {
2468                                    query = new StringBundler(3 +
2469                                                    (orderByComparator.getOrderByFields().length * 3));
2470                            }
2471                            else {
2472                                    query = new StringBundler(3);
2473                            }
2474    
2475                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2476    
2477                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2478    
2479                            if (orderByComparator != null) {
2480                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2481                                            orderByComparator);
2482                            }
2483                            else
2484                             if (pagination) {
2485                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2486                            }
2487    
2488                            String sql = query.toString();
2489    
2490                            Session session = null;
2491    
2492                            try {
2493                                    session = openSession();
2494    
2495                                    Query q = session.createQuery(sql);
2496    
2497                                    QueryPos qPos = QueryPos.getInstance(q);
2498    
2499                                    qPos.add(companyId);
2500    
2501                                    if (!pagination) {
2502                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2503                                                            start, end, false);
2504    
2505                                            Collections.sort(list);
2506    
2507                                            list = Collections.unmodifiableList(list);
2508                                    }
2509                                    else {
2510                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2511                                                            start, end);
2512                                    }
2513    
2514                                    cacheResult(list);
2515    
2516                                    finderCache.putResult(finderPath, finderArgs, list);
2517                            }
2518                            catch (Exception e) {
2519                                    finderCache.removeResult(finderPath, finderArgs);
2520    
2521                                    throw processException(e);
2522                            }
2523                            finally {
2524                                    closeSession(session);
2525                            }
2526                    }
2527    
2528                    return list;
2529            }
2530    
2531            /**
2532             * Returns the first document library file entry in the ordered set where companyId = &#63;.
2533             *
2534             * @param companyId the company ID
2535             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2536             * @return the first matching document library file entry
2537             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
2538             */
2539            @Override
2540            public DLFileEntry findByCompanyId_First(long companyId,
2541                    OrderByComparator<DLFileEntry> orderByComparator)
2542                    throws NoSuchFileEntryException {
2543                    DLFileEntry dlFileEntry = fetchByCompanyId_First(companyId,
2544                                    orderByComparator);
2545    
2546                    if (dlFileEntry != null) {
2547                            return dlFileEntry;
2548                    }
2549    
2550                    StringBundler msg = new StringBundler(4);
2551    
2552                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2553    
2554                    msg.append("companyId=");
2555                    msg.append(companyId);
2556    
2557                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2558    
2559                    throw new NoSuchFileEntryException(msg.toString());
2560            }
2561    
2562            /**
2563             * Returns the first document library file entry in the ordered set where companyId = &#63;.
2564             *
2565             * @param companyId the company ID
2566             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2567             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
2568             */
2569            @Override
2570            public DLFileEntry fetchByCompanyId_First(long companyId,
2571                    OrderByComparator<DLFileEntry> orderByComparator) {
2572                    List<DLFileEntry> list = findByCompanyId(companyId, 0, 1,
2573                                    orderByComparator);
2574    
2575                    if (!list.isEmpty()) {
2576                            return list.get(0);
2577                    }
2578    
2579                    return null;
2580            }
2581    
2582            /**
2583             * Returns the last document library file entry in the ordered set where companyId = &#63;.
2584             *
2585             * @param companyId the company ID
2586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2587             * @return the last matching document library file entry
2588             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
2589             */
2590            @Override
2591            public DLFileEntry findByCompanyId_Last(long companyId,
2592                    OrderByComparator<DLFileEntry> orderByComparator)
2593                    throws NoSuchFileEntryException {
2594                    DLFileEntry dlFileEntry = fetchByCompanyId_Last(companyId,
2595                                    orderByComparator);
2596    
2597                    if (dlFileEntry != null) {
2598                            return dlFileEntry;
2599                    }
2600    
2601                    StringBundler msg = new StringBundler(4);
2602    
2603                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2604    
2605                    msg.append("companyId=");
2606                    msg.append(companyId);
2607    
2608                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2609    
2610                    throw new NoSuchFileEntryException(msg.toString());
2611            }
2612    
2613            /**
2614             * Returns the last document library file entry in the ordered set where companyId = &#63;.
2615             *
2616             * @param companyId the company ID
2617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2618             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
2619             */
2620            @Override
2621            public DLFileEntry fetchByCompanyId_Last(long companyId,
2622                    OrderByComparator<DLFileEntry> orderByComparator) {
2623                    int count = countByCompanyId(companyId);
2624    
2625                    if (count == 0) {
2626                            return null;
2627                    }
2628    
2629                    List<DLFileEntry> list = findByCompanyId(companyId, count - 1, count,
2630                                    orderByComparator);
2631    
2632                    if (!list.isEmpty()) {
2633                            return list.get(0);
2634                    }
2635    
2636                    return null;
2637            }
2638    
2639            /**
2640             * Returns the document library file entries before and after the current document library file entry in the ordered set where companyId = &#63;.
2641             *
2642             * @param fileEntryId the primary key of the current document library file entry
2643             * @param companyId the company ID
2644             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2645             * @return the previous, current, and next document library file entry
2646             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
2647             */
2648            @Override
2649            public DLFileEntry[] findByCompanyId_PrevAndNext(long fileEntryId,
2650                    long companyId, OrderByComparator<DLFileEntry> orderByComparator)
2651                    throws NoSuchFileEntryException {
2652                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2653    
2654                    Session session = null;
2655    
2656                    try {
2657                            session = openSession();
2658    
2659                            DLFileEntry[] array = new DLFileEntryImpl[3];
2660    
2661                            array[0] = getByCompanyId_PrevAndNext(session, dlFileEntry,
2662                                            companyId, orderByComparator, true);
2663    
2664                            array[1] = dlFileEntry;
2665    
2666                            array[2] = getByCompanyId_PrevAndNext(session, dlFileEntry,
2667                                            companyId, orderByComparator, false);
2668    
2669                            return array;
2670                    }
2671                    catch (Exception e) {
2672                            throw processException(e);
2673                    }
2674                    finally {
2675                            closeSession(session);
2676                    }
2677            }
2678    
2679            protected DLFileEntry getByCompanyId_PrevAndNext(Session session,
2680                    DLFileEntry dlFileEntry, long companyId,
2681                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
2682                    StringBundler query = null;
2683    
2684                    if (orderByComparator != null) {
2685                            query = new StringBundler(6 +
2686                                            (orderByComparator.getOrderByFields().length * 6));
2687                    }
2688                    else {
2689                            query = new StringBundler(3);
2690                    }
2691    
2692                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2693    
2694                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2695    
2696                    if (orderByComparator != null) {
2697                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2698    
2699                            if (orderByConditionFields.length > 0) {
2700                                    query.append(WHERE_AND);
2701                            }
2702    
2703                            for (int i = 0; i < orderByConditionFields.length; i++) {
2704                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2705                                    query.append(orderByConditionFields[i]);
2706    
2707                                    if ((i + 1) < orderByConditionFields.length) {
2708                                            if (orderByComparator.isAscending() ^ previous) {
2709                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2710                                            }
2711                                            else {
2712                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2713                                            }
2714                                    }
2715                                    else {
2716                                            if (orderByComparator.isAscending() ^ previous) {
2717                                                    query.append(WHERE_GREATER_THAN);
2718                                            }
2719                                            else {
2720                                                    query.append(WHERE_LESSER_THAN);
2721                                            }
2722                                    }
2723                            }
2724    
2725                            query.append(ORDER_BY_CLAUSE);
2726    
2727                            String[] orderByFields = orderByComparator.getOrderByFields();
2728    
2729                            for (int i = 0; i < orderByFields.length; i++) {
2730                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2731                                    query.append(orderByFields[i]);
2732    
2733                                    if ((i + 1) < orderByFields.length) {
2734                                            if (orderByComparator.isAscending() ^ previous) {
2735                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2736                                            }
2737                                            else {
2738                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2739                                            }
2740                                    }
2741                                    else {
2742                                            if (orderByComparator.isAscending() ^ previous) {
2743                                                    query.append(ORDER_BY_ASC);
2744                                            }
2745                                            else {
2746                                                    query.append(ORDER_BY_DESC);
2747                                            }
2748                                    }
2749                            }
2750                    }
2751                    else {
2752                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2753                    }
2754    
2755                    String sql = query.toString();
2756    
2757                    Query q = session.createQuery(sql);
2758    
2759                    q.setFirstResult(0);
2760                    q.setMaxResults(2);
2761    
2762                    QueryPos qPos = QueryPos.getInstance(q);
2763    
2764                    qPos.add(companyId);
2765    
2766                    if (orderByComparator != null) {
2767                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2768    
2769                            for (Object value : values) {
2770                                    qPos.add(value);
2771                            }
2772                    }
2773    
2774                    List<DLFileEntry> list = q.list();
2775    
2776                    if (list.size() == 2) {
2777                            return list.get(1);
2778                    }
2779                    else {
2780                            return null;
2781                    }
2782            }
2783    
2784            /**
2785             * Removes all the document library file entries where companyId = &#63; from the database.
2786             *
2787             * @param companyId the company ID
2788             */
2789            @Override
2790            public void removeByCompanyId(long companyId) {
2791                    for (DLFileEntry dlFileEntry : findByCompanyId(companyId,
2792                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2793                            remove(dlFileEntry);
2794                    }
2795            }
2796    
2797            /**
2798             * Returns the number of document library file entries where companyId = &#63;.
2799             *
2800             * @param companyId the company ID
2801             * @return the number of matching document library file entries
2802             */
2803            @Override
2804            public int countByCompanyId(long companyId) {
2805                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2806    
2807                    Object[] finderArgs = new Object[] { companyId };
2808    
2809                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2810    
2811                    if (count == null) {
2812                            StringBundler query = new StringBundler(2);
2813    
2814                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
2815    
2816                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2817    
2818                            String sql = query.toString();
2819    
2820                            Session session = null;
2821    
2822                            try {
2823                                    session = openSession();
2824    
2825                                    Query q = session.createQuery(sql);
2826    
2827                                    QueryPos qPos = QueryPos.getInstance(q);
2828    
2829                                    qPos.add(companyId);
2830    
2831                                    count = (Long)q.uniqueResult();
2832    
2833                                    finderCache.putResult(finderPath, finderArgs, count);
2834                            }
2835                            catch (Exception e) {
2836                                    finderCache.removeResult(finderPath, finderArgs);
2837    
2838                                    throw processException(e);
2839                            }
2840                            finally {
2841                                    closeSession(session);
2842                            }
2843                    }
2844    
2845                    return count.intValue();
2846            }
2847    
2848            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFileEntry.companyId = ?";
2849            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID =
2850                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2851                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
2852                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRepositoryId",
2853                            new String[] {
2854                                    Long.class.getName(),
2855                                    
2856                            Integer.class.getName(), Integer.class.getName(),
2857                                    OrderByComparator.class.getName()
2858                            });
2859            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID =
2860                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2861                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
2862                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRepositoryId",
2863                            new String[] { Long.class.getName() },
2864                            DLFileEntryModelImpl.REPOSITORYID_COLUMN_BITMASK |
2865                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
2866                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
2867            public static final FinderPath FINDER_PATH_COUNT_BY_REPOSITORYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
2868                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2869                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRepositoryId",
2870                            new String[] { Long.class.getName() });
2871    
2872            /**
2873             * Returns all the document library file entries where repositoryId = &#63;.
2874             *
2875             * @param repositoryId the repository ID
2876             * @return the matching document library file entries
2877             */
2878            @Override
2879            public List<DLFileEntry> findByRepositoryId(long repositoryId) {
2880                    return findByRepositoryId(repositoryId, QueryUtil.ALL_POS,
2881                            QueryUtil.ALL_POS, null);
2882            }
2883    
2884            /**
2885             * Returns a range of all the document library file entries where repositoryId = &#63;.
2886             *
2887             * <p>
2888             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2889             * </p>
2890             *
2891             * @param repositoryId the repository ID
2892             * @param start the lower bound of the range of document library file entries
2893             * @param end the upper bound of the range of document library file entries (not inclusive)
2894             * @return the range of matching document library file entries
2895             */
2896            @Override
2897            public List<DLFileEntry> findByRepositoryId(long repositoryId, int start,
2898                    int end) {
2899                    return findByRepositoryId(repositoryId, start, end, null);
2900            }
2901    
2902            /**
2903             * Returns an ordered range of all the document library file entries where repositoryId = &#63;.
2904             *
2905             * <p>
2906             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2907             * </p>
2908             *
2909             * @param repositoryId the repository ID
2910             * @param start the lower bound of the range of document library file entries
2911             * @param end the upper bound of the range of document library file entries (not inclusive)
2912             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2913             * @return the ordered range of matching document library file entries
2914             */
2915            @Override
2916            public List<DLFileEntry> findByRepositoryId(long repositoryId, int start,
2917                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
2918                    return findByRepositoryId(repositoryId, start, end, orderByComparator,
2919                            true);
2920            }
2921    
2922            /**
2923             * Returns an ordered range of all the document library file entries where repositoryId = &#63;.
2924             *
2925             * <p>
2926             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2927             * </p>
2928             *
2929             * @param repositoryId the repository ID
2930             * @param start the lower bound of the range of document library file entries
2931             * @param end the upper bound of the range of document library file entries (not inclusive)
2932             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2933             * @param retrieveFromCache whether to retrieve from the finder cache
2934             * @return the ordered range of matching document library file entries
2935             */
2936            @Override
2937            public List<DLFileEntry> findByRepositoryId(long repositoryId, int start,
2938                    int end, OrderByComparator<DLFileEntry> orderByComparator,
2939                    boolean retrieveFromCache) {
2940                    boolean pagination = true;
2941                    FinderPath finderPath = null;
2942                    Object[] finderArgs = null;
2943    
2944                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2945                                    (orderByComparator == null)) {
2946                            pagination = false;
2947                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID;
2948                            finderArgs = new Object[] { repositoryId };
2949                    }
2950                    else {
2951                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID;
2952                            finderArgs = new Object[] {
2953                                            repositoryId,
2954                                            
2955                                            start, end, orderByComparator
2956                                    };
2957                    }
2958    
2959                    List<DLFileEntry> list = null;
2960    
2961                    if (retrieveFromCache) {
2962                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
2963                                            finderArgs, this);
2964    
2965                            if ((list != null) && !list.isEmpty()) {
2966                                    for (DLFileEntry dlFileEntry : list) {
2967                                            if ((repositoryId != dlFileEntry.getRepositoryId())) {
2968                                                    list = null;
2969    
2970                                                    break;
2971                                            }
2972                                    }
2973                            }
2974                    }
2975    
2976                    if (list == null) {
2977                            StringBundler query = null;
2978    
2979                            if (orderByComparator != null) {
2980                                    query = new StringBundler(3 +
2981                                                    (orderByComparator.getOrderByFields().length * 3));
2982                            }
2983                            else {
2984                                    query = new StringBundler(3);
2985                            }
2986    
2987                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2988    
2989                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
2990    
2991                            if (orderByComparator != null) {
2992                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2993                                            orderByComparator);
2994                            }
2995                            else
2996                             if (pagination) {
2997                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2998                            }
2999    
3000                            String sql = query.toString();
3001    
3002                            Session session = null;
3003    
3004                            try {
3005                                    session = openSession();
3006    
3007                                    Query q = session.createQuery(sql);
3008    
3009                                    QueryPos qPos = QueryPos.getInstance(q);
3010    
3011                                    qPos.add(repositoryId);
3012    
3013                                    if (!pagination) {
3014                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3015                                                            start, end, false);
3016    
3017                                            Collections.sort(list);
3018    
3019                                            list = Collections.unmodifiableList(list);
3020                                    }
3021                                    else {
3022                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3023                                                            start, end);
3024                                    }
3025    
3026                                    cacheResult(list);
3027    
3028                                    finderCache.putResult(finderPath, finderArgs, list);
3029                            }
3030                            catch (Exception e) {
3031                                    finderCache.removeResult(finderPath, finderArgs);
3032    
3033                                    throw processException(e);
3034                            }
3035                            finally {
3036                                    closeSession(session);
3037                            }
3038                    }
3039    
3040                    return list;
3041            }
3042    
3043            /**
3044             * Returns the first document library file entry in the ordered set where repositoryId = &#63;.
3045             *
3046             * @param repositoryId the repository ID
3047             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3048             * @return the first matching document library file entry
3049             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
3050             */
3051            @Override
3052            public DLFileEntry findByRepositoryId_First(long repositoryId,
3053                    OrderByComparator<DLFileEntry> orderByComparator)
3054                    throws NoSuchFileEntryException {
3055                    DLFileEntry dlFileEntry = fetchByRepositoryId_First(repositoryId,
3056                                    orderByComparator);
3057    
3058                    if (dlFileEntry != null) {
3059                            return dlFileEntry;
3060                    }
3061    
3062                    StringBundler msg = new StringBundler(4);
3063    
3064                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3065    
3066                    msg.append("repositoryId=");
3067                    msg.append(repositoryId);
3068    
3069                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3070    
3071                    throw new NoSuchFileEntryException(msg.toString());
3072            }
3073    
3074            /**
3075             * Returns the first document library file entry in the ordered set where repositoryId = &#63;.
3076             *
3077             * @param repositoryId the repository ID
3078             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3079             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
3080             */
3081            @Override
3082            public DLFileEntry fetchByRepositoryId_First(long repositoryId,
3083                    OrderByComparator<DLFileEntry> orderByComparator) {
3084                    List<DLFileEntry> list = findByRepositoryId(repositoryId, 0, 1,
3085                                    orderByComparator);
3086    
3087                    if (!list.isEmpty()) {
3088                            return list.get(0);
3089                    }
3090    
3091                    return null;
3092            }
3093    
3094            /**
3095             * Returns the last document library file entry in the ordered set where repositoryId = &#63;.
3096             *
3097             * @param repositoryId the repository ID
3098             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3099             * @return the last matching document library file entry
3100             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
3101             */
3102            @Override
3103            public DLFileEntry findByRepositoryId_Last(long repositoryId,
3104                    OrderByComparator<DLFileEntry> orderByComparator)
3105                    throws NoSuchFileEntryException {
3106                    DLFileEntry dlFileEntry = fetchByRepositoryId_Last(repositoryId,
3107                                    orderByComparator);
3108    
3109                    if (dlFileEntry != null) {
3110                            return dlFileEntry;
3111                    }
3112    
3113                    StringBundler msg = new StringBundler(4);
3114    
3115                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3116    
3117                    msg.append("repositoryId=");
3118                    msg.append(repositoryId);
3119    
3120                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3121    
3122                    throw new NoSuchFileEntryException(msg.toString());
3123            }
3124    
3125            /**
3126             * Returns the last document library file entry in the ordered set where repositoryId = &#63;.
3127             *
3128             * @param repositoryId the repository ID
3129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3130             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
3131             */
3132            @Override
3133            public DLFileEntry fetchByRepositoryId_Last(long repositoryId,
3134                    OrderByComparator<DLFileEntry> orderByComparator) {
3135                    int count = countByRepositoryId(repositoryId);
3136    
3137                    if (count == 0) {
3138                            return null;
3139                    }
3140    
3141                    List<DLFileEntry> list = findByRepositoryId(repositoryId, count - 1,
3142                                    count, orderByComparator);
3143    
3144                    if (!list.isEmpty()) {
3145                            return list.get(0);
3146                    }
3147    
3148                    return null;
3149            }
3150    
3151            /**
3152             * Returns the document library file entries before and after the current document library file entry in the ordered set where repositoryId = &#63;.
3153             *
3154             * @param fileEntryId the primary key of the current document library file entry
3155             * @param repositoryId the repository ID
3156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3157             * @return the previous, current, and next document library file entry
3158             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
3159             */
3160            @Override
3161            public DLFileEntry[] findByRepositoryId_PrevAndNext(long fileEntryId,
3162                    long repositoryId, OrderByComparator<DLFileEntry> orderByComparator)
3163                    throws NoSuchFileEntryException {
3164                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3165    
3166                    Session session = null;
3167    
3168                    try {
3169                            session = openSession();
3170    
3171                            DLFileEntry[] array = new DLFileEntryImpl[3];
3172    
3173                            array[0] = getByRepositoryId_PrevAndNext(session, dlFileEntry,
3174                                            repositoryId, orderByComparator, true);
3175    
3176                            array[1] = dlFileEntry;
3177    
3178                            array[2] = getByRepositoryId_PrevAndNext(session, dlFileEntry,
3179                                            repositoryId, orderByComparator, false);
3180    
3181                            return array;
3182                    }
3183                    catch (Exception e) {
3184                            throw processException(e);
3185                    }
3186                    finally {
3187                            closeSession(session);
3188                    }
3189            }
3190    
3191            protected DLFileEntry getByRepositoryId_PrevAndNext(Session session,
3192                    DLFileEntry dlFileEntry, long repositoryId,
3193                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
3194                    StringBundler query = null;
3195    
3196                    if (orderByComparator != null) {
3197                            query = new StringBundler(6 +
3198                                            (orderByComparator.getOrderByFields().length * 6));
3199                    }
3200                    else {
3201                            query = new StringBundler(3);
3202                    }
3203    
3204                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3205    
3206                    query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
3207    
3208                    if (orderByComparator != null) {
3209                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3210    
3211                            if (orderByConditionFields.length > 0) {
3212                                    query.append(WHERE_AND);
3213                            }
3214    
3215                            for (int i = 0; i < orderByConditionFields.length; i++) {
3216                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3217                                    query.append(orderByConditionFields[i]);
3218    
3219                                    if ((i + 1) < orderByConditionFields.length) {
3220                                            if (orderByComparator.isAscending() ^ previous) {
3221                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3222                                            }
3223                                            else {
3224                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3225                                            }
3226                                    }
3227                                    else {
3228                                            if (orderByComparator.isAscending() ^ previous) {
3229                                                    query.append(WHERE_GREATER_THAN);
3230                                            }
3231                                            else {
3232                                                    query.append(WHERE_LESSER_THAN);
3233                                            }
3234                                    }
3235                            }
3236    
3237                            query.append(ORDER_BY_CLAUSE);
3238    
3239                            String[] orderByFields = orderByComparator.getOrderByFields();
3240    
3241                            for (int i = 0; i < orderByFields.length; i++) {
3242                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3243                                    query.append(orderByFields[i]);
3244    
3245                                    if ((i + 1) < orderByFields.length) {
3246                                            if (orderByComparator.isAscending() ^ previous) {
3247                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3248                                            }
3249                                            else {
3250                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3251                                            }
3252                                    }
3253                                    else {
3254                                            if (orderByComparator.isAscending() ^ previous) {
3255                                                    query.append(ORDER_BY_ASC);
3256                                            }
3257                                            else {
3258                                                    query.append(ORDER_BY_DESC);
3259                                            }
3260                                    }
3261                            }
3262                    }
3263                    else {
3264                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3265                    }
3266    
3267                    String sql = query.toString();
3268    
3269                    Query q = session.createQuery(sql);
3270    
3271                    q.setFirstResult(0);
3272                    q.setMaxResults(2);
3273    
3274                    QueryPos qPos = QueryPos.getInstance(q);
3275    
3276                    qPos.add(repositoryId);
3277    
3278                    if (orderByComparator != null) {
3279                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3280    
3281                            for (Object value : values) {
3282                                    qPos.add(value);
3283                            }
3284                    }
3285    
3286                    List<DLFileEntry> list = q.list();
3287    
3288                    if (list.size() == 2) {
3289                            return list.get(1);
3290                    }
3291                    else {
3292                            return null;
3293                    }
3294            }
3295    
3296            /**
3297             * Removes all the document library file entries where repositoryId = &#63; from the database.
3298             *
3299             * @param repositoryId the repository ID
3300             */
3301            @Override
3302            public void removeByRepositoryId(long repositoryId) {
3303                    for (DLFileEntry dlFileEntry : findByRepositoryId(repositoryId,
3304                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3305                            remove(dlFileEntry);
3306                    }
3307            }
3308    
3309            /**
3310             * Returns the number of document library file entries where repositoryId = &#63;.
3311             *
3312             * @param repositoryId the repository ID
3313             * @return the number of matching document library file entries
3314             */
3315            @Override
3316            public int countByRepositoryId(long repositoryId) {
3317                    FinderPath finderPath = FINDER_PATH_COUNT_BY_REPOSITORYID;
3318    
3319                    Object[] finderArgs = new Object[] { repositoryId };
3320    
3321                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3322    
3323                    if (count == null) {
3324                            StringBundler query = new StringBundler(2);
3325    
3326                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
3327    
3328                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
3329    
3330                            String sql = query.toString();
3331    
3332                            Session session = null;
3333    
3334                            try {
3335                                    session = openSession();
3336    
3337                                    Query q = session.createQuery(sql);
3338    
3339                                    QueryPos qPos = QueryPos.getInstance(q);
3340    
3341                                    qPos.add(repositoryId);
3342    
3343                                    count = (Long)q.uniqueResult();
3344    
3345                                    finderCache.putResult(finderPath, finderArgs, count);
3346                            }
3347                            catch (Exception e) {
3348                                    finderCache.removeResult(finderPath, finderArgs);
3349    
3350                                    throw processException(e);
3351                            }
3352                            finally {
3353                                    closeSession(session);
3354                            }
3355                    }
3356    
3357                    return count.intValue();
3358            }
3359    
3360            private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "dlFileEntry.repositoryId = ?";
3361            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_MIMETYPE = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3362                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
3363                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByMimeType",
3364                            new String[] {
3365                                    String.class.getName(),
3366                                    
3367                            Integer.class.getName(), Integer.class.getName(),
3368                                    OrderByComparator.class.getName()
3369                            });
3370            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE =
3371                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3372                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
3373                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByMimeType",
3374                            new String[] { String.class.getName() },
3375                            DLFileEntryModelImpl.MIMETYPE_COLUMN_BITMASK |
3376                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
3377                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
3378            public static final FinderPath FINDER_PATH_COUNT_BY_MIMETYPE = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3379                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3380                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByMimeType",
3381                            new String[] { String.class.getName() });
3382    
3383            /**
3384             * Returns all the document library file entries where mimeType = &#63;.
3385             *
3386             * @param mimeType the mime type
3387             * @return the matching document library file entries
3388             */
3389            @Override
3390            public List<DLFileEntry> findByMimeType(String mimeType) {
3391                    return findByMimeType(mimeType, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3392                            null);
3393            }
3394    
3395            /**
3396             * Returns a range of all the document library file entries where mimeType = &#63;.
3397             *
3398             * <p>
3399             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3400             * </p>
3401             *
3402             * @param mimeType the mime type
3403             * @param start the lower bound of the range of document library file entries
3404             * @param end the upper bound of the range of document library file entries (not inclusive)
3405             * @return the range of matching document library file entries
3406             */
3407            @Override
3408            public List<DLFileEntry> findByMimeType(String mimeType, int start, int end) {
3409                    return findByMimeType(mimeType, start, end, null);
3410            }
3411    
3412            /**
3413             * Returns an ordered range of all the document library file entries where mimeType = &#63;.
3414             *
3415             * <p>
3416             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3417             * </p>
3418             *
3419             * @param mimeType the mime type
3420             * @param start the lower bound of the range of document library file entries
3421             * @param end the upper bound of the range of document library file entries (not inclusive)
3422             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3423             * @return the ordered range of matching document library file entries
3424             */
3425            @Override
3426            public List<DLFileEntry> findByMimeType(String mimeType, int start,
3427                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
3428                    return findByMimeType(mimeType, start, end, orderByComparator, true);
3429            }
3430    
3431            /**
3432             * Returns an ordered range of all the document library file entries where mimeType = &#63;.
3433             *
3434             * <p>
3435             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3436             * </p>
3437             *
3438             * @param mimeType the mime type
3439             * @param start the lower bound of the range of document library file entries
3440             * @param end the upper bound of the range of document library file entries (not inclusive)
3441             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3442             * @param retrieveFromCache whether to retrieve from the finder cache
3443             * @return the ordered range of matching document library file entries
3444             */
3445            @Override
3446            public List<DLFileEntry> findByMimeType(String mimeType, int start,
3447                    int end, OrderByComparator<DLFileEntry> orderByComparator,
3448                    boolean retrieveFromCache) {
3449                    boolean pagination = true;
3450                    FinderPath finderPath = null;
3451                    Object[] finderArgs = null;
3452    
3453                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3454                                    (orderByComparator == null)) {
3455                            pagination = false;
3456                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE;
3457                            finderArgs = new Object[] { mimeType };
3458                    }
3459                    else {
3460                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_MIMETYPE;
3461                            finderArgs = new Object[] { mimeType, start, end, orderByComparator };
3462                    }
3463    
3464                    List<DLFileEntry> list = null;
3465    
3466                    if (retrieveFromCache) {
3467                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
3468                                            finderArgs, this);
3469    
3470                            if ((list != null) && !list.isEmpty()) {
3471                                    for (DLFileEntry dlFileEntry : list) {
3472                                            if (!Validator.equals(mimeType, dlFileEntry.getMimeType())) {
3473                                                    list = null;
3474    
3475                                                    break;
3476                                            }
3477                                    }
3478                            }
3479                    }
3480    
3481                    if (list == null) {
3482                            StringBundler query = null;
3483    
3484                            if (orderByComparator != null) {
3485                                    query = new StringBundler(3 +
3486                                                    (orderByComparator.getOrderByFields().length * 3));
3487                            }
3488                            else {
3489                                    query = new StringBundler(3);
3490                            }
3491    
3492                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3493    
3494                            boolean bindMimeType = false;
3495    
3496                            if (mimeType == null) {
3497                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_1);
3498                            }
3499                            else if (mimeType.equals(StringPool.BLANK)) {
3500                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_3);
3501                            }
3502                            else {
3503                                    bindMimeType = true;
3504    
3505                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_2);
3506                            }
3507    
3508                            if (orderByComparator != null) {
3509                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3510                                            orderByComparator);
3511                            }
3512                            else
3513                             if (pagination) {
3514                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3515                            }
3516    
3517                            String sql = query.toString();
3518    
3519                            Session session = null;
3520    
3521                            try {
3522                                    session = openSession();
3523    
3524                                    Query q = session.createQuery(sql);
3525    
3526                                    QueryPos qPos = QueryPos.getInstance(q);
3527    
3528                                    if (bindMimeType) {
3529                                            qPos.add(mimeType);
3530                                    }
3531    
3532                                    if (!pagination) {
3533                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3534                                                            start, end, false);
3535    
3536                                            Collections.sort(list);
3537    
3538                                            list = Collections.unmodifiableList(list);
3539                                    }
3540                                    else {
3541                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3542                                                            start, end);
3543                                    }
3544    
3545                                    cacheResult(list);
3546    
3547                                    finderCache.putResult(finderPath, finderArgs, list);
3548                            }
3549                            catch (Exception e) {
3550                                    finderCache.removeResult(finderPath, finderArgs);
3551    
3552                                    throw processException(e);
3553                            }
3554                            finally {
3555                                    closeSession(session);
3556                            }
3557                    }
3558    
3559                    return list;
3560            }
3561    
3562            /**
3563             * Returns the first document library file entry in the ordered set where mimeType = &#63;.
3564             *
3565             * @param mimeType the mime type
3566             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3567             * @return the first matching document library file entry
3568             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
3569             */
3570            @Override
3571            public DLFileEntry findByMimeType_First(String mimeType,
3572                    OrderByComparator<DLFileEntry> orderByComparator)
3573                    throws NoSuchFileEntryException {
3574                    DLFileEntry dlFileEntry = fetchByMimeType_First(mimeType,
3575                                    orderByComparator);
3576    
3577                    if (dlFileEntry != null) {
3578                            return dlFileEntry;
3579                    }
3580    
3581                    StringBundler msg = new StringBundler(4);
3582    
3583                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3584    
3585                    msg.append("mimeType=");
3586                    msg.append(mimeType);
3587    
3588                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3589    
3590                    throw new NoSuchFileEntryException(msg.toString());
3591            }
3592    
3593            /**
3594             * Returns the first document library file entry in the ordered set where mimeType = &#63;.
3595             *
3596             * @param mimeType the mime type
3597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3598             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
3599             */
3600            @Override
3601            public DLFileEntry fetchByMimeType_First(String mimeType,
3602                    OrderByComparator<DLFileEntry> orderByComparator) {
3603                    List<DLFileEntry> list = findByMimeType(mimeType, 0, 1,
3604                                    orderByComparator);
3605    
3606                    if (!list.isEmpty()) {
3607                            return list.get(0);
3608                    }
3609    
3610                    return null;
3611            }
3612    
3613            /**
3614             * Returns the last document library file entry in the ordered set where mimeType = &#63;.
3615             *
3616             * @param mimeType the mime type
3617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3618             * @return the last matching document library file entry
3619             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
3620             */
3621            @Override
3622            public DLFileEntry findByMimeType_Last(String mimeType,
3623                    OrderByComparator<DLFileEntry> orderByComparator)
3624                    throws NoSuchFileEntryException {
3625                    DLFileEntry dlFileEntry = fetchByMimeType_Last(mimeType,
3626                                    orderByComparator);
3627    
3628                    if (dlFileEntry != null) {
3629                            return dlFileEntry;
3630                    }
3631    
3632                    StringBundler msg = new StringBundler(4);
3633    
3634                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3635    
3636                    msg.append("mimeType=");
3637                    msg.append(mimeType);
3638    
3639                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3640    
3641                    throw new NoSuchFileEntryException(msg.toString());
3642            }
3643    
3644            /**
3645             * Returns the last document library file entry in the ordered set where mimeType = &#63;.
3646             *
3647             * @param mimeType the mime type
3648             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3649             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
3650             */
3651            @Override
3652            public DLFileEntry fetchByMimeType_Last(String mimeType,
3653                    OrderByComparator<DLFileEntry> orderByComparator) {
3654                    int count = countByMimeType(mimeType);
3655    
3656                    if (count == 0) {
3657                            return null;
3658                    }
3659    
3660                    List<DLFileEntry> list = findByMimeType(mimeType, count - 1, count,
3661                                    orderByComparator);
3662    
3663                    if (!list.isEmpty()) {
3664                            return list.get(0);
3665                    }
3666    
3667                    return null;
3668            }
3669    
3670            /**
3671             * Returns the document library file entries before and after the current document library file entry in the ordered set where mimeType = &#63;.
3672             *
3673             * @param fileEntryId the primary key of the current document library file entry
3674             * @param mimeType the mime type
3675             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3676             * @return the previous, current, and next document library file entry
3677             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
3678             */
3679            @Override
3680            public DLFileEntry[] findByMimeType_PrevAndNext(long fileEntryId,
3681                    String mimeType, OrderByComparator<DLFileEntry> orderByComparator)
3682                    throws NoSuchFileEntryException {
3683                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3684    
3685                    Session session = null;
3686    
3687                    try {
3688                            session = openSession();
3689    
3690                            DLFileEntry[] array = new DLFileEntryImpl[3];
3691    
3692                            array[0] = getByMimeType_PrevAndNext(session, dlFileEntry,
3693                                            mimeType, orderByComparator, true);
3694    
3695                            array[1] = dlFileEntry;
3696    
3697                            array[2] = getByMimeType_PrevAndNext(session, dlFileEntry,
3698                                            mimeType, orderByComparator, false);
3699    
3700                            return array;
3701                    }
3702                    catch (Exception e) {
3703                            throw processException(e);
3704                    }
3705                    finally {
3706                            closeSession(session);
3707                    }
3708            }
3709    
3710            protected DLFileEntry getByMimeType_PrevAndNext(Session session,
3711                    DLFileEntry dlFileEntry, String mimeType,
3712                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
3713                    StringBundler query = null;
3714    
3715                    if (orderByComparator != null) {
3716                            query = new StringBundler(6 +
3717                                            (orderByComparator.getOrderByFields().length * 6));
3718                    }
3719                    else {
3720                            query = new StringBundler(3);
3721                    }
3722    
3723                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3724    
3725                    boolean bindMimeType = false;
3726    
3727                    if (mimeType == null) {
3728                            query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_1);
3729                    }
3730                    else if (mimeType.equals(StringPool.BLANK)) {
3731                            query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_3);
3732                    }
3733                    else {
3734                            bindMimeType = true;
3735    
3736                            query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_2);
3737                    }
3738    
3739                    if (orderByComparator != null) {
3740                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3741    
3742                            if (orderByConditionFields.length > 0) {
3743                                    query.append(WHERE_AND);
3744                            }
3745    
3746                            for (int i = 0; i < orderByConditionFields.length; i++) {
3747                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3748                                    query.append(orderByConditionFields[i]);
3749    
3750                                    if ((i + 1) < orderByConditionFields.length) {
3751                                            if (orderByComparator.isAscending() ^ previous) {
3752                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3753                                            }
3754                                            else {
3755                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3756                                            }
3757                                    }
3758                                    else {
3759                                            if (orderByComparator.isAscending() ^ previous) {
3760                                                    query.append(WHERE_GREATER_THAN);
3761                                            }
3762                                            else {
3763                                                    query.append(WHERE_LESSER_THAN);
3764                                            }
3765                                    }
3766                            }
3767    
3768                            query.append(ORDER_BY_CLAUSE);
3769    
3770                            String[] orderByFields = orderByComparator.getOrderByFields();
3771    
3772                            for (int i = 0; i < orderByFields.length; i++) {
3773                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3774                                    query.append(orderByFields[i]);
3775    
3776                                    if ((i + 1) < orderByFields.length) {
3777                                            if (orderByComparator.isAscending() ^ previous) {
3778                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3779                                            }
3780                                            else {
3781                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3782                                            }
3783                                    }
3784                                    else {
3785                                            if (orderByComparator.isAscending() ^ previous) {
3786                                                    query.append(ORDER_BY_ASC);
3787                                            }
3788                                            else {
3789                                                    query.append(ORDER_BY_DESC);
3790                                            }
3791                                    }
3792                            }
3793                    }
3794                    else {
3795                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3796                    }
3797    
3798                    String sql = query.toString();
3799    
3800                    Query q = session.createQuery(sql);
3801    
3802                    q.setFirstResult(0);
3803                    q.setMaxResults(2);
3804    
3805                    QueryPos qPos = QueryPos.getInstance(q);
3806    
3807                    if (bindMimeType) {
3808                            qPos.add(mimeType);
3809                    }
3810    
3811                    if (orderByComparator != null) {
3812                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3813    
3814                            for (Object value : values) {
3815                                    qPos.add(value);
3816                            }
3817                    }
3818    
3819                    List<DLFileEntry> list = q.list();
3820    
3821                    if (list.size() == 2) {
3822                            return list.get(1);
3823                    }
3824                    else {
3825                            return null;
3826                    }
3827            }
3828    
3829            /**
3830             * Removes all the document library file entries where mimeType = &#63; from the database.
3831             *
3832             * @param mimeType the mime type
3833             */
3834            @Override
3835            public void removeByMimeType(String mimeType) {
3836                    for (DLFileEntry dlFileEntry : findByMimeType(mimeType,
3837                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3838                            remove(dlFileEntry);
3839                    }
3840            }
3841    
3842            /**
3843             * Returns the number of document library file entries where mimeType = &#63;.
3844             *
3845             * @param mimeType the mime type
3846             * @return the number of matching document library file entries
3847             */
3848            @Override
3849            public int countByMimeType(String mimeType) {
3850                    FinderPath finderPath = FINDER_PATH_COUNT_BY_MIMETYPE;
3851    
3852                    Object[] finderArgs = new Object[] { mimeType };
3853    
3854                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3855    
3856                    if (count == null) {
3857                            StringBundler query = new StringBundler(2);
3858    
3859                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
3860    
3861                            boolean bindMimeType = false;
3862    
3863                            if (mimeType == null) {
3864                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_1);
3865                            }
3866                            else if (mimeType.equals(StringPool.BLANK)) {
3867                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_3);
3868                            }
3869                            else {
3870                                    bindMimeType = true;
3871    
3872                                    query.append(_FINDER_COLUMN_MIMETYPE_MIMETYPE_2);
3873                            }
3874    
3875                            String sql = query.toString();
3876    
3877                            Session session = null;
3878    
3879                            try {
3880                                    session = openSession();
3881    
3882                                    Query q = session.createQuery(sql);
3883    
3884                                    QueryPos qPos = QueryPos.getInstance(q);
3885    
3886                                    if (bindMimeType) {
3887                                            qPos.add(mimeType);
3888                                    }
3889    
3890                                    count = (Long)q.uniqueResult();
3891    
3892                                    finderCache.putResult(finderPath, finderArgs, count);
3893                            }
3894                            catch (Exception e) {
3895                                    finderCache.removeResult(finderPath, finderArgs);
3896    
3897                                    throw processException(e);
3898                            }
3899                            finally {
3900                                    closeSession(session);
3901                            }
3902                    }
3903    
3904                    return count.intValue();
3905            }
3906    
3907            private static final String _FINDER_COLUMN_MIMETYPE_MIMETYPE_1 = "dlFileEntry.mimeType IS NULL";
3908            private static final String _FINDER_COLUMN_MIMETYPE_MIMETYPE_2 = "dlFileEntry.mimeType = ?";
3909            private static final String _FINDER_COLUMN_MIMETYPE_MIMETYPE_3 = "(dlFileEntry.mimeType IS NULL OR dlFileEntry.mimeType = '')";
3910            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYTYPEID =
3911                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3912                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
3913                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileEntryTypeId",
3914                            new String[] {
3915                                    Long.class.getName(),
3916                                    
3917                            Integer.class.getName(), Integer.class.getName(),
3918                                    OrderByComparator.class.getName()
3919                            });
3920            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID =
3921                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3922                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
3923                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileEntryTypeId",
3924                            new String[] { Long.class.getName() },
3925                            DLFileEntryModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK |
3926                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
3927                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
3928            public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYTYPEID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
3929                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3930                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3931                            "countByFileEntryTypeId", new String[] { Long.class.getName() });
3932    
3933            /**
3934             * Returns all the document library file entries where fileEntryTypeId = &#63;.
3935             *
3936             * @param fileEntryTypeId the file entry type ID
3937             * @return the matching document library file entries
3938             */
3939            @Override
3940            public List<DLFileEntry> findByFileEntryTypeId(long fileEntryTypeId) {
3941                    return findByFileEntryTypeId(fileEntryTypeId, QueryUtil.ALL_POS,
3942                            QueryUtil.ALL_POS, null);
3943            }
3944    
3945            /**
3946             * Returns a range of all the document library file entries where fileEntryTypeId = &#63;.
3947             *
3948             * <p>
3949             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3950             * </p>
3951             *
3952             * @param fileEntryTypeId the file entry type ID
3953             * @param start the lower bound of the range of document library file entries
3954             * @param end the upper bound of the range of document library file entries (not inclusive)
3955             * @return the range of matching document library file entries
3956             */
3957            @Override
3958            public List<DLFileEntry> findByFileEntryTypeId(long fileEntryTypeId,
3959                    int start, int end) {
3960                    return findByFileEntryTypeId(fileEntryTypeId, start, end, null);
3961            }
3962    
3963            /**
3964             * Returns an ordered range of all the document library file entries where fileEntryTypeId = &#63;.
3965             *
3966             * <p>
3967             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3968             * </p>
3969             *
3970             * @param fileEntryTypeId the file entry type ID
3971             * @param start the lower bound of the range of document library file entries
3972             * @param end the upper bound of the range of document library file entries (not inclusive)
3973             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3974             * @return the ordered range of matching document library file entries
3975             */
3976            @Override
3977            public List<DLFileEntry> findByFileEntryTypeId(long fileEntryTypeId,
3978                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
3979                    return findByFileEntryTypeId(fileEntryTypeId, start, end,
3980                            orderByComparator, true);
3981            }
3982    
3983            /**
3984             * Returns an ordered range of all the document library file entries where fileEntryTypeId = &#63;.
3985             *
3986             * <p>
3987             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3988             * </p>
3989             *
3990             * @param fileEntryTypeId the file entry type ID
3991             * @param start the lower bound of the range of document library file entries
3992             * @param end the upper bound of the range of document library file entries (not inclusive)
3993             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3994             * @param retrieveFromCache whether to retrieve from the finder cache
3995             * @return the ordered range of matching document library file entries
3996             */
3997            @Override
3998            public List<DLFileEntry> findByFileEntryTypeId(long fileEntryTypeId,
3999                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator,
4000                    boolean retrieveFromCache) {
4001                    boolean pagination = true;
4002                    FinderPath finderPath = null;
4003                    Object[] finderArgs = null;
4004    
4005                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4006                                    (orderByComparator == null)) {
4007                            pagination = false;
4008                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID;
4009                            finderArgs = new Object[] { fileEntryTypeId };
4010                    }
4011                    else {
4012                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYTYPEID;
4013                            finderArgs = new Object[] {
4014                                            fileEntryTypeId,
4015                                            
4016                                            start, end, orderByComparator
4017                                    };
4018                    }
4019    
4020                    List<DLFileEntry> list = null;
4021    
4022                    if (retrieveFromCache) {
4023                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
4024                                            finderArgs, this);
4025    
4026                            if ((list != null) && !list.isEmpty()) {
4027                                    for (DLFileEntry dlFileEntry : list) {
4028                                            if ((fileEntryTypeId != dlFileEntry.getFileEntryTypeId())) {
4029                                                    list = null;
4030    
4031                                                    break;
4032                                            }
4033                                    }
4034                            }
4035                    }
4036    
4037                    if (list == null) {
4038                            StringBundler query = null;
4039    
4040                            if (orderByComparator != null) {
4041                                    query = new StringBundler(3 +
4042                                                    (orderByComparator.getOrderByFields().length * 3));
4043                            }
4044                            else {
4045                                    query = new StringBundler(3);
4046                            }
4047    
4048                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4049    
4050                            query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
4051    
4052                            if (orderByComparator != null) {
4053                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4054                                            orderByComparator);
4055                            }
4056                            else
4057                             if (pagination) {
4058                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4059                            }
4060    
4061                            String sql = query.toString();
4062    
4063                            Session session = null;
4064    
4065                            try {
4066                                    session = openSession();
4067    
4068                                    Query q = session.createQuery(sql);
4069    
4070                                    QueryPos qPos = QueryPos.getInstance(q);
4071    
4072                                    qPos.add(fileEntryTypeId);
4073    
4074                                    if (!pagination) {
4075                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4076                                                            start, end, false);
4077    
4078                                            Collections.sort(list);
4079    
4080                                            list = Collections.unmodifiableList(list);
4081                                    }
4082                                    else {
4083                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4084                                                            start, end);
4085                                    }
4086    
4087                                    cacheResult(list);
4088    
4089                                    finderCache.putResult(finderPath, finderArgs, list);
4090                            }
4091                            catch (Exception e) {
4092                                    finderCache.removeResult(finderPath, finderArgs);
4093    
4094                                    throw processException(e);
4095                            }
4096                            finally {
4097                                    closeSession(session);
4098                            }
4099                    }
4100    
4101                    return list;
4102            }
4103    
4104            /**
4105             * Returns the first document library file entry in the ordered set where fileEntryTypeId = &#63;.
4106             *
4107             * @param fileEntryTypeId the file entry type ID
4108             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4109             * @return the first matching document library file entry
4110             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
4111             */
4112            @Override
4113            public DLFileEntry findByFileEntryTypeId_First(long fileEntryTypeId,
4114                    OrderByComparator<DLFileEntry> orderByComparator)
4115                    throws NoSuchFileEntryException {
4116                    DLFileEntry dlFileEntry = fetchByFileEntryTypeId_First(fileEntryTypeId,
4117                                    orderByComparator);
4118    
4119                    if (dlFileEntry != null) {
4120                            return dlFileEntry;
4121                    }
4122    
4123                    StringBundler msg = new StringBundler(4);
4124    
4125                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4126    
4127                    msg.append("fileEntryTypeId=");
4128                    msg.append(fileEntryTypeId);
4129    
4130                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4131    
4132                    throw new NoSuchFileEntryException(msg.toString());
4133            }
4134    
4135            /**
4136             * Returns the first document library file entry in the ordered set where fileEntryTypeId = &#63;.
4137             *
4138             * @param fileEntryTypeId the file entry type ID
4139             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4140             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
4141             */
4142            @Override
4143            public DLFileEntry fetchByFileEntryTypeId_First(long fileEntryTypeId,
4144                    OrderByComparator<DLFileEntry> orderByComparator) {
4145                    List<DLFileEntry> list = findByFileEntryTypeId(fileEntryTypeId, 0, 1,
4146                                    orderByComparator);
4147    
4148                    if (!list.isEmpty()) {
4149                            return list.get(0);
4150                    }
4151    
4152                    return null;
4153            }
4154    
4155            /**
4156             * Returns the last document library file entry in the ordered set where fileEntryTypeId = &#63;.
4157             *
4158             * @param fileEntryTypeId the file entry type ID
4159             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4160             * @return the last matching document library file entry
4161             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
4162             */
4163            @Override
4164            public DLFileEntry findByFileEntryTypeId_Last(long fileEntryTypeId,
4165                    OrderByComparator<DLFileEntry> orderByComparator)
4166                    throws NoSuchFileEntryException {
4167                    DLFileEntry dlFileEntry = fetchByFileEntryTypeId_Last(fileEntryTypeId,
4168                                    orderByComparator);
4169    
4170                    if (dlFileEntry != null) {
4171                            return dlFileEntry;
4172                    }
4173    
4174                    StringBundler msg = new StringBundler(4);
4175    
4176                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4177    
4178                    msg.append("fileEntryTypeId=");
4179                    msg.append(fileEntryTypeId);
4180    
4181                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4182    
4183                    throw new NoSuchFileEntryException(msg.toString());
4184            }
4185    
4186            /**
4187             * Returns the last document library file entry in the ordered set where fileEntryTypeId = &#63;.
4188             *
4189             * @param fileEntryTypeId the file entry type ID
4190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4191             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
4192             */
4193            @Override
4194            public DLFileEntry fetchByFileEntryTypeId_Last(long fileEntryTypeId,
4195                    OrderByComparator<DLFileEntry> orderByComparator) {
4196                    int count = countByFileEntryTypeId(fileEntryTypeId);
4197    
4198                    if (count == 0) {
4199                            return null;
4200                    }
4201    
4202                    List<DLFileEntry> list = findByFileEntryTypeId(fileEntryTypeId,
4203                                    count - 1, count, orderByComparator);
4204    
4205                    if (!list.isEmpty()) {
4206                            return list.get(0);
4207                    }
4208    
4209                    return null;
4210            }
4211    
4212            /**
4213             * Returns the document library file entries before and after the current document library file entry in the ordered set where fileEntryTypeId = &#63;.
4214             *
4215             * @param fileEntryId the primary key of the current document library file entry
4216             * @param fileEntryTypeId the file entry type ID
4217             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4218             * @return the previous, current, and next document library file entry
4219             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
4220             */
4221            @Override
4222            public DLFileEntry[] findByFileEntryTypeId_PrevAndNext(long fileEntryId,
4223                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator)
4224                    throws NoSuchFileEntryException {
4225                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4226    
4227                    Session session = null;
4228    
4229                    try {
4230                            session = openSession();
4231    
4232                            DLFileEntry[] array = new DLFileEntryImpl[3];
4233    
4234                            array[0] = getByFileEntryTypeId_PrevAndNext(session, dlFileEntry,
4235                                            fileEntryTypeId, orderByComparator, true);
4236    
4237                            array[1] = dlFileEntry;
4238    
4239                            array[2] = getByFileEntryTypeId_PrevAndNext(session, dlFileEntry,
4240                                            fileEntryTypeId, orderByComparator, false);
4241    
4242                            return array;
4243                    }
4244                    catch (Exception e) {
4245                            throw processException(e);
4246                    }
4247                    finally {
4248                            closeSession(session);
4249                    }
4250            }
4251    
4252            protected DLFileEntry getByFileEntryTypeId_PrevAndNext(Session session,
4253                    DLFileEntry dlFileEntry, long fileEntryTypeId,
4254                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
4255                    StringBundler query = null;
4256    
4257                    if (orderByComparator != null) {
4258                            query = new StringBundler(6 +
4259                                            (orderByComparator.getOrderByFields().length * 6));
4260                    }
4261                    else {
4262                            query = new StringBundler(3);
4263                    }
4264    
4265                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4266    
4267                    query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
4268    
4269                    if (orderByComparator != null) {
4270                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4271    
4272                            if (orderByConditionFields.length > 0) {
4273                                    query.append(WHERE_AND);
4274                            }
4275    
4276                            for (int i = 0; i < orderByConditionFields.length; i++) {
4277                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4278                                    query.append(orderByConditionFields[i]);
4279    
4280                                    if ((i + 1) < orderByConditionFields.length) {
4281                                            if (orderByComparator.isAscending() ^ previous) {
4282                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4283                                            }
4284                                            else {
4285                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4286                                            }
4287                                    }
4288                                    else {
4289                                            if (orderByComparator.isAscending() ^ previous) {
4290                                                    query.append(WHERE_GREATER_THAN);
4291                                            }
4292                                            else {
4293                                                    query.append(WHERE_LESSER_THAN);
4294                                            }
4295                                    }
4296                            }
4297    
4298                            query.append(ORDER_BY_CLAUSE);
4299    
4300                            String[] orderByFields = orderByComparator.getOrderByFields();
4301    
4302                            for (int i = 0; i < orderByFields.length; i++) {
4303                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4304                                    query.append(orderByFields[i]);
4305    
4306                                    if ((i + 1) < orderByFields.length) {
4307                                            if (orderByComparator.isAscending() ^ previous) {
4308                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4309                                            }
4310                                            else {
4311                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4312                                            }
4313                                    }
4314                                    else {
4315                                            if (orderByComparator.isAscending() ^ previous) {
4316                                                    query.append(ORDER_BY_ASC);
4317                                            }
4318                                            else {
4319                                                    query.append(ORDER_BY_DESC);
4320                                            }
4321                                    }
4322                            }
4323                    }
4324                    else {
4325                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4326                    }
4327    
4328                    String sql = query.toString();
4329    
4330                    Query q = session.createQuery(sql);
4331    
4332                    q.setFirstResult(0);
4333                    q.setMaxResults(2);
4334    
4335                    QueryPos qPos = QueryPos.getInstance(q);
4336    
4337                    qPos.add(fileEntryTypeId);
4338    
4339                    if (orderByComparator != null) {
4340                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
4341    
4342                            for (Object value : values) {
4343                                    qPos.add(value);
4344                            }
4345                    }
4346    
4347                    List<DLFileEntry> list = q.list();
4348    
4349                    if (list.size() == 2) {
4350                            return list.get(1);
4351                    }
4352                    else {
4353                            return null;
4354                    }
4355            }
4356    
4357            /**
4358             * Removes all the document library file entries where fileEntryTypeId = &#63; from the database.
4359             *
4360             * @param fileEntryTypeId the file entry type ID
4361             */
4362            @Override
4363            public void removeByFileEntryTypeId(long fileEntryTypeId) {
4364                    for (DLFileEntry dlFileEntry : findByFileEntryTypeId(fileEntryTypeId,
4365                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4366                            remove(dlFileEntry);
4367                    }
4368            }
4369    
4370            /**
4371             * Returns the number of document library file entries where fileEntryTypeId = &#63;.
4372             *
4373             * @param fileEntryTypeId the file entry type ID
4374             * @return the number of matching document library file entries
4375             */
4376            @Override
4377            public int countByFileEntryTypeId(long fileEntryTypeId) {
4378                    FinderPath finderPath = FINDER_PATH_COUNT_BY_FILEENTRYTYPEID;
4379    
4380                    Object[] finderArgs = new Object[] { fileEntryTypeId };
4381    
4382                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4383    
4384                    if (count == null) {
4385                            StringBundler query = new StringBundler(2);
4386    
4387                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
4388    
4389                            query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
4390    
4391                            String sql = query.toString();
4392    
4393                            Session session = null;
4394    
4395                            try {
4396                                    session = openSession();
4397    
4398                                    Query q = session.createQuery(sql);
4399    
4400                                    QueryPos qPos = QueryPos.getInstance(q);
4401    
4402                                    qPos.add(fileEntryTypeId);
4403    
4404                                    count = (Long)q.uniqueResult();
4405    
4406                                    finderCache.putResult(finderPath, finderArgs, count);
4407                            }
4408                            catch (Exception e) {
4409                                    finderCache.removeResult(finderPath, finderArgs);
4410    
4411                                    throw processException(e);
4412                            }
4413                            finally {
4414                                    closeSession(session);
4415                            }
4416                    }
4417    
4418                    return count.intValue();
4419            }
4420    
4421            private static final String _FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2 =
4422                    "dlFileEntry.fileEntryTypeId = ?";
4423            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
4424                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
4425                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U",
4426                            new String[] {
4427                                    Long.class.getName(), Long.class.getName(),
4428                                    
4429                            Integer.class.getName(), Integer.class.getName(),
4430                                    OrderByComparator.class.getName()
4431                            });
4432            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
4433                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
4434                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
4435                            new String[] { Long.class.getName(), Long.class.getName() },
4436                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
4437                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK |
4438                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
4439                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
4440            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
4441                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4442                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
4443                            new String[] { Long.class.getName(), Long.class.getName() });
4444    
4445            /**
4446             * Returns all the document library file entries where groupId = &#63; and userId = &#63;.
4447             *
4448             * @param groupId the group ID
4449             * @param userId the user ID
4450             * @return the matching document library file entries
4451             */
4452            @Override
4453            public List<DLFileEntry> findByG_U(long groupId, long userId) {
4454                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4455                            null);
4456            }
4457    
4458            /**
4459             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63;.
4460             *
4461             * <p>
4462             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4463             * </p>
4464             *
4465             * @param groupId the group ID
4466             * @param userId the user ID
4467             * @param start the lower bound of the range of document library file entries
4468             * @param end the upper bound of the range of document library file entries (not inclusive)
4469             * @return the range of matching document library file entries
4470             */
4471            @Override
4472            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
4473                    int end) {
4474                    return findByG_U(groupId, userId, start, end, null);
4475            }
4476    
4477            /**
4478             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63;.
4479             *
4480             * <p>
4481             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4482             * </p>
4483             *
4484             * @param groupId the group ID
4485             * @param userId the user ID
4486             * @param start the lower bound of the range of document library file entries
4487             * @param end the upper bound of the range of document library file entries (not inclusive)
4488             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4489             * @return the ordered range of matching document library file entries
4490             */
4491            @Override
4492            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
4493                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
4494                    return findByG_U(groupId, userId, start, end, orderByComparator, true);
4495            }
4496    
4497            /**
4498             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63;.
4499             *
4500             * <p>
4501             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4502             * </p>
4503             *
4504             * @param groupId the group ID
4505             * @param userId the user ID
4506             * @param start the lower bound of the range of document library file entries
4507             * @param end the upper bound of the range of document library file entries (not inclusive)
4508             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4509             * @param retrieveFromCache whether to retrieve from the finder cache
4510             * @return the ordered range of matching document library file entries
4511             */
4512            @Override
4513            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
4514                    int end, OrderByComparator<DLFileEntry> orderByComparator,
4515                    boolean retrieveFromCache) {
4516                    boolean pagination = true;
4517                    FinderPath finderPath = null;
4518                    Object[] finderArgs = null;
4519    
4520                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4521                                    (orderByComparator == null)) {
4522                            pagination = false;
4523                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
4524                            finderArgs = new Object[] { groupId, userId };
4525                    }
4526                    else {
4527                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
4528                            finderArgs = new Object[] {
4529                                            groupId, userId,
4530                                            
4531                                            start, end, orderByComparator
4532                                    };
4533                    }
4534    
4535                    List<DLFileEntry> list = null;
4536    
4537                    if (retrieveFromCache) {
4538                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
4539                                            finderArgs, this);
4540    
4541                            if ((list != null) && !list.isEmpty()) {
4542                                    for (DLFileEntry dlFileEntry : list) {
4543                                            if ((groupId != dlFileEntry.getGroupId()) ||
4544                                                            (userId != dlFileEntry.getUserId())) {
4545                                                    list = null;
4546    
4547                                                    break;
4548                                            }
4549                                    }
4550                            }
4551                    }
4552    
4553                    if (list == null) {
4554                            StringBundler query = null;
4555    
4556                            if (orderByComparator != null) {
4557                                    query = new StringBundler(4 +
4558                                                    (orderByComparator.getOrderByFields().length * 3));
4559                            }
4560                            else {
4561                                    query = new StringBundler(4);
4562                            }
4563    
4564                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4565    
4566                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4567    
4568                            query.append(_FINDER_COLUMN_G_U_USERID_2);
4569    
4570                            if (orderByComparator != null) {
4571                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4572                                            orderByComparator);
4573                            }
4574                            else
4575                             if (pagination) {
4576                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4577                            }
4578    
4579                            String sql = query.toString();
4580    
4581                            Session session = null;
4582    
4583                            try {
4584                                    session = openSession();
4585    
4586                                    Query q = session.createQuery(sql);
4587    
4588                                    QueryPos qPos = QueryPos.getInstance(q);
4589    
4590                                    qPos.add(groupId);
4591    
4592                                    qPos.add(userId);
4593    
4594                                    if (!pagination) {
4595                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4596                                                            start, end, false);
4597    
4598                                            Collections.sort(list);
4599    
4600                                            list = Collections.unmodifiableList(list);
4601                                    }
4602                                    else {
4603                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4604                                                            start, end);
4605                                    }
4606    
4607                                    cacheResult(list);
4608    
4609                                    finderCache.putResult(finderPath, finderArgs, list);
4610                            }
4611                            catch (Exception e) {
4612                                    finderCache.removeResult(finderPath, finderArgs);
4613    
4614                                    throw processException(e);
4615                            }
4616                            finally {
4617                                    closeSession(session);
4618                            }
4619                    }
4620    
4621                    return list;
4622            }
4623    
4624            /**
4625             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4626             *
4627             * @param groupId the group ID
4628             * @param userId the user ID
4629             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4630             * @return the first matching document library file entry
4631             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
4632             */
4633            @Override
4634            public DLFileEntry findByG_U_First(long groupId, long userId,
4635                    OrderByComparator<DLFileEntry> orderByComparator)
4636                    throws NoSuchFileEntryException {
4637                    DLFileEntry dlFileEntry = fetchByG_U_First(groupId, userId,
4638                                    orderByComparator);
4639    
4640                    if (dlFileEntry != null) {
4641                            return dlFileEntry;
4642                    }
4643    
4644                    StringBundler msg = new StringBundler(6);
4645    
4646                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4647    
4648                    msg.append("groupId=");
4649                    msg.append(groupId);
4650    
4651                    msg.append(", userId=");
4652                    msg.append(userId);
4653    
4654                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4655    
4656                    throw new NoSuchFileEntryException(msg.toString());
4657            }
4658    
4659            /**
4660             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4661             *
4662             * @param groupId the group ID
4663             * @param userId the user ID
4664             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4665             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
4666             */
4667            @Override
4668            public DLFileEntry fetchByG_U_First(long groupId, long userId,
4669                    OrderByComparator<DLFileEntry> orderByComparator) {
4670                    List<DLFileEntry> list = findByG_U(groupId, userId, 0, 1,
4671                                    orderByComparator);
4672    
4673                    if (!list.isEmpty()) {
4674                            return list.get(0);
4675                    }
4676    
4677                    return null;
4678            }
4679    
4680            /**
4681             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4682             *
4683             * @param groupId the group ID
4684             * @param userId the user ID
4685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4686             * @return the last matching document library file entry
4687             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
4688             */
4689            @Override
4690            public DLFileEntry findByG_U_Last(long groupId, long userId,
4691                    OrderByComparator<DLFileEntry> orderByComparator)
4692                    throws NoSuchFileEntryException {
4693                    DLFileEntry dlFileEntry = fetchByG_U_Last(groupId, userId,
4694                                    orderByComparator);
4695    
4696                    if (dlFileEntry != null) {
4697                            return dlFileEntry;
4698                    }
4699    
4700                    StringBundler msg = new StringBundler(6);
4701    
4702                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4703    
4704                    msg.append("groupId=");
4705                    msg.append(groupId);
4706    
4707                    msg.append(", userId=");
4708                    msg.append(userId);
4709    
4710                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4711    
4712                    throw new NoSuchFileEntryException(msg.toString());
4713            }
4714    
4715            /**
4716             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
4717             *
4718             * @param groupId the group ID
4719             * @param userId the user ID
4720             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4721             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
4722             */
4723            @Override
4724            public DLFileEntry fetchByG_U_Last(long groupId, long userId,
4725                    OrderByComparator<DLFileEntry> orderByComparator) {
4726                    int count = countByG_U(groupId, userId);
4727    
4728                    if (count == 0) {
4729                            return null;
4730                    }
4731    
4732                    List<DLFileEntry> list = findByG_U(groupId, userId, count - 1, count,
4733                                    orderByComparator);
4734    
4735                    if (!list.isEmpty()) {
4736                            return list.get(0);
4737                    }
4738    
4739                    return null;
4740            }
4741    
4742            /**
4743             * 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;.
4744             *
4745             * @param fileEntryId the primary key of the current document library file entry
4746             * @param groupId the group ID
4747             * @param userId the user ID
4748             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4749             * @return the previous, current, and next document library file entry
4750             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
4751             */
4752            @Override
4753            public DLFileEntry[] findByG_U_PrevAndNext(long fileEntryId, long groupId,
4754                    long userId, OrderByComparator<DLFileEntry> orderByComparator)
4755                    throws NoSuchFileEntryException {
4756                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4757    
4758                    Session session = null;
4759    
4760                    try {
4761                            session = openSession();
4762    
4763                            DLFileEntry[] array = new DLFileEntryImpl[3];
4764    
4765                            array[0] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
4766                                            userId, orderByComparator, true);
4767    
4768                            array[1] = dlFileEntry;
4769    
4770                            array[2] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
4771                                            userId, orderByComparator, false);
4772    
4773                            return array;
4774                    }
4775                    catch (Exception e) {
4776                            throw processException(e);
4777                    }
4778                    finally {
4779                            closeSession(session);
4780                    }
4781            }
4782    
4783            protected DLFileEntry getByG_U_PrevAndNext(Session session,
4784                    DLFileEntry dlFileEntry, long groupId, long userId,
4785                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
4786                    StringBundler query = null;
4787    
4788                    if (orderByComparator != null) {
4789                            query = new StringBundler(6 +
4790                                            (orderByComparator.getOrderByFields().length * 6));
4791                    }
4792                    else {
4793                            query = new StringBundler(3);
4794                    }
4795    
4796                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4797    
4798                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4799    
4800                    query.append(_FINDER_COLUMN_G_U_USERID_2);
4801    
4802                    if (orderByComparator != null) {
4803                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4804    
4805                            if (orderByConditionFields.length > 0) {
4806                                    query.append(WHERE_AND);
4807                            }
4808    
4809                            for (int i = 0; i < orderByConditionFields.length; i++) {
4810                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4811                                    query.append(orderByConditionFields[i]);
4812    
4813                                    if ((i + 1) < orderByConditionFields.length) {
4814                                            if (orderByComparator.isAscending() ^ previous) {
4815                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4816                                            }
4817                                            else {
4818                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4819                                            }
4820                                    }
4821                                    else {
4822                                            if (orderByComparator.isAscending() ^ previous) {
4823                                                    query.append(WHERE_GREATER_THAN);
4824                                            }
4825                                            else {
4826                                                    query.append(WHERE_LESSER_THAN);
4827                                            }
4828                                    }
4829                            }
4830    
4831                            query.append(ORDER_BY_CLAUSE);
4832    
4833                            String[] orderByFields = orderByComparator.getOrderByFields();
4834    
4835                            for (int i = 0; i < orderByFields.length; i++) {
4836                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4837                                    query.append(orderByFields[i]);
4838    
4839                                    if ((i + 1) < orderByFields.length) {
4840                                            if (orderByComparator.isAscending() ^ previous) {
4841                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4842                                            }
4843                                            else {
4844                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4845                                            }
4846                                    }
4847                                    else {
4848                                            if (orderByComparator.isAscending() ^ previous) {
4849                                                    query.append(ORDER_BY_ASC);
4850                                            }
4851                                            else {
4852                                                    query.append(ORDER_BY_DESC);
4853                                            }
4854                                    }
4855                            }
4856                    }
4857                    else {
4858                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4859                    }
4860    
4861                    String sql = query.toString();
4862    
4863                    Query q = session.createQuery(sql);
4864    
4865                    q.setFirstResult(0);
4866                    q.setMaxResults(2);
4867    
4868                    QueryPos qPos = QueryPos.getInstance(q);
4869    
4870                    qPos.add(groupId);
4871    
4872                    qPos.add(userId);
4873    
4874                    if (orderByComparator != null) {
4875                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
4876    
4877                            for (Object value : values) {
4878                                    qPos.add(value);
4879                            }
4880                    }
4881    
4882                    List<DLFileEntry> list = q.list();
4883    
4884                    if (list.size() == 2) {
4885                            return list.get(1);
4886                    }
4887                    else {
4888                            return null;
4889                    }
4890            }
4891    
4892            /**
4893             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
4894             *
4895             * @param groupId the group ID
4896             * @param userId the user ID
4897             * @return the matching document library file entries that the user has permission to view
4898             */
4899            @Override
4900            public List<DLFileEntry> filterFindByG_U(long groupId, long userId) {
4901                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
4902                            QueryUtil.ALL_POS, null);
4903            }
4904    
4905            /**
4906             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
4907             *
4908             * <p>
4909             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4910             * </p>
4911             *
4912             * @param groupId the group ID
4913             * @param userId the user ID
4914             * @param start the lower bound of the range of document library file entries
4915             * @param end the upper bound of the range of document library file entries (not inclusive)
4916             * @return the range of matching document library file entries that the user has permission to view
4917             */
4918            @Override
4919            public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
4920                    int start, int end) {
4921                    return filterFindByG_U(groupId, userId, start, end, null);
4922            }
4923    
4924            /**
4925             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and userId = &#63;.
4926             *
4927             * <p>
4928             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4929             * </p>
4930             *
4931             * @param groupId the group ID
4932             * @param userId the user ID
4933             * @param start the lower bound of the range of document library file entries
4934             * @param end the upper bound of the range of document library file entries (not inclusive)
4935             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4936             * @return the ordered range of matching document library file entries that the user has permission to view
4937             */
4938            @Override
4939            public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
4940                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
4941                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4942                            return findByG_U(groupId, userId, start, end, orderByComparator);
4943                    }
4944    
4945                    StringBundler query = null;
4946    
4947                    if (orderByComparator != null) {
4948                            query = new StringBundler(4 +
4949                                            (orderByComparator.getOrderByFields().length * 3));
4950                    }
4951                    else {
4952                            query = new StringBundler(4);
4953                    }
4954    
4955                    if (getDB().isSupportsInlineDistinct()) {
4956                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4957                    }
4958                    else {
4959                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4960                    }
4961    
4962                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4963    
4964                    query.append(_FINDER_COLUMN_G_U_USERID_2);
4965    
4966                    if (!getDB().isSupportsInlineDistinct()) {
4967                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4968                    }
4969    
4970                    if (orderByComparator != null) {
4971                            if (getDB().isSupportsInlineDistinct()) {
4972                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4973                                            orderByComparator, true);
4974                            }
4975                            else {
4976                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4977                                            orderByComparator, true);
4978                            }
4979                    }
4980                    else {
4981                            if (getDB().isSupportsInlineDistinct()) {
4982                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4983                            }
4984                            else {
4985                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
4986                            }
4987                    }
4988    
4989                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4990                                    DLFileEntry.class.getName(),
4991                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4992    
4993                    Session session = null;
4994    
4995                    try {
4996                            session = openSession();
4997    
4998                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4999    
5000                            if (getDB().isSupportsInlineDistinct()) {
5001                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5002                            }
5003                            else {
5004                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5005                            }
5006    
5007                            QueryPos qPos = QueryPos.getInstance(q);
5008    
5009                            qPos.add(groupId);
5010    
5011                            qPos.add(userId);
5012    
5013                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
5014                    }
5015                    catch (Exception e) {
5016                            throw processException(e);
5017                    }
5018                    finally {
5019                            closeSession(session);
5020                    }
5021            }
5022    
5023            /**
5024             * 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;.
5025             *
5026             * @param fileEntryId the primary key of the current document library file entry
5027             * @param groupId the group ID
5028             * @param userId the user ID
5029             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5030             * @return the previous, current, and next document library file entry
5031             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
5032             */
5033            @Override
5034            public DLFileEntry[] filterFindByG_U_PrevAndNext(long fileEntryId,
5035                    long groupId, long userId,
5036                    OrderByComparator<DLFileEntry> orderByComparator)
5037                    throws NoSuchFileEntryException {
5038                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5039                            return findByG_U_PrevAndNext(fileEntryId, groupId, userId,
5040                                    orderByComparator);
5041                    }
5042    
5043                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
5044    
5045                    Session session = null;
5046    
5047                    try {
5048                            session = openSession();
5049    
5050                            DLFileEntry[] array = new DLFileEntryImpl[3];
5051    
5052                            array[0] = filterGetByG_U_PrevAndNext(session, dlFileEntry,
5053                                            groupId, userId, orderByComparator, true);
5054    
5055                            array[1] = dlFileEntry;
5056    
5057                            array[2] = filterGetByG_U_PrevAndNext(session, dlFileEntry,
5058                                            groupId, userId, orderByComparator, false);
5059    
5060                            return array;
5061                    }
5062                    catch (Exception e) {
5063                            throw processException(e);
5064                    }
5065                    finally {
5066                            closeSession(session);
5067                    }
5068            }
5069    
5070            protected DLFileEntry filterGetByG_U_PrevAndNext(Session session,
5071                    DLFileEntry dlFileEntry, long groupId, long userId,
5072                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
5073                    StringBundler query = null;
5074    
5075                    if (orderByComparator != null) {
5076                            query = new StringBundler(6 +
5077                                            (orderByComparator.getOrderByFields().length * 6));
5078                    }
5079                    else {
5080                            query = new StringBundler(3);
5081                    }
5082    
5083                    if (getDB().isSupportsInlineDistinct()) {
5084                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
5085                    }
5086                    else {
5087                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
5088                    }
5089    
5090                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
5091    
5092                    query.append(_FINDER_COLUMN_G_U_USERID_2);
5093    
5094                    if (!getDB().isSupportsInlineDistinct()) {
5095                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
5096                    }
5097    
5098                    if (orderByComparator != null) {
5099                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5100    
5101                            if (orderByConditionFields.length > 0) {
5102                                    query.append(WHERE_AND);
5103                            }
5104    
5105                            for (int i = 0; i < orderByConditionFields.length; i++) {
5106                                    if (getDB().isSupportsInlineDistinct()) {
5107                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5108                                    }
5109                                    else {
5110                                            query.append(_ORDER_BY_ENTITY_TABLE);
5111                                    }
5112    
5113                                    query.append(orderByConditionFields[i]);
5114    
5115                                    if ((i + 1) < orderByConditionFields.length) {
5116                                            if (orderByComparator.isAscending() ^ previous) {
5117                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5118                                            }
5119                                            else {
5120                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5121                                            }
5122                                    }
5123                                    else {
5124                                            if (orderByComparator.isAscending() ^ previous) {
5125                                                    query.append(WHERE_GREATER_THAN);
5126                                            }
5127                                            else {
5128                                                    query.append(WHERE_LESSER_THAN);
5129                                            }
5130                                    }
5131                            }
5132    
5133                            query.append(ORDER_BY_CLAUSE);
5134    
5135                            String[] orderByFields = orderByComparator.getOrderByFields();
5136    
5137                            for (int i = 0; i < orderByFields.length; i++) {
5138                                    if (getDB().isSupportsInlineDistinct()) {
5139                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5140                                    }
5141                                    else {
5142                                            query.append(_ORDER_BY_ENTITY_TABLE);
5143                                    }
5144    
5145                                    query.append(orderByFields[i]);
5146    
5147                                    if ((i + 1) < orderByFields.length) {
5148                                            if (orderByComparator.isAscending() ^ previous) {
5149                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5150                                            }
5151                                            else {
5152                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5153                                            }
5154                                    }
5155                                    else {
5156                                            if (orderByComparator.isAscending() ^ previous) {
5157                                                    query.append(ORDER_BY_ASC);
5158                                            }
5159                                            else {
5160                                                    query.append(ORDER_BY_DESC);
5161                                            }
5162                                    }
5163                            }
5164                    }
5165                    else {
5166                            if (getDB().isSupportsInlineDistinct()) {
5167                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5168                            }
5169                            else {
5170                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
5171                            }
5172                    }
5173    
5174                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5175                                    DLFileEntry.class.getName(),
5176                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5177    
5178                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5179    
5180                    q.setFirstResult(0);
5181                    q.setMaxResults(2);
5182    
5183                    if (getDB().isSupportsInlineDistinct()) {
5184                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5185                    }
5186                    else {
5187                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5188                    }
5189    
5190                    QueryPos qPos = QueryPos.getInstance(q);
5191    
5192                    qPos.add(groupId);
5193    
5194                    qPos.add(userId);
5195    
5196                    if (orderByComparator != null) {
5197                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
5198    
5199                            for (Object value : values) {
5200                                    qPos.add(value);
5201                            }
5202                    }
5203    
5204                    List<DLFileEntry> list = q.list();
5205    
5206                    if (list.size() == 2) {
5207                            return list.get(1);
5208                    }
5209                    else {
5210                            return null;
5211                    }
5212            }
5213    
5214            /**
5215             * Removes all the document library file entries where groupId = &#63; and userId = &#63; from the database.
5216             *
5217             * @param groupId the group ID
5218             * @param userId the user ID
5219             */
5220            @Override
5221            public void removeByG_U(long groupId, long userId) {
5222                    for (DLFileEntry dlFileEntry : findByG_U(groupId, userId,
5223                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5224                            remove(dlFileEntry);
5225                    }
5226            }
5227    
5228            /**
5229             * Returns the number of document library file entries where groupId = &#63; and userId = &#63;.
5230             *
5231             * @param groupId the group ID
5232             * @param userId the user ID
5233             * @return the number of matching document library file entries
5234             */
5235            @Override
5236            public int countByG_U(long groupId, long userId) {
5237                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
5238    
5239                    Object[] finderArgs = new Object[] { groupId, userId };
5240    
5241                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5242    
5243                    if (count == null) {
5244                            StringBundler query = new StringBundler(3);
5245    
5246                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
5247    
5248                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
5249    
5250                            query.append(_FINDER_COLUMN_G_U_USERID_2);
5251    
5252                            String sql = query.toString();
5253    
5254                            Session session = null;
5255    
5256                            try {
5257                                    session = openSession();
5258    
5259                                    Query q = session.createQuery(sql);
5260    
5261                                    QueryPos qPos = QueryPos.getInstance(q);
5262    
5263                                    qPos.add(groupId);
5264    
5265                                    qPos.add(userId);
5266    
5267                                    count = (Long)q.uniqueResult();
5268    
5269                                    finderCache.putResult(finderPath, finderArgs, count);
5270                            }
5271                            catch (Exception e) {
5272                                    finderCache.removeResult(finderPath, finderArgs);
5273    
5274                                    throw processException(e);
5275                            }
5276                            finally {
5277                                    closeSession(session);
5278                            }
5279                    }
5280    
5281                    return count.intValue();
5282            }
5283    
5284            /**
5285             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
5286             *
5287             * @param groupId the group ID
5288             * @param userId the user ID
5289             * @return the number of matching document library file entries that the user has permission to view
5290             */
5291            @Override
5292            public int filterCountByG_U(long groupId, long userId) {
5293                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5294                            return countByG_U(groupId, userId);
5295                    }
5296    
5297                    StringBundler query = new StringBundler(3);
5298    
5299                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
5300    
5301                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
5302    
5303                    query.append(_FINDER_COLUMN_G_U_USERID_2);
5304    
5305                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5306                                    DLFileEntry.class.getName(),
5307                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5308    
5309                    Session session = null;
5310    
5311                    try {
5312                            session = openSession();
5313    
5314                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5315    
5316                            q.addScalar(COUNT_COLUMN_NAME,
5317                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5318    
5319                            QueryPos qPos = QueryPos.getInstance(q);
5320    
5321                            qPos.add(groupId);
5322    
5323                            qPos.add(userId);
5324    
5325                            Long count = (Long)q.uniqueResult();
5326    
5327                            return count.intValue();
5328                    }
5329                    catch (Exception e) {
5330                            throw processException(e);
5331                    }
5332                    finally {
5333                            closeSession(session);
5334                    }
5335            }
5336    
5337            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
5338            private static final String _FINDER_COLUMN_G_U_USERID_2 = "dlFileEntry.userId = ?";
5339            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
5340                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
5341                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F",
5342                            new String[] {
5343                                    Long.class.getName(), Long.class.getName(),
5344                                    
5345                            Integer.class.getName(), Integer.class.getName(),
5346                                    OrderByComparator.class.getName()
5347                            });
5348            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
5349                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
5350                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
5351                            new String[] { Long.class.getName(), Long.class.getName() },
5352                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
5353                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
5354                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
5355            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
5356                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5357                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
5358                            new String[] { Long.class.getName(), Long.class.getName() });
5359            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
5360                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5361                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
5362                            new String[] { Long.class.getName(), Long.class.getName() });
5363    
5364            /**
5365             * Returns all the document library file entries where groupId = &#63; and folderId = &#63;.
5366             *
5367             * @param groupId the group ID
5368             * @param folderId the folder ID
5369             * @return the matching document library file entries
5370             */
5371            @Override
5372            public List<DLFileEntry> findByG_F(long groupId, long folderId) {
5373                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
5374                            QueryUtil.ALL_POS, null);
5375            }
5376    
5377            /**
5378             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63;.
5379             *
5380             * <p>
5381             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5382             * </p>
5383             *
5384             * @param groupId the group ID
5385             * @param folderId the folder ID
5386             * @param start the lower bound of the range of document library file entries
5387             * @param end the upper bound of the range of document library file entries (not inclusive)
5388             * @return the range of matching document library file entries
5389             */
5390            @Override
5391            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
5392                    int end) {
5393                    return findByG_F(groupId, folderId, start, end, null);
5394            }
5395    
5396            /**
5397             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63;.
5398             *
5399             * <p>
5400             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5401             * </p>
5402             *
5403             * @param groupId the group ID
5404             * @param folderId the folder ID
5405             * @param start the lower bound of the range of document library file entries
5406             * @param end the upper bound of the range of document library file entries (not inclusive)
5407             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5408             * @return the ordered range of matching document library file entries
5409             */
5410            @Override
5411            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
5412                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
5413                    return findByG_F(groupId, folderId, start, end, orderByComparator, true);
5414            }
5415    
5416            /**
5417             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63;.
5418             *
5419             * <p>
5420             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5421             * </p>
5422             *
5423             * @param groupId the group ID
5424             * @param folderId the folder ID
5425             * @param start the lower bound of the range of document library file entries
5426             * @param end the upper bound of the range of document library file entries (not inclusive)
5427             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5428             * @param retrieveFromCache whether to retrieve from the finder cache
5429             * @return the ordered range of matching document library file entries
5430             */
5431            @Override
5432            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
5433                    int end, OrderByComparator<DLFileEntry> orderByComparator,
5434                    boolean retrieveFromCache) {
5435                    boolean pagination = true;
5436                    FinderPath finderPath = null;
5437                    Object[] finderArgs = null;
5438    
5439                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5440                                    (orderByComparator == null)) {
5441                            pagination = false;
5442                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
5443                            finderArgs = new Object[] { groupId, folderId };
5444                    }
5445                    else {
5446                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
5447                            finderArgs = new Object[] {
5448                                            groupId, folderId,
5449                                            
5450                                            start, end, orderByComparator
5451                                    };
5452                    }
5453    
5454                    List<DLFileEntry> list = null;
5455    
5456                    if (retrieveFromCache) {
5457                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
5458                                            finderArgs, this);
5459    
5460                            if ((list != null) && !list.isEmpty()) {
5461                                    for (DLFileEntry dlFileEntry : list) {
5462                                            if ((groupId != dlFileEntry.getGroupId()) ||
5463                                                            (folderId != dlFileEntry.getFolderId())) {
5464                                                    list = null;
5465    
5466                                                    break;
5467                                            }
5468                                    }
5469                            }
5470                    }
5471    
5472                    if (list == null) {
5473                            StringBundler query = null;
5474    
5475                            if (orderByComparator != null) {
5476                                    query = new StringBundler(4 +
5477                                                    (orderByComparator.getOrderByFields().length * 3));
5478                            }
5479                            else {
5480                                    query = new StringBundler(4);
5481                            }
5482    
5483                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5484    
5485                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5486    
5487                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
5488    
5489                            if (orderByComparator != null) {
5490                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5491                                            orderByComparator);
5492                            }
5493                            else
5494                             if (pagination) {
5495                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5496                            }
5497    
5498                            String sql = query.toString();
5499    
5500                            Session session = null;
5501    
5502                            try {
5503                                    session = openSession();
5504    
5505                                    Query q = session.createQuery(sql);
5506    
5507                                    QueryPos qPos = QueryPos.getInstance(q);
5508    
5509                                    qPos.add(groupId);
5510    
5511                                    qPos.add(folderId);
5512    
5513                                    if (!pagination) {
5514                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
5515                                                            start, end, false);
5516    
5517                                            Collections.sort(list);
5518    
5519                                            list = Collections.unmodifiableList(list);
5520                                    }
5521                                    else {
5522                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
5523                                                            start, end);
5524                                    }
5525    
5526                                    cacheResult(list);
5527    
5528                                    finderCache.putResult(finderPath, finderArgs, list);
5529                            }
5530                            catch (Exception e) {
5531                                    finderCache.removeResult(finderPath, finderArgs);
5532    
5533                                    throw processException(e);
5534                            }
5535                            finally {
5536                                    closeSession(session);
5537                            }
5538                    }
5539    
5540                    return list;
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
5550             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
5551             */
5552            @Override
5553            public DLFileEntry findByG_F_First(long groupId, long folderId,
5554                    OrderByComparator<DLFileEntry> orderByComparator)
5555                    throws NoSuchFileEntryException {
5556                    DLFileEntry dlFileEntry = fetchByG_F_First(groupId, folderId,
5557                                    orderByComparator);
5558    
5559                    if (dlFileEntry != null) {
5560                            return dlFileEntry;
5561                    }
5562    
5563                    StringBundler msg = new StringBundler(6);
5564    
5565                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5566    
5567                    msg.append("groupId=");
5568                    msg.append(groupId);
5569    
5570                    msg.append(", folderId=");
5571                    msg.append(folderId);
5572    
5573                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5574    
5575                    throw new NoSuchFileEntryException(msg.toString());
5576            }
5577    
5578            /**
5579             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
5580             *
5581             * @param groupId the group ID
5582             * @param folderId the folder ID
5583             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5584             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5585             */
5586            @Override
5587            public DLFileEntry fetchByG_F_First(long groupId, long folderId,
5588                    OrderByComparator<DLFileEntry> orderByComparator) {
5589                    List<DLFileEntry> list = findByG_F(groupId, folderId, 0, 1,
5590                                    orderByComparator);
5591    
5592                    if (!list.isEmpty()) {
5593                            return list.get(0);
5594                    }
5595    
5596                    return null;
5597            }
5598    
5599            /**
5600             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
5601             *
5602             * @param groupId the group ID
5603             * @param folderId the folder ID
5604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5605             * @return the last matching document library file entry
5606             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
5607             */
5608            @Override
5609            public DLFileEntry findByG_F_Last(long groupId, long folderId,
5610                    OrderByComparator<DLFileEntry> orderByComparator)
5611                    throws NoSuchFileEntryException {
5612                    DLFileEntry dlFileEntry = fetchByG_F_Last(groupId, folderId,
5613                                    orderByComparator);
5614    
5615                    if (dlFileEntry != null) {
5616                            return dlFileEntry;
5617                    }
5618    
5619                    StringBundler msg = new StringBundler(6);
5620    
5621                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5622    
5623                    msg.append("groupId=");
5624                    msg.append(groupId);
5625    
5626                    msg.append(", folderId=");
5627                    msg.append(folderId);
5628    
5629                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5630    
5631                    throw new NoSuchFileEntryException(msg.toString());
5632            }
5633    
5634            /**
5635             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
5636             *
5637             * @param groupId the group ID
5638             * @param folderId the folder ID
5639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5640             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5641             */
5642            @Override
5643            public DLFileEntry fetchByG_F_Last(long groupId, long folderId,
5644                    OrderByComparator<DLFileEntry> orderByComparator) {
5645                    int count = countByG_F(groupId, folderId);
5646    
5647                    if (count == 0) {
5648                            return null;
5649                    }
5650    
5651                    List<DLFileEntry> list = findByG_F(groupId, folderId, count - 1, count,
5652                                    orderByComparator);
5653    
5654                    if (!list.isEmpty()) {
5655                            return list.get(0);
5656                    }
5657    
5658                    return null;
5659            }
5660    
5661            /**
5662             * 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;.
5663             *
5664             * @param fileEntryId the primary key of the current document library file entry
5665             * @param groupId the group ID
5666             * @param folderId the folder ID
5667             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5668             * @return the previous, current, and next document library file entry
5669             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
5670             */
5671            @Override
5672            public DLFileEntry[] findByG_F_PrevAndNext(long fileEntryId, long groupId,
5673                    long folderId, OrderByComparator<DLFileEntry> orderByComparator)
5674                    throws NoSuchFileEntryException {
5675                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
5676    
5677                    Session session = null;
5678    
5679                    try {
5680                            session = openSession();
5681    
5682                            DLFileEntry[] array = new DLFileEntryImpl[3];
5683    
5684                            array[0] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
5685                                            folderId, orderByComparator, true);
5686    
5687                            array[1] = dlFileEntry;
5688    
5689                            array[2] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
5690                                            folderId, orderByComparator, false);
5691    
5692                            return array;
5693                    }
5694                    catch (Exception e) {
5695                            throw processException(e);
5696                    }
5697                    finally {
5698                            closeSession(session);
5699                    }
5700            }
5701    
5702            protected DLFileEntry getByG_F_PrevAndNext(Session session,
5703                    DLFileEntry dlFileEntry, long groupId, long folderId,
5704                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
5705                    StringBundler query = null;
5706    
5707                    if (orderByComparator != null) {
5708                            query = new StringBundler(6 +
5709                                            (orderByComparator.getOrderByFields().length * 6));
5710                    }
5711                    else {
5712                            query = new StringBundler(3);
5713                    }
5714    
5715                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5716    
5717                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5718    
5719                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
5720    
5721                    if (orderByComparator != null) {
5722                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5723    
5724                            if (orderByConditionFields.length > 0) {
5725                                    query.append(WHERE_AND);
5726                            }
5727    
5728                            for (int i = 0; i < orderByConditionFields.length; i++) {
5729                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5730                                    query.append(orderByConditionFields[i]);
5731    
5732                                    if ((i + 1) < orderByConditionFields.length) {
5733                                            if (orderByComparator.isAscending() ^ previous) {
5734                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5735                                            }
5736                                            else {
5737                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5738                                            }
5739                                    }
5740                                    else {
5741                                            if (orderByComparator.isAscending() ^ previous) {
5742                                                    query.append(WHERE_GREATER_THAN);
5743                                            }
5744                                            else {
5745                                                    query.append(WHERE_LESSER_THAN);
5746                                            }
5747                                    }
5748                            }
5749    
5750                            query.append(ORDER_BY_CLAUSE);
5751    
5752                            String[] orderByFields = orderByComparator.getOrderByFields();
5753    
5754                            for (int i = 0; i < orderByFields.length; i++) {
5755                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5756                                    query.append(orderByFields[i]);
5757    
5758                                    if ((i + 1) < orderByFields.length) {
5759                                            if (orderByComparator.isAscending() ^ previous) {
5760                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5761                                            }
5762                                            else {
5763                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5764                                            }
5765                                    }
5766                                    else {
5767                                            if (orderByComparator.isAscending() ^ previous) {
5768                                                    query.append(ORDER_BY_ASC);
5769                                            }
5770                                            else {
5771                                                    query.append(ORDER_BY_DESC);
5772                                            }
5773                                    }
5774                            }
5775                    }
5776                    else {
5777                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5778                    }
5779    
5780                    String sql = query.toString();
5781    
5782                    Query q = session.createQuery(sql);
5783    
5784                    q.setFirstResult(0);
5785                    q.setMaxResults(2);
5786    
5787                    QueryPos qPos = QueryPos.getInstance(q);
5788    
5789                    qPos.add(groupId);
5790    
5791                    qPos.add(folderId);
5792    
5793                    if (orderByComparator != null) {
5794                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
5795    
5796                            for (Object value : values) {
5797                                    qPos.add(value);
5798                            }
5799                    }
5800    
5801                    List<DLFileEntry> list = q.list();
5802    
5803                    if (list.size() == 2) {
5804                            return list.get(1);
5805                    }
5806                    else {
5807                            return null;
5808                    }
5809            }
5810    
5811            /**
5812             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
5813             *
5814             * @param groupId the group ID
5815             * @param folderId the folder ID
5816             * @return the matching document library file entries that the user has permission to view
5817             */
5818            @Override
5819            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId) {
5820                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
5821                            QueryUtil.ALL_POS, null);
5822            }
5823    
5824            /**
5825             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
5826             *
5827             * <p>
5828             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5829             * </p>
5830             *
5831             * @param groupId the group ID
5832             * @param folderId the folder ID
5833             * @param start the lower bound of the range of document library file entries
5834             * @param end the upper bound of the range of document library file entries (not inclusive)
5835             * @return the range of matching document library file entries that the user has permission to view
5836             */
5837            @Override
5838            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
5839                    int start, int end) {
5840                    return filterFindByG_F(groupId, folderId, start, end, null);
5841            }
5842    
5843            /**
5844             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and folderId = &#63;.
5845             *
5846             * <p>
5847             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5848             * </p>
5849             *
5850             * @param groupId the group ID
5851             * @param folderId the folder ID
5852             * @param start the lower bound of the range of document library file entries
5853             * @param end the upper bound of the range of document library file entries (not inclusive)
5854             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5855             * @return the ordered range of matching document library file entries that the user has permission to view
5856             */
5857            @Override
5858            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
5859                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
5860                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5861                            return findByG_F(groupId, folderId, start, end, orderByComparator);
5862                    }
5863    
5864                    StringBundler query = null;
5865    
5866                    if (orderByComparator != null) {
5867                            query = new StringBundler(4 +
5868                                            (orderByComparator.getOrderByFields().length * 3));
5869                    }
5870                    else {
5871                            query = new StringBundler(4);
5872                    }
5873    
5874                    if (getDB().isSupportsInlineDistinct()) {
5875                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
5876                    }
5877                    else {
5878                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
5879                    }
5880    
5881                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
5882    
5883                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
5884    
5885                    if (!getDB().isSupportsInlineDistinct()) {
5886                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
5887                    }
5888    
5889                    if (orderByComparator != null) {
5890                            if (getDB().isSupportsInlineDistinct()) {
5891                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5892                                            orderByComparator, true);
5893                            }
5894                            else {
5895                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5896                                            orderByComparator, true);
5897                            }
5898                    }
5899                    else {
5900                            if (getDB().isSupportsInlineDistinct()) {
5901                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5902                            }
5903                            else {
5904                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
5905                            }
5906                    }
5907    
5908                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5909                                    DLFileEntry.class.getName(),
5910                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5911    
5912                    Session session = null;
5913    
5914                    try {
5915                            session = openSession();
5916    
5917                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5918    
5919                            if (getDB().isSupportsInlineDistinct()) {
5920                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5921                            }
5922                            else {
5923                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5924                            }
5925    
5926                            QueryPos qPos = QueryPos.getInstance(q);
5927    
5928                            qPos.add(groupId);
5929    
5930                            qPos.add(folderId);
5931    
5932                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
5933                    }
5934                    catch (Exception e) {
5935                            throw processException(e);
5936                    }
5937                    finally {
5938                            closeSession(session);
5939                    }
5940            }
5941    
5942            /**
5943             * 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;.
5944             *
5945             * @param fileEntryId the primary key of the current document library file entry
5946             * @param groupId the group ID
5947             * @param folderId the folder ID
5948             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5949             * @return the previous, current, and next document library file entry
5950             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
5951             */
5952            @Override
5953            public DLFileEntry[] filterFindByG_F_PrevAndNext(long fileEntryId,
5954                    long groupId, long folderId,
5955                    OrderByComparator<DLFileEntry> orderByComparator)
5956                    throws NoSuchFileEntryException {
5957                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5958                            return findByG_F_PrevAndNext(fileEntryId, groupId, folderId,
5959                                    orderByComparator);
5960                    }
5961    
5962                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
5963    
5964                    Session session = null;
5965    
5966                    try {
5967                            session = openSession();
5968    
5969                            DLFileEntry[] array = new DLFileEntryImpl[3];
5970    
5971                            array[0] = filterGetByG_F_PrevAndNext(session, dlFileEntry,
5972                                            groupId, folderId, orderByComparator, true);
5973    
5974                            array[1] = dlFileEntry;
5975    
5976                            array[2] = filterGetByG_F_PrevAndNext(session, dlFileEntry,
5977                                            groupId, folderId, orderByComparator, false);
5978    
5979                            return array;
5980                    }
5981                    catch (Exception e) {
5982                            throw processException(e);
5983                    }
5984                    finally {
5985                            closeSession(session);
5986                    }
5987            }
5988    
5989            protected DLFileEntry filterGetByG_F_PrevAndNext(Session session,
5990                    DLFileEntry dlFileEntry, long groupId, long folderId,
5991                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
5992                    StringBundler query = null;
5993    
5994                    if (orderByComparator != null) {
5995                            query = new StringBundler(6 +
5996                                            (orderByComparator.getOrderByFields().length * 6));
5997                    }
5998                    else {
5999                            query = new StringBundler(3);
6000                    }
6001    
6002                    if (getDB().isSupportsInlineDistinct()) {
6003                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
6004                    }
6005                    else {
6006                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
6007                    }
6008    
6009                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6010    
6011                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
6012    
6013                    if (!getDB().isSupportsInlineDistinct()) {
6014                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
6015                    }
6016    
6017                    if (orderByComparator != null) {
6018                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6019    
6020                            if (orderByConditionFields.length > 0) {
6021                                    query.append(WHERE_AND);
6022                            }
6023    
6024                            for (int i = 0; i < orderByConditionFields.length; i++) {
6025                                    if (getDB().isSupportsInlineDistinct()) {
6026                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6027                                    }
6028                                    else {
6029                                            query.append(_ORDER_BY_ENTITY_TABLE);
6030                                    }
6031    
6032                                    query.append(orderByConditionFields[i]);
6033    
6034                                    if ((i + 1) < orderByConditionFields.length) {
6035                                            if (orderByComparator.isAscending() ^ previous) {
6036                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6037                                            }
6038                                            else {
6039                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6040                                            }
6041                                    }
6042                                    else {
6043                                            if (orderByComparator.isAscending() ^ previous) {
6044                                                    query.append(WHERE_GREATER_THAN);
6045                                            }
6046                                            else {
6047                                                    query.append(WHERE_LESSER_THAN);
6048                                            }
6049                                    }
6050                            }
6051    
6052                            query.append(ORDER_BY_CLAUSE);
6053    
6054                            String[] orderByFields = orderByComparator.getOrderByFields();
6055    
6056                            for (int i = 0; i < orderByFields.length; i++) {
6057                                    if (getDB().isSupportsInlineDistinct()) {
6058                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6059                                    }
6060                                    else {
6061                                            query.append(_ORDER_BY_ENTITY_TABLE);
6062                                    }
6063    
6064                                    query.append(orderByFields[i]);
6065    
6066                                    if ((i + 1) < orderByFields.length) {
6067                                            if (orderByComparator.isAscending() ^ previous) {
6068                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6069                                            }
6070                                            else {
6071                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6072                                            }
6073                                    }
6074                                    else {
6075                                            if (orderByComparator.isAscending() ^ previous) {
6076                                                    query.append(ORDER_BY_ASC);
6077                                            }
6078                                            else {
6079                                                    query.append(ORDER_BY_DESC);
6080                                            }
6081                                    }
6082                            }
6083                    }
6084                    else {
6085                            if (getDB().isSupportsInlineDistinct()) {
6086                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6087                            }
6088                            else {
6089                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6090                            }
6091                    }
6092    
6093                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6094                                    DLFileEntry.class.getName(),
6095                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6096    
6097                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
6098    
6099                    q.setFirstResult(0);
6100                    q.setMaxResults(2);
6101    
6102                    if (getDB().isSupportsInlineDistinct()) {
6103                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6104                    }
6105                    else {
6106                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6107                    }
6108    
6109                    QueryPos qPos = QueryPos.getInstance(q);
6110    
6111                    qPos.add(groupId);
6112    
6113                    qPos.add(folderId);
6114    
6115                    if (orderByComparator != null) {
6116                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
6117    
6118                            for (Object value : values) {
6119                                    qPos.add(value);
6120                            }
6121                    }
6122    
6123                    List<DLFileEntry> list = q.list();
6124    
6125                    if (list.size() == 2) {
6126                            return list.get(1);
6127                    }
6128                    else {
6129                            return null;
6130                    }
6131            }
6132    
6133            /**
6134             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
6135             *
6136             * @param groupId the group ID
6137             * @param folderIds the folder IDs
6138             * @return the matching document library file entries that the user has permission to view
6139             */
6140            @Override
6141            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds) {
6142                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
6143                            QueryUtil.ALL_POS, null);
6144            }
6145    
6146            /**
6147             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
6148             *
6149             * <p>
6150             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6151             * </p>
6152             *
6153             * @param groupId the group ID
6154             * @param folderIds the folder IDs
6155             * @param start the lower bound of the range of document library file entries
6156             * @param end the upper bound of the range of document library file entries (not inclusive)
6157             * @return the range of matching document library file entries that the user has permission to view
6158             */
6159            @Override
6160            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
6161                    int start, int end) {
6162                    return filterFindByG_F(groupId, folderIds, start, end, null);
6163            }
6164    
6165            /**
6166             * 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;.
6167             *
6168             * <p>
6169             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6170             * </p>
6171             *
6172             * @param groupId the group ID
6173             * @param folderIds the folder IDs
6174             * @param start the lower bound of the range of document library file entries
6175             * @param end the upper bound of the range of document library file entries (not inclusive)
6176             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6177             * @return the ordered range of matching document library file entries that the user has permission to view
6178             */
6179            @Override
6180            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
6181                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
6182                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6183                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
6184                    }
6185    
6186                    if (folderIds == null) {
6187                            folderIds = new long[0];
6188                    }
6189                    else if (folderIds.length > 1) {
6190                            folderIds = ArrayUtil.unique(folderIds);
6191    
6192                            Arrays.sort(folderIds);
6193                    }
6194    
6195                    StringBundler query = new StringBundler();
6196    
6197                    if (getDB().isSupportsInlineDistinct()) {
6198                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
6199                    }
6200                    else {
6201                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
6202                    }
6203    
6204                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6205    
6206                    if (folderIds.length > 0) {
6207                            query.append(StringPool.OPEN_PARENTHESIS);
6208    
6209                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
6210    
6211                            query.append(StringUtil.merge(folderIds));
6212    
6213                            query.append(StringPool.CLOSE_PARENTHESIS);
6214    
6215                            query.append(StringPool.CLOSE_PARENTHESIS);
6216                    }
6217    
6218                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
6219                            query.index() - 1);
6220    
6221                    if (!getDB().isSupportsInlineDistinct()) {
6222                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
6223                    }
6224    
6225                    if (orderByComparator != null) {
6226                            if (getDB().isSupportsInlineDistinct()) {
6227                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6228                                            orderByComparator, true);
6229                            }
6230                            else {
6231                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6232                                            orderByComparator, true);
6233                            }
6234                    }
6235                    else {
6236                            if (getDB().isSupportsInlineDistinct()) {
6237                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6238                            }
6239                            else {
6240                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6241                            }
6242                    }
6243    
6244                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6245                                    DLFileEntry.class.getName(),
6246                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6247    
6248                    Session session = null;
6249    
6250                    try {
6251                            session = openSession();
6252    
6253                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6254    
6255                            if (getDB().isSupportsInlineDistinct()) {
6256                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6257                            }
6258                            else {
6259                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6260                            }
6261    
6262                            QueryPos qPos = QueryPos.getInstance(q);
6263    
6264                            qPos.add(groupId);
6265    
6266                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
6267                    }
6268                    catch (Exception e) {
6269                            throw processException(e);
6270                    }
6271                    finally {
6272                            closeSession(session);
6273                    }
6274            }
6275    
6276            /**
6277             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63;.
6278             *
6279             * <p>
6280             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6281             * </p>
6282             *
6283             * @param groupId the group ID
6284             * @param folderIds the folder IDs
6285             * @return the matching document library file entries
6286             */
6287            @Override
6288            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds) {
6289                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
6290                            QueryUtil.ALL_POS, null);
6291            }
6292    
6293            /**
6294             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63;.
6295             *
6296             * <p>
6297             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6298             * </p>
6299             *
6300             * @param groupId the group ID
6301             * @param folderIds the folder IDs
6302             * @param start the lower bound of the range of document library file entries
6303             * @param end the upper bound of the range of document library file entries (not inclusive)
6304             * @return the range of matching document library file entries
6305             */
6306            @Override
6307            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
6308                    int start, int end) {
6309                    return findByG_F(groupId, folderIds, start, end, null);
6310            }
6311    
6312            /**
6313             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63;.
6314             *
6315             * <p>
6316             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6317             * </p>
6318             *
6319             * @param groupId the group ID
6320             * @param folderIds the folder IDs
6321             * @param start the lower bound of the range of document library file entries
6322             * @param end the upper bound of the range of document library file entries (not inclusive)
6323             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6324             * @return the ordered range of matching document library file entries
6325             */
6326            @Override
6327            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
6328                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
6329                    return findByG_F(groupId, folderIds, start, end, orderByComparator, true);
6330            }
6331    
6332            /**
6333             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63;, optionally using the finder cache.
6334             *
6335             * <p>
6336             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6337             * </p>
6338             *
6339             * @param groupId the group ID
6340             * @param folderId the folder ID
6341             * @param start the lower bound of the range of document library file entries
6342             * @param end the upper bound of the range of document library file entries (not inclusive)
6343             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6344             * @param retrieveFromCache whether to retrieve from the finder cache
6345             * @return the ordered range of matching document library file entries
6346             */
6347            @Override
6348            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
6349                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator,
6350                    boolean retrieveFromCache) {
6351                    if (folderIds == null) {
6352                            folderIds = new long[0];
6353                    }
6354                    else if (folderIds.length > 1) {
6355                            folderIds = ArrayUtil.unique(folderIds);
6356    
6357                            Arrays.sort(folderIds);
6358                    }
6359    
6360                    if (folderIds.length == 1) {
6361                            return findByG_F(groupId, folderIds[0], start, end,
6362                                    orderByComparator);
6363                    }
6364    
6365                    boolean pagination = true;
6366                    Object[] finderArgs = null;
6367    
6368                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6369                                    (orderByComparator == null)) {
6370                            pagination = false;
6371                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
6372                    }
6373                    else {
6374                            finderArgs = new Object[] {
6375                                            groupId, StringUtil.merge(folderIds),
6376                                            
6377                                            start, end, orderByComparator
6378                                    };
6379                    }
6380    
6381                    List<DLFileEntry> list = null;
6382    
6383                    if (retrieveFromCache) {
6384                            list = (List<DLFileEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
6385                                            finderArgs, this);
6386    
6387                            if ((list != null) && !list.isEmpty()) {
6388                                    for (DLFileEntry dlFileEntry : list) {
6389                                            if ((groupId != dlFileEntry.getGroupId()) ||
6390                                                            !ArrayUtil.contains(folderIds,
6391                                                                    dlFileEntry.getFolderId())) {
6392                                                    list = null;
6393    
6394                                                    break;
6395                                            }
6396                                    }
6397                            }
6398                    }
6399    
6400                    if (list == null) {
6401                            StringBundler query = new StringBundler();
6402    
6403                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
6404    
6405                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6406    
6407                            if (folderIds.length > 0) {
6408                                    query.append(StringPool.OPEN_PARENTHESIS);
6409    
6410                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
6411    
6412                                    query.append(StringUtil.merge(folderIds));
6413    
6414                                    query.append(StringPool.CLOSE_PARENTHESIS);
6415    
6416                                    query.append(StringPool.CLOSE_PARENTHESIS);
6417                            }
6418    
6419                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
6420                                                    1)), query.index() - 1);
6421    
6422                            if (orderByComparator != null) {
6423                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6424                                            orderByComparator);
6425                            }
6426                            else
6427                             if (pagination) {
6428                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6429                            }
6430    
6431                            String sql = query.toString();
6432    
6433                            Session session = null;
6434    
6435                            try {
6436                                    session = openSession();
6437    
6438                                    Query q = session.createQuery(sql);
6439    
6440                                    QueryPos qPos = QueryPos.getInstance(q);
6441    
6442                                    qPos.add(groupId);
6443    
6444                                    if (!pagination) {
6445                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6446                                                            start, end, false);
6447    
6448                                            Collections.sort(list);
6449    
6450                                            list = Collections.unmodifiableList(list);
6451                                    }
6452                                    else {
6453                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6454                                                            start, end);
6455                                    }
6456    
6457                                    cacheResult(list);
6458    
6459                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
6460                                            finderArgs, list);
6461                            }
6462                            catch (Exception e) {
6463                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
6464                                            finderArgs);
6465    
6466                                    throw processException(e);
6467                            }
6468                            finally {
6469                                    closeSession(session);
6470                            }
6471                    }
6472    
6473                    return list;
6474            }
6475    
6476            /**
6477             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; from the database.
6478             *
6479             * @param groupId the group ID
6480             * @param folderId the folder ID
6481             */
6482            @Override
6483            public void removeByG_F(long groupId, long folderId) {
6484                    for (DLFileEntry dlFileEntry : findByG_F(groupId, folderId,
6485                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6486                            remove(dlFileEntry);
6487                    }
6488            }
6489    
6490            /**
6491             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63;.
6492             *
6493             * @param groupId the group ID
6494             * @param folderId the folder ID
6495             * @return the number of matching document library file entries
6496             */
6497            @Override
6498            public int countByG_F(long groupId, long folderId) {
6499                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
6500    
6501                    Object[] finderArgs = new Object[] { groupId, folderId };
6502    
6503                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6504    
6505                    if (count == null) {
6506                            StringBundler query = new StringBundler(3);
6507    
6508                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
6509    
6510                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6511    
6512                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
6513    
6514                            String sql = query.toString();
6515    
6516                            Session session = null;
6517    
6518                            try {
6519                                    session = openSession();
6520    
6521                                    Query q = session.createQuery(sql);
6522    
6523                                    QueryPos qPos = QueryPos.getInstance(q);
6524    
6525                                    qPos.add(groupId);
6526    
6527                                    qPos.add(folderId);
6528    
6529                                    count = (Long)q.uniqueResult();
6530    
6531                                    finderCache.putResult(finderPath, finderArgs, count);
6532                            }
6533                            catch (Exception e) {
6534                                    finderCache.removeResult(finderPath, finderArgs);
6535    
6536                                    throw processException(e);
6537                            }
6538                            finally {
6539                                    closeSession(session);
6540                            }
6541                    }
6542    
6543                    return count.intValue();
6544            }
6545    
6546            /**
6547             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63;.
6548             *
6549             * @param groupId the group ID
6550             * @param folderIds the folder IDs
6551             * @return the number of matching document library file entries
6552             */
6553            @Override
6554            public int countByG_F(long groupId, long[] folderIds) {
6555                    if (folderIds == null) {
6556                            folderIds = new long[0];
6557                    }
6558                    else if (folderIds.length > 1) {
6559                            folderIds = ArrayUtil.unique(folderIds);
6560    
6561                            Arrays.sort(folderIds);
6562                    }
6563    
6564                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
6565    
6566                    Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
6567                                    finderArgs, this);
6568    
6569                    if (count == null) {
6570                            StringBundler query = new StringBundler();
6571    
6572                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
6573    
6574                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6575    
6576                            if (folderIds.length > 0) {
6577                                    query.append(StringPool.OPEN_PARENTHESIS);
6578    
6579                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
6580    
6581                                    query.append(StringUtil.merge(folderIds));
6582    
6583                                    query.append(StringPool.CLOSE_PARENTHESIS);
6584    
6585                                    query.append(StringPool.CLOSE_PARENTHESIS);
6586                            }
6587    
6588                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
6589                                                    1)), query.index() - 1);
6590    
6591                            String sql = query.toString();
6592    
6593                            Session session = null;
6594    
6595                            try {
6596                                    session = openSession();
6597    
6598                                    Query q = session.createQuery(sql);
6599    
6600                                    QueryPos qPos = QueryPos.getInstance(q);
6601    
6602                                    qPos.add(groupId);
6603    
6604                                    count = (Long)q.uniqueResult();
6605    
6606                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
6607                                            finderArgs, count);
6608                            }
6609                            catch (Exception e) {
6610                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
6611                                            finderArgs);
6612    
6613                                    throw processException(e);
6614                            }
6615                            finally {
6616                                    closeSession(session);
6617                            }
6618                    }
6619    
6620                    return count.intValue();
6621            }
6622    
6623            /**
6624             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
6625             *
6626             * @param groupId the group ID
6627             * @param folderId the folder ID
6628             * @return the number of matching document library file entries that the user has permission to view
6629             */
6630            @Override
6631            public int filterCountByG_F(long groupId, long folderId) {
6632                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6633                            return countByG_F(groupId, folderId);
6634                    }
6635    
6636                    StringBundler query = new StringBundler(3);
6637    
6638                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
6639    
6640                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6641    
6642                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
6643    
6644                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6645                                    DLFileEntry.class.getName(),
6646                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6647    
6648                    Session session = null;
6649    
6650                    try {
6651                            session = openSession();
6652    
6653                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6654    
6655                            q.addScalar(COUNT_COLUMN_NAME,
6656                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6657    
6658                            QueryPos qPos = QueryPos.getInstance(q);
6659    
6660                            qPos.add(groupId);
6661    
6662                            qPos.add(folderId);
6663    
6664                            Long count = (Long)q.uniqueResult();
6665    
6666                            return count.intValue();
6667                    }
6668                    catch (Exception e) {
6669                            throw processException(e);
6670                    }
6671                    finally {
6672                            closeSession(session);
6673                    }
6674            }
6675    
6676            /**
6677             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
6678             *
6679             * @param groupId the group ID
6680             * @param folderIds the folder IDs
6681             * @return the number of matching document library file entries that the user has permission to view
6682             */
6683            @Override
6684            public int filterCountByG_F(long groupId, long[] folderIds) {
6685                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6686                            return countByG_F(groupId, folderIds);
6687                    }
6688    
6689                    if (folderIds == null) {
6690                            folderIds = new long[0];
6691                    }
6692                    else if (folderIds.length > 1) {
6693                            folderIds = ArrayUtil.unique(folderIds);
6694    
6695                            Arrays.sort(folderIds);
6696                    }
6697    
6698                    StringBundler query = new StringBundler();
6699    
6700                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
6701    
6702                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
6703    
6704                    if (folderIds.length > 0) {
6705                            query.append(StringPool.OPEN_PARENTHESIS);
6706    
6707                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
6708    
6709                            query.append(StringUtil.merge(folderIds));
6710    
6711                            query.append(StringPool.CLOSE_PARENTHESIS);
6712    
6713                            query.append(StringPool.CLOSE_PARENTHESIS);
6714                    }
6715    
6716                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
6717                            query.index() - 1);
6718    
6719                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6720                                    DLFileEntry.class.getName(),
6721                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6722    
6723                    Session session = null;
6724    
6725                    try {
6726                            session = openSession();
6727    
6728                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
6729    
6730                            q.addScalar(COUNT_COLUMN_NAME,
6731                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6732    
6733                            QueryPos qPos = QueryPos.getInstance(q);
6734    
6735                            qPos.add(groupId);
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_FOLDERID_2 = "dlFileEntry.folderId = ?";
6751            private static final String _FINDER_COLUMN_G_F_FOLDERID_7 = "dlFileEntry.folderId IN (";
6752            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6753                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
6754                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByR_F",
6755                            new String[] {
6756                                    Long.class.getName(), Long.class.getName(),
6757                                    
6758                            Integer.class.getName(), Integer.class.getName(),
6759                                    OrderByComparator.class.getName()
6760                            });
6761            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6762                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
6763                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_F",
6764                            new String[] { Long.class.getName(), Long.class.getName() },
6765                            DLFileEntryModelImpl.REPOSITORYID_COLUMN_BITMASK |
6766                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
6767                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
6768            public static final FinderPath FINDER_PATH_COUNT_BY_R_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
6769                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6770                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_F",
6771                            new String[] { Long.class.getName(), Long.class.getName() });
6772    
6773            /**
6774             * Returns all the document library file entries where repositoryId = &#63; and folderId = &#63;.
6775             *
6776             * @param repositoryId the repository ID
6777             * @param folderId the folder ID
6778             * @return the matching document library file entries
6779             */
6780            @Override
6781            public List<DLFileEntry> findByR_F(long repositoryId, long folderId) {
6782                    return findByR_F(repositoryId, folderId, QueryUtil.ALL_POS,
6783                            QueryUtil.ALL_POS, null);
6784            }
6785    
6786            /**
6787             * Returns a range of all the document library file entries where repositoryId = &#63; and folderId = &#63;.
6788             *
6789             * <p>
6790             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6791             * </p>
6792             *
6793             * @param repositoryId the repository ID
6794             * @param folderId the folder ID
6795             * @param start the lower bound of the range of document library file entries
6796             * @param end the upper bound of the range of document library file entries (not inclusive)
6797             * @return the range of matching document library file entries
6798             */
6799            @Override
6800            public List<DLFileEntry> findByR_F(long repositoryId, long folderId,
6801                    int start, int end) {
6802                    return findByR_F(repositoryId, folderId, start, end, null);
6803            }
6804    
6805            /**
6806             * Returns an ordered range of all the document library file entries where repositoryId = &#63; and folderId = &#63;.
6807             *
6808             * <p>
6809             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6810             * </p>
6811             *
6812             * @param repositoryId the repository ID
6813             * @param folderId the folder ID
6814             * @param start the lower bound of the range of document library file entries
6815             * @param end the upper bound of the range of document library file entries (not inclusive)
6816             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6817             * @return the ordered range of matching document library file entries
6818             */
6819            @Override
6820            public List<DLFileEntry> findByR_F(long repositoryId, long folderId,
6821                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator) {
6822                    return findByR_F(repositoryId, folderId, start, end, orderByComparator,
6823                            true);
6824            }
6825    
6826            /**
6827             * Returns an ordered range of all the document library file entries where repositoryId = &#63; and folderId = &#63;.
6828             *
6829             * <p>
6830             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6831             * </p>
6832             *
6833             * @param repositoryId the repository ID
6834             * @param folderId the folder ID
6835             * @param start the lower bound of the range of document library file entries
6836             * @param end the upper bound of the range of document library file entries (not inclusive)
6837             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6838             * @param retrieveFromCache whether to retrieve from the finder cache
6839             * @return the ordered range of matching document library file entries
6840             */
6841            @Override
6842            public List<DLFileEntry> findByR_F(long repositoryId, long folderId,
6843                    int start, int end, OrderByComparator<DLFileEntry> orderByComparator,
6844                    boolean retrieveFromCache) {
6845                    boolean pagination = true;
6846                    FinderPath finderPath = null;
6847                    Object[] finderArgs = null;
6848    
6849                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6850                                    (orderByComparator == null)) {
6851                            pagination = false;
6852                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F;
6853                            finderArgs = new Object[] { repositoryId, folderId };
6854                    }
6855                    else {
6856                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_F;
6857                            finderArgs = new Object[] {
6858                                            repositoryId, folderId,
6859                                            
6860                                            start, end, orderByComparator
6861                                    };
6862                    }
6863    
6864                    List<DLFileEntry> list = null;
6865    
6866                    if (retrieveFromCache) {
6867                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
6868                                            finderArgs, this);
6869    
6870                            if ((list != null) && !list.isEmpty()) {
6871                                    for (DLFileEntry dlFileEntry : list) {
6872                                            if ((repositoryId != dlFileEntry.getRepositoryId()) ||
6873                                                            (folderId != dlFileEntry.getFolderId())) {
6874                                                    list = null;
6875    
6876                                                    break;
6877                                            }
6878                                    }
6879                            }
6880                    }
6881    
6882                    if (list == null) {
6883                            StringBundler query = null;
6884    
6885                            if (orderByComparator != null) {
6886                                    query = new StringBundler(4 +
6887                                                    (orderByComparator.getOrderByFields().length * 3));
6888                            }
6889                            else {
6890                                    query = new StringBundler(4);
6891                            }
6892    
6893                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
6894    
6895                            query.append(_FINDER_COLUMN_R_F_REPOSITORYID_2);
6896    
6897                            query.append(_FINDER_COLUMN_R_F_FOLDERID_2);
6898    
6899                            if (orderByComparator != null) {
6900                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6901                                            orderByComparator);
6902                            }
6903                            else
6904                             if (pagination) {
6905                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6906                            }
6907    
6908                            String sql = query.toString();
6909    
6910                            Session session = null;
6911    
6912                            try {
6913                                    session = openSession();
6914    
6915                                    Query q = session.createQuery(sql);
6916    
6917                                    QueryPos qPos = QueryPos.getInstance(q);
6918    
6919                                    qPos.add(repositoryId);
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 = Collections.unmodifiableList(list);
6930                                    }
6931                                    else {
6932                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6933                                                            start, end);
6934                                    }
6935    
6936                                    cacheResult(list);
6937    
6938                                    finderCache.putResult(finderPath, finderArgs, list);
6939                            }
6940                            catch (Exception e) {
6941                                    finderCache.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 repositoryId = &#63; and folderId = &#63;.
6955             *
6956             * @param repositoryId the repository ID
6957             * @param folderId the folder ID
6958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6959             * @return the first matching document library file entry
6960             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
6961             */
6962            @Override
6963            public DLFileEntry findByR_F_First(long repositoryId, long folderId,
6964                    OrderByComparator<DLFileEntry> orderByComparator)
6965                    throws NoSuchFileEntryException {
6966                    DLFileEntry dlFileEntry = fetchByR_F_First(repositoryId, folderId,
6967                                    orderByComparator);
6968    
6969                    if (dlFileEntry != null) {
6970                            return dlFileEntry;
6971                    }
6972    
6973                    StringBundler msg = new StringBundler(6);
6974    
6975                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6976    
6977                    msg.append("repositoryId=");
6978                    msg.append(repositoryId);
6979    
6980                    msg.append(", folderId=");
6981                    msg.append(folderId);
6982    
6983                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6984    
6985                    throw new NoSuchFileEntryException(msg.toString());
6986            }
6987    
6988            /**
6989             * Returns the first document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
6990             *
6991             * @param repositoryId the repository ID
6992             * @param folderId the folder ID
6993             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6994             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
6995             */
6996            @Override
6997            public DLFileEntry fetchByR_F_First(long repositoryId, long folderId,
6998                    OrderByComparator<DLFileEntry> orderByComparator) {
6999                    List<DLFileEntry> list = findByR_F(repositoryId, folderId, 0, 1,
7000                                    orderByComparator);
7001    
7002                    if (!list.isEmpty()) {
7003                            return list.get(0);
7004                    }
7005    
7006                    return null;
7007            }
7008    
7009            /**
7010             * Returns the last document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
7011             *
7012             * @param repositoryId the repository ID
7013             * @param folderId the folder ID
7014             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7015             * @return the last matching document library file entry
7016             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
7017             */
7018            @Override
7019            public DLFileEntry findByR_F_Last(long repositoryId, long folderId,
7020                    OrderByComparator<DLFileEntry> orderByComparator)
7021                    throws NoSuchFileEntryException {
7022                    DLFileEntry dlFileEntry = fetchByR_F_Last(repositoryId, folderId,
7023                                    orderByComparator);
7024    
7025                    if (dlFileEntry != null) {
7026                            return dlFileEntry;
7027                    }
7028    
7029                    StringBundler msg = new StringBundler(6);
7030    
7031                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7032    
7033                    msg.append("repositoryId=");
7034                    msg.append(repositoryId);
7035    
7036                    msg.append(", folderId=");
7037                    msg.append(folderId);
7038    
7039                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7040    
7041                    throw new NoSuchFileEntryException(msg.toString());
7042            }
7043    
7044            /**
7045             * Returns the last document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
7046             *
7047             * @param repositoryId the repository ID
7048             * @param folderId the folder ID
7049             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7050             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7051             */
7052            @Override
7053            public DLFileEntry fetchByR_F_Last(long repositoryId, long folderId,
7054                    OrderByComparator<DLFileEntry> orderByComparator) {
7055                    int count = countByR_F(repositoryId, folderId);
7056    
7057                    if (count == 0) {
7058                            return null;
7059                    }
7060    
7061                    List<DLFileEntry> list = findByR_F(repositoryId, folderId, count - 1,
7062                                    count, orderByComparator);
7063    
7064                    if (!list.isEmpty()) {
7065                            return list.get(0);
7066                    }
7067    
7068                    return null;
7069            }
7070    
7071            /**
7072             * Returns the document library file entries before and after the current document library file entry in the ordered set where repositoryId = &#63; and folderId = &#63;.
7073             *
7074             * @param fileEntryId the primary key of the current document library file entry
7075             * @param repositoryId the repository ID
7076             * @param folderId the folder ID
7077             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7078             * @return the previous, current, and next document library file entry
7079             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
7080             */
7081            @Override
7082            public DLFileEntry[] findByR_F_PrevAndNext(long fileEntryId,
7083                    long repositoryId, long folderId,
7084                    OrderByComparator<DLFileEntry> orderByComparator)
7085                    throws NoSuchFileEntryException {
7086                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
7087    
7088                    Session session = null;
7089    
7090                    try {
7091                            session = openSession();
7092    
7093                            DLFileEntry[] array = new DLFileEntryImpl[3];
7094    
7095                            array[0] = getByR_F_PrevAndNext(session, dlFileEntry, repositoryId,
7096                                            folderId, orderByComparator, true);
7097    
7098                            array[1] = dlFileEntry;
7099    
7100                            array[2] = getByR_F_PrevAndNext(session, dlFileEntry, repositoryId,
7101                                            folderId, orderByComparator, false);
7102    
7103                            return array;
7104                    }
7105                    catch (Exception e) {
7106                            throw processException(e);
7107                    }
7108                    finally {
7109                            closeSession(session);
7110                    }
7111            }
7112    
7113            protected DLFileEntry getByR_F_PrevAndNext(Session session,
7114                    DLFileEntry dlFileEntry, long repositoryId, long folderId,
7115                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
7116                    StringBundler query = null;
7117    
7118                    if (orderByComparator != null) {
7119                            query = new StringBundler(6 +
7120                                            (orderByComparator.getOrderByFields().length * 6));
7121                    }
7122                    else {
7123                            query = new StringBundler(3);
7124                    }
7125    
7126                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7127    
7128                    query.append(_FINDER_COLUMN_R_F_REPOSITORYID_2);
7129    
7130                    query.append(_FINDER_COLUMN_R_F_FOLDERID_2);
7131    
7132                    if (orderByComparator != null) {
7133                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7134    
7135                            if (orderByConditionFields.length > 0) {
7136                                    query.append(WHERE_AND);
7137                            }
7138    
7139                            for (int i = 0; i < orderByConditionFields.length; i++) {
7140                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7141                                    query.append(orderByConditionFields[i]);
7142    
7143                                    if ((i + 1) < orderByConditionFields.length) {
7144                                            if (orderByComparator.isAscending() ^ previous) {
7145                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7146                                            }
7147                                            else {
7148                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7149                                            }
7150                                    }
7151                                    else {
7152                                            if (orderByComparator.isAscending() ^ previous) {
7153                                                    query.append(WHERE_GREATER_THAN);
7154                                            }
7155                                            else {
7156                                                    query.append(WHERE_LESSER_THAN);
7157                                            }
7158                                    }
7159                            }
7160    
7161                            query.append(ORDER_BY_CLAUSE);
7162    
7163                            String[] orderByFields = orderByComparator.getOrderByFields();
7164    
7165                            for (int i = 0; i < orderByFields.length; i++) {
7166                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7167                                    query.append(orderByFields[i]);
7168    
7169                                    if ((i + 1) < orderByFields.length) {
7170                                            if (orderByComparator.isAscending() ^ previous) {
7171                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7172                                            }
7173                                            else {
7174                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7175                                            }
7176                                    }
7177                                    else {
7178                                            if (orderByComparator.isAscending() ^ previous) {
7179                                                    query.append(ORDER_BY_ASC);
7180                                            }
7181                                            else {
7182                                                    query.append(ORDER_BY_DESC);
7183                                            }
7184                                    }
7185                            }
7186                    }
7187                    else {
7188                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7189                    }
7190    
7191                    String sql = query.toString();
7192    
7193                    Query q = session.createQuery(sql);
7194    
7195                    q.setFirstResult(0);
7196                    q.setMaxResults(2);
7197    
7198                    QueryPos qPos = QueryPos.getInstance(q);
7199    
7200                    qPos.add(repositoryId);
7201    
7202                    qPos.add(folderId);
7203    
7204                    if (orderByComparator != null) {
7205                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
7206    
7207                            for (Object value : values) {
7208                                    qPos.add(value);
7209                            }
7210                    }
7211    
7212                    List<DLFileEntry> list = q.list();
7213    
7214                    if (list.size() == 2) {
7215                            return list.get(1);
7216                    }
7217                    else {
7218                            return null;
7219                    }
7220            }
7221    
7222            /**
7223             * Removes all the document library file entries where repositoryId = &#63; and folderId = &#63; from the database.
7224             *
7225             * @param repositoryId the repository ID
7226             * @param folderId the folder ID
7227             */
7228            @Override
7229            public void removeByR_F(long repositoryId, long folderId) {
7230                    for (DLFileEntry dlFileEntry : findByR_F(repositoryId, folderId,
7231                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7232                            remove(dlFileEntry);
7233                    }
7234            }
7235    
7236            /**
7237             * Returns the number of document library file entries where repositoryId = &#63; and folderId = &#63;.
7238             *
7239             * @param repositoryId the repository ID
7240             * @param folderId the folder ID
7241             * @return the number of matching document library file entries
7242             */
7243            @Override
7244            public int countByR_F(long repositoryId, long folderId) {
7245                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_F;
7246    
7247                    Object[] finderArgs = new Object[] { repositoryId, folderId };
7248    
7249                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7250    
7251                    if (count == null) {
7252                            StringBundler query = new StringBundler(3);
7253    
7254                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7255    
7256                            query.append(_FINDER_COLUMN_R_F_REPOSITORYID_2);
7257    
7258                            query.append(_FINDER_COLUMN_R_F_FOLDERID_2);
7259    
7260                            String sql = query.toString();
7261    
7262                            Session session = null;
7263    
7264                            try {
7265                                    session = openSession();
7266    
7267                                    Query q = session.createQuery(sql);
7268    
7269                                    QueryPos qPos = QueryPos.getInstance(q);
7270    
7271                                    qPos.add(repositoryId);
7272    
7273                                    qPos.add(folderId);
7274    
7275                                    count = (Long)q.uniqueResult();
7276    
7277                                    finderCache.putResult(finderPath, finderArgs, count);
7278                            }
7279                            catch (Exception e) {
7280                                    finderCache.removeResult(finderPath, finderArgs);
7281    
7282                                    throw processException(e);
7283                            }
7284                            finally {
7285                                    closeSession(session);
7286                            }
7287                    }
7288    
7289                    return count.intValue();
7290            }
7291    
7292            private static final String _FINDER_COLUMN_R_F_REPOSITORYID_2 = "dlFileEntry.repositoryId = ? AND ";
7293            private static final String _FINDER_COLUMN_R_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
7294            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7295                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
7296                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByF_N",
7297                            new String[] {
7298                                    Long.class.getName(), String.class.getName(),
7299                                    
7300                            Integer.class.getName(), Integer.class.getName(),
7301                                    OrderByComparator.class.getName()
7302                            });
7303            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7304                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
7305                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByF_N",
7306                            new String[] { Long.class.getName(), String.class.getName() },
7307                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
7308                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
7309            public static final FinderPath FINDER_PATH_COUNT_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7310                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7311                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByF_N",
7312                            new String[] { Long.class.getName(), String.class.getName() });
7313    
7314            /**
7315             * Returns all the document library file entries where folderId = &#63; and name = &#63;.
7316             *
7317             * @param folderId the folder ID
7318             * @param name the name
7319             * @return the matching document library file entries
7320             */
7321            @Override
7322            public List<DLFileEntry> findByF_N(long folderId, String name) {
7323                    return findByF_N(folderId, name, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
7324                            null);
7325            }
7326    
7327            /**
7328             * Returns a range of all the document library file entries where folderId = &#63; and name = &#63;.
7329             *
7330             * <p>
7331             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7332             * </p>
7333             *
7334             * @param folderId the folder ID
7335             * @param name the name
7336             * @param start the lower bound of the range of document library file entries
7337             * @param end the upper bound of the range of document library file entries (not inclusive)
7338             * @return the range of matching document library file entries
7339             */
7340            @Override
7341            public List<DLFileEntry> findByF_N(long folderId, String name, int start,
7342                    int end) {
7343                    return findByF_N(folderId, name, start, end, null);
7344            }
7345    
7346            /**
7347             * Returns an ordered range of all the document library file entries where folderId = &#63; and name = &#63;.
7348             *
7349             * <p>
7350             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7351             * </p>
7352             *
7353             * @param folderId the folder ID
7354             * @param name the name
7355             * @param start the lower bound of the range of document library file entries
7356             * @param end the upper bound of the range of document library file entries (not inclusive)
7357             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7358             * @return the ordered range of matching document library file entries
7359             */
7360            @Override
7361            public List<DLFileEntry> findByF_N(long folderId, String name, int start,
7362                    int end, OrderByComparator<DLFileEntry> orderByComparator) {
7363                    return findByF_N(folderId, name, start, end, orderByComparator, true);
7364            }
7365    
7366            /**
7367             * Returns an ordered range of all the document library file entries where folderId = &#63; and name = &#63;.
7368             *
7369             * <p>
7370             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7371             * </p>
7372             *
7373             * @param folderId the folder ID
7374             * @param name the name
7375             * @param start the lower bound of the range of document library file entries
7376             * @param end the upper bound of the range of document library file entries (not inclusive)
7377             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7378             * @param retrieveFromCache whether to retrieve from the finder cache
7379             * @return the ordered range of matching document library file entries
7380             */
7381            @Override
7382            public List<DLFileEntry> findByF_N(long folderId, String name, int start,
7383                    int end, OrderByComparator<DLFileEntry> orderByComparator,
7384                    boolean retrieveFromCache) {
7385                    boolean pagination = true;
7386                    FinderPath finderPath = null;
7387                    Object[] finderArgs = null;
7388    
7389                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7390                                    (orderByComparator == null)) {
7391                            pagination = false;
7392                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N;
7393                            finderArgs = new Object[] { folderId, name };
7394                    }
7395                    else {
7396                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_F_N;
7397                            finderArgs = new Object[] {
7398                                            folderId, name,
7399                                            
7400                                            start, end, orderByComparator
7401                                    };
7402                    }
7403    
7404                    List<DLFileEntry> list = null;
7405    
7406                    if (retrieveFromCache) {
7407                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
7408                                            finderArgs, this);
7409    
7410                            if ((list != null) && !list.isEmpty()) {
7411                                    for (DLFileEntry dlFileEntry : list) {
7412                                            if ((folderId != dlFileEntry.getFolderId()) ||
7413                                                            !Validator.equals(name, dlFileEntry.getName())) {
7414                                                    list = null;
7415    
7416                                                    break;
7417                                            }
7418                                    }
7419                            }
7420                    }
7421    
7422                    if (list == null) {
7423                            StringBundler query = null;
7424    
7425                            if (orderByComparator != null) {
7426                                    query = new StringBundler(4 +
7427                                                    (orderByComparator.getOrderByFields().length * 3));
7428                            }
7429                            else {
7430                                    query = new StringBundler(4);
7431                            }
7432    
7433                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7434    
7435                            query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
7436    
7437                            boolean bindName = false;
7438    
7439                            if (name == null) {
7440                                    query.append(_FINDER_COLUMN_F_N_NAME_1);
7441                            }
7442                            else if (name.equals(StringPool.BLANK)) {
7443                                    query.append(_FINDER_COLUMN_F_N_NAME_3);
7444                            }
7445                            else {
7446                                    bindName = true;
7447    
7448                                    query.append(_FINDER_COLUMN_F_N_NAME_2);
7449                            }
7450    
7451                            if (orderByComparator != null) {
7452                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7453                                            orderByComparator);
7454                            }
7455                            else
7456                             if (pagination) {
7457                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7458                            }
7459    
7460                            String sql = query.toString();
7461    
7462                            Session session = null;
7463    
7464                            try {
7465                                    session = openSession();
7466    
7467                                    Query q = session.createQuery(sql);
7468    
7469                                    QueryPos qPos = QueryPos.getInstance(q);
7470    
7471                                    qPos.add(folderId);
7472    
7473                                    if (bindName) {
7474                                            qPos.add(name);
7475                                    }
7476    
7477                                    if (!pagination) {
7478                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
7479                                                            start, end, false);
7480    
7481                                            Collections.sort(list);
7482    
7483                                            list = Collections.unmodifiableList(list);
7484                                    }
7485                                    else {
7486                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
7487                                                            start, end);
7488                                    }
7489    
7490                                    cacheResult(list);
7491    
7492                                    finderCache.putResult(finderPath, finderArgs, list);
7493                            }
7494                            catch (Exception e) {
7495                                    finderCache.removeResult(finderPath, finderArgs);
7496    
7497                                    throw processException(e);
7498                            }
7499                            finally {
7500                                    closeSession(session);
7501                            }
7502                    }
7503    
7504                    return list;
7505            }
7506    
7507            /**
7508             * Returns the first document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7509             *
7510             * @param folderId the folder ID
7511             * @param name the name
7512             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7513             * @return the first matching document library file entry
7514             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
7515             */
7516            @Override
7517            public DLFileEntry findByF_N_First(long folderId, String name,
7518                    OrderByComparator<DLFileEntry> orderByComparator)
7519                    throws NoSuchFileEntryException {
7520                    DLFileEntry dlFileEntry = fetchByF_N_First(folderId, name,
7521                                    orderByComparator);
7522    
7523                    if (dlFileEntry != null) {
7524                            return dlFileEntry;
7525                    }
7526    
7527                    StringBundler msg = new StringBundler(6);
7528    
7529                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7530    
7531                    msg.append("folderId=");
7532                    msg.append(folderId);
7533    
7534                    msg.append(", name=");
7535                    msg.append(name);
7536    
7537                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7538    
7539                    throw new NoSuchFileEntryException(msg.toString());
7540            }
7541    
7542            /**
7543             * Returns the first document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7544             *
7545             * @param folderId the folder ID
7546             * @param name the name
7547             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7548             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7549             */
7550            @Override
7551            public DLFileEntry fetchByF_N_First(long folderId, String name,
7552                    OrderByComparator<DLFileEntry> orderByComparator) {
7553                    List<DLFileEntry> list = findByF_N(folderId, name, 0, 1,
7554                                    orderByComparator);
7555    
7556                    if (!list.isEmpty()) {
7557                            return list.get(0);
7558                    }
7559    
7560                    return null;
7561            }
7562    
7563            /**
7564             * Returns the last document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7565             *
7566             * @param folderId the folder ID
7567             * @param name the name
7568             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7569             * @return the last matching document library file entry
7570             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
7571             */
7572            @Override
7573            public DLFileEntry findByF_N_Last(long folderId, String name,
7574                    OrderByComparator<DLFileEntry> orderByComparator)
7575                    throws NoSuchFileEntryException {
7576                    DLFileEntry dlFileEntry = fetchByF_N_Last(folderId, name,
7577                                    orderByComparator);
7578    
7579                    if (dlFileEntry != null) {
7580                            return dlFileEntry;
7581                    }
7582    
7583                    StringBundler msg = new StringBundler(6);
7584    
7585                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7586    
7587                    msg.append("folderId=");
7588                    msg.append(folderId);
7589    
7590                    msg.append(", name=");
7591                    msg.append(name);
7592    
7593                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7594    
7595                    throw new NoSuchFileEntryException(msg.toString());
7596            }
7597    
7598            /**
7599             * Returns the last document library file entry in the ordered set where folderId = &#63; and name = &#63;.
7600             *
7601             * @param folderId the folder ID
7602             * @param name the name
7603             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7604             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
7605             */
7606            @Override
7607            public DLFileEntry fetchByF_N_Last(long folderId, String name,
7608                    OrderByComparator<DLFileEntry> orderByComparator) {
7609                    int count = countByF_N(folderId, name);
7610    
7611                    if (count == 0) {
7612                            return null;
7613                    }
7614    
7615                    List<DLFileEntry> list = findByF_N(folderId, name, count - 1, count,
7616                                    orderByComparator);
7617    
7618                    if (!list.isEmpty()) {
7619                            return list.get(0);
7620                    }
7621    
7622                    return null;
7623            }
7624    
7625            /**
7626             * 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;.
7627             *
7628             * @param fileEntryId the primary key of the current document library file entry
7629             * @param folderId the folder ID
7630             * @param name the name
7631             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7632             * @return the previous, current, and next document library file entry
7633             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
7634             */
7635            @Override
7636            public DLFileEntry[] findByF_N_PrevAndNext(long fileEntryId, long folderId,
7637                    String name, OrderByComparator<DLFileEntry> orderByComparator)
7638                    throws NoSuchFileEntryException {
7639                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
7640    
7641                    Session session = null;
7642    
7643                    try {
7644                            session = openSession();
7645    
7646                            DLFileEntry[] array = new DLFileEntryImpl[3];
7647    
7648                            array[0] = getByF_N_PrevAndNext(session, dlFileEntry, folderId,
7649                                            name, orderByComparator, true);
7650    
7651                            array[1] = dlFileEntry;
7652    
7653                            array[2] = getByF_N_PrevAndNext(session, dlFileEntry, folderId,
7654                                            name, orderByComparator, false);
7655    
7656                            return array;
7657                    }
7658                    catch (Exception e) {
7659                            throw processException(e);
7660                    }
7661                    finally {
7662                            closeSession(session);
7663                    }
7664            }
7665    
7666            protected DLFileEntry getByF_N_PrevAndNext(Session session,
7667                    DLFileEntry dlFileEntry, long folderId, String name,
7668                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
7669                    StringBundler query = null;
7670    
7671                    if (orderByComparator != null) {
7672                            query = new StringBundler(6 +
7673                                            (orderByComparator.getOrderByFields().length * 6));
7674                    }
7675                    else {
7676                            query = new StringBundler(3);
7677                    }
7678    
7679                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
7680    
7681                    query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
7682    
7683                    boolean bindName = false;
7684    
7685                    if (name == null) {
7686                            query.append(_FINDER_COLUMN_F_N_NAME_1);
7687                    }
7688                    else if (name.equals(StringPool.BLANK)) {
7689                            query.append(_FINDER_COLUMN_F_N_NAME_3);
7690                    }
7691                    else {
7692                            bindName = true;
7693    
7694                            query.append(_FINDER_COLUMN_F_N_NAME_2);
7695                    }
7696    
7697                    if (orderByComparator != null) {
7698                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7699    
7700                            if (orderByConditionFields.length > 0) {
7701                                    query.append(WHERE_AND);
7702                            }
7703    
7704                            for (int i = 0; i < orderByConditionFields.length; i++) {
7705                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7706                                    query.append(orderByConditionFields[i]);
7707    
7708                                    if ((i + 1) < orderByConditionFields.length) {
7709                                            if (orderByComparator.isAscending() ^ previous) {
7710                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7711                                            }
7712                                            else {
7713                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7714                                            }
7715                                    }
7716                                    else {
7717                                            if (orderByComparator.isAscending() ^ previous) {
7718                                                    query.append(WHERE_GREATER_THAN);
7719                                            }
7720                                            else {
7721                                                    query.append(WHERE_LESSER_THAN);
7722                                            }
7723                                    }
7724                            }
7725    
7726                            query.append(ORDER_BY_CLAUSE);
7727    
7728                            String[] orderByFields = orderByComparator.getOrderByFields();
7729    
7730                            for (int i = 0; i < orderByFields.length; i++) {
7731                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7732                                    query.append(orderByFields[i]);
7733    
7734                                    if ((i + 1) < orderByFields.length) {
7735                                            if (orderByComparator.isAscending() ^ previous) {
7736                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7737                                            }
7738                                            else {
7739                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7740                                            }
7741                                    }
7742                                    else {
7743                                            if (orderByComparator.isAscending() ^ previous) {
7744                                                    query.append(ORDER_BY_ASC);
7745                                            }
7746                                            else {
7747                                                    query.append(ORDER_BY_DESC);
7748                                            }
7749                                    }
7750                            }
7751                    }
7752                    else {
7753                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
7754                    }
7755    
7756                    String sql = query.toString();
7757    
7758                    Query q = session.createQuery(sql);
7759    
7760                    q.setFirstResult(0);
7761                    q.setMaxResults(2);
7762    
7763                    QueryPos qPos = QueryPos.getInstance(q);
7764    
7765                    qPos.add(folderId);
7766    
7767                    if (bindName) {
7768                            qPos.add(name);
7769                    }
7770    
7771                    if (orderByComparator != null) {
7772                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
7773    
7774                            for (Object value : values) {
7775                                    qPos.add(value);
7776                            }
7777                    }
7778    
7779                    List<DLFileEntry> list = q.list();
7780    
7781                    if (list.size() == 2) {
7782                            return list.get(1);
7783                    }
7784                    else {
7785                            return null;
7786                    }
7787            }
7788    
7789            /**
7790             * Removes all the document library file entries where folderId = &#63; and name = &#63; from the database.
7791             *
7792             * @param folderId the folder ID
7793             * @param name the name
7794             */
7795            @Override
7796            public void removeByF_N(long folderId, String name) {
7797                    for (DLFileEntry dlFileEntry : findByF_N(folderId, name,
7798                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7799                            remove(dlFileEntry);
7800                    }
7801            }
7802    
7803            /**
7804             * Returns the number of document library file entries where folderId = &#63; and name = &#63;.
7805             *
7806             * @param folderId the folder ID
7807             * @param name the name
7808             * @return the number of matching document library file entries
7809             */
7810            @Override
7811            public int countByF_N(long folderId, String name) {
7812                    FinderPath finderPath = FINDER_PATH_COUNT_BY_F_N;
7813    
7814                    Object[] finderArgs = new Object[] { folderId, name };
7815    
7816                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7817    
7818                    if (count == null) {
7819                            StringBundler query = new StringBundler(3);
7820    
7821                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7822    
7823                            query.append(_FINDER_COLUMN_F_N_FOLDERID_2);
7824    
7825                            boolean bindName = false;
7826    
7827                            if (name == null) {
7828                                    query.append(_FINDER_COLUMN_F_N_NAME_1);
7829                            }
7830                            else if (name.equals(StringPool.BLANK)) {
7831                                    query.append(_FINDER_COLUMN_F_N_NAME_3);
7832                            }
7833                            else {
7834                                    bindName = true;
7835    
7836                                    query.append(_FINDER_COLUMN_F_N_NAME_2);
7837                            }
7838    
7839                            String sql = query.toString();
7840    
7841                            Session session = null;
7842    
7843                            try {
7844                                    session = openSession();
7845    
7846                                    Query q = session.createQuery(sql);
7847    
7848                                    QueryPos qPos = QueryPos.getInstance(q);
7849    
7850                                    qPos.add(folderId);
7851    
7852                                    if (bindName) {
7853                                            qPos.add(name);
7854                                    }
7855    
7856                                    count = (Long)q.uniqueResult();
7857    
7858                                    finderCache.putResult(finderPath, finderArgs, count);
7859                            }
7860                            catch (Exception e) {
7861                                    finderCache.removeResult(finderPath, finderArgs);
7862    
7863                                    throw processException(e);
7864                            }
7865                            finally {
7866                                    closeSession(session);
7867                            }
7868                    }
7869    
7870                    return count.intValue();
7871            }
7872    
7873            private static final String _FINDER_COLUMN_F_N_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
7874            private static final String _FINDER_COLUMN_F_N_NAME_1 = "dlFileEntry.name IS NULL";
7875            private static final String _FINDER_COLUMN_F_N_NAME_2 = "dlFileEntry.name = ?";
7876            private static final String _FINDER_COLUMN_F_N_NAME_3 = "(dlFileEntry.name IS NULL OR dlFileEntry.name = '')";
7877            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7878                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
7879                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_F",
7880                            new String[] {
7881                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
7882                                    
7883                            Integer.class.getName(), Integer.class.getName(),
7884                                    OrderByComparator.class.getName()
7885                            });
7886            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7887                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
7888                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F",
7889                            new String[] {
7890                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
7891                            },
7892                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
7893                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK |
7894                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
7895                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
7896            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7897                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7898                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F",
7899                            new String[] {
7900                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
7901                            });
7902            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
7903                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7904                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_F",
7905                            new String[] {
7906                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
7907                            });
7908    
7909            /**
7910             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7911             *
7912             * @param groupId the group ID
7913             * @param userId the user ID
7914             * @param folderId the folder ID
7915             * @return the matching document library file entries
7916             */
7917            @Override
7918            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7919                    long folderId) {
7920                    return findByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
7921                            QueryUtil.ALL_POS, null);
7922            }
7923    
7924            /**
7925             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7926             *
7927             * <p>
7928             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7929             * </p>
7930             *
7931             * @param groupId the group ID
7932             * @param userId the user ID
7933             * @param folderId the folder ID
7934             * @param start the lower bound of the range of document library file entries
7935             * @param end the upper bound of the range of document library file entries (not inclusive)
7936             * @return the range of matching document library file entries
7937             */
7938            @Override
7939            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7940                    long folderId, int start, int end) {
7941                    return findByG_U_F(groupId, userId, folderId, start, end, null);
7942            }
7943    
7944            /**
7945             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7946             *
7947             * <p>
7948             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7949             * </p>
7950             *
7951             * @param groupId the group ID
7952             * @param userId the user ID
7953             * @param folderId the folder ID
7954             * @param start the lower bound of the range of document library file entries
7955             * @param end the upper bound of the range of document library file entries (not inclusive)
7956             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7957             * @return the ordered range of matching document library file entries
7958             */
7959            @Override
7960            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7961                    long folderId, int start, int end,
7962                    OrderByComparator<DLFileEntry> orderByComparator) {
7963                    return findByG_U_F(groupId, userId, folderId, start, end,
7964                            orderByComparator, true);
7965            }
7966    
7967            /**
7968             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7969             *
7970             * <p>
7971             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7972             * </p>
7973             *
7974             * @param groupId the group ID
7975             * @param userId the user ID
7976             * @param folderId the folder ID
7977             * @param start the lower bound of the range of document library file entries
7978             * @param end the upper bound of the range of document library file entries (not inclusive)
7979             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7980             * @param retrieveFromCache whether to retrieve from the finder cache
7981             * @return the ordered range of matching document library file entries
7982             */
7983            @Override
7984            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
7985                    long folderId, int start, int end,
7986                    OrderByComparator<DLFileEntry> orderByComparator,
7987                    boolean retrieveFromCache) {
7988                    boolean pagination = true;
7989                    FinderPath finderPath = null;
7990                    Object[] finderArgs = null;
7991    
7992                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7993                                    (orderByComparator == null)) {
7994                            pagination = false;
7995                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F;
7996                            finderArgs = new Object[] { groupId, userId, folderId };
7997                    }
7998                    else {
7999                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
8000                            finderArgs = new Object[] {
8001                                            groupId, userId, folderId,
8002                                            
8003                                            start, end, orderByComparator
8004                                    };
8005                    }
8006    
8007                    List<DLFileEntry> list = null;
8008    
8009                    if (retrieveFromCache) {
8010                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
8011                                            finderArgs, this);
8012    
8013                            if ((list != null) && !list.isEmpty()) {
8014                                    for (DLFileEntry dlFileEntry : list) {
8015                                            if ((groupId != dlFileEntry.getGroupId()) ||
8016                                                            (userId != dlFileEntry.getUserId()) ||
8017                                                            (folderId != dlFileEntry.getFolderId())) {
8018                                                    list = null;
8019    
8020                                                    break;
8021                                            }
8022                                    }
8023                            }
8024                    }
8025    
8026                    if (list == null) {
8027                            StringBundler query = null;
8028    
8029                            if (orderByComparator != null) {
8030                                    query = new StringBundler(5 +
8031                                                    (orderByComparator.getOrderByFields().length * 3));
8032                            }
8033                            else {
8034                                    query = new StringBundler(5);
8035                            }
8036    
8037                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
8038    
8039                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8040    
8041                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8042    
8043                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8044    
8045                            if (orderByComparator != null) {
8046                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8047                                            orderByComparator);
8048                            }
8049                            else
8050                             if (pagination) {
8051                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8052                            }
8053    
8054                            String sql = query.toString();
8055    
8056                            Session session = null;
8057    
8058                            try {
8059                                    session = openSession();
8060    
8061                                    Query q = session.createQuery(sql);
8062    
8063                                    QueryPos qPos = QueryPos.getInstance(q);
8064    
8065                                    qPos.add(groupId);
8066    
8067                                    qPos.add(userId);
8068    
8069                                    qPos.add(folderId);
8070    
8071                                    if (!pagination) {
8072                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
8073                                                            start, end, false);
8074    
8075                                            Collections.sort(list);
8076    
8077                                            list = Collections.unmodifiableList(list);
8078                                    }
8079                                    else {
8080                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
8081                                                            start, end);
8082                                    }
8083    
8084                                    cacheResult(list);
8085    
8086                                    finderCache.putResult(finderPath, finderArgs, list);
8087                            }
8088                            catch (Exception e) {
8089                                    finderCache.removeResult(finderPath, finderArgs);
8090    
8091                                    throw processException(e);
8092                            }
8093                            finally {
8094                                    closeSession(session);
8095                            }
8096                    }
8097    
8098                    return list;
8099            }
8100    
8101            /**
8102             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
8103             *
8104             * @param groupId the group ID
8105             * @param userId the user ID
8106             * @param folderId the folder ID
8107             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8108             * @return the first matching document library file entry
8109             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
8110             */
8111            @Override
8112            public DLFileEntry findByG_U_F_First(long groupId, long userId,
8113                    long folderId, OrderByComparator<DLFileEntry> orderByComparator)
8114                    throws NoSuchFileEntryException {
8115                    DLFileEntry dlFileEntry = fetchByG_U_F_First(groupId, userId, folderId,
8116                                    orderByComparator);
8117    
8118                    if (dlFileEntry != null) {
8119                            return dlFileEntry;
8120                    }
8121    
8122                    StringBundler msg = new StringBundler(8);
8123    
8124                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8125    
8126                    msg.append("groupId=");
8127                    msg.append(groupId);
8128    
8129                    msg.append(", userId=");
8130                    msg.append(userId);
8131    
8132                    msg.append(", folderId=");
8133                    msg.append(folderId);
8134    
8135                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8136    
8137                    throw new NoSuchFileEntryException(msg.toString());
8138            }
8139    
8140            /**
8141             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
8142             *
8143             * @param groupId the group ID
8144             * @param userId the user ID
8145             * @param folderId the folder ID
8146             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8147             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
8148             */
8149            @Override
8150            public DLFileEntry fetchByG_U_F_First(long groupId, long userId,
8151                    long folderId, OrderByComparator<DLFileEntry> orderByComparator) {
8152                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId, 0, 1,
8153                                    orderByComparator);
8154    
8155                    if (!list.isEmpty()) {
8156                            return list.get(0);
8157                    }
8158    
8159                    return null;
8160            }
8161    
8162            /**
8163             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
8164             *
8165             * @param groupId the group ID
8166             * @param userId the user ID
8167             * @param folderId the folder ID
8168             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8169             * @return the last matching document library file entry
8170             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
8171             */
8172            @Override
8173            public DLFileEntry findByG_U_F_Last(long groupId, long userId,
8174                    long folderId, OrderByComparator<DLFileEntry> orderByComparator)
8175                    throws NoSuchFileEntryException {
8176                    DLFileEntry dlFileEntry = fetchByG_U_F_Last(groupId, userId, folderId,
8177                                    orderByComparator);
8178    
8179                    if (dlFileEntry != null) {
8180                            return dlFileEntry;
8181                    }
8182    
8183                    StringBundler msg = new StringBundler(8);
8184    
8185                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8186    
8187                    msg.append("groupId=");
8188                    msg.append(groupId);
8189    
8190                    msg.append(", userId=");
8191                    msg.append(userId);
8192    
8193                    msg.append(", folderId=");
8194                    msg.append(folderId);
8195    
8196                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8197    
8198                    throw new NoSuchFileEntryException(msg.toString());
8199            }
8200    
8201            /**
8202             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
8203             *
8204             * @param groupId the group ID
8205             * @param userId the user ID
8206             * @param folderId the folder ID
8207             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8208             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
8209             */
8210            @Override
8211            public DLFileEntry fetchByG_U_F_Last(long groupId, long userId,
8212                    long folderId, OrderByComparator<DLFileEntry> orderByComparator) {
8213                    int count = countByG_U_F(groupId, userId, folderId);
8214    
8215                    if (count == 0) {
8216                            return null;
8217                    }
8218    
8219                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId,
8220                                    count - 1, count, orderByComparator);
8221    
8222                    if (!list.isEmpty()) {
8223                            return list.get(0);
8224                    }
8225    
8226                    return null;
8227            }
8228    
8229            /**
8230             * 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;.
8231             *
8232             * @param fileEntryId the primary key of the current document library file entry
8233             * @param groupId the group ID
8234             * @param userId the user ID
8235             * @param folderId the folder ID
8236             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8237             * @return the previous, current, and next document library file entry
8238             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
8239             */
8240            @Override
8241            public DLFileEntry[] findByG_U_F_PrevAndNext(long fileEntryId,
8242                    long groupId, long userId, long folderId,
8243                    OrderByComparator<DLFileEntry> orderByComparator)
8244                    throws NoSuchFileEntryException {
8245                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
8246    
8247                    Session session = null;
8248    
8249                    try {
8250                            session = openSession();
8251    
8252                            DLFileEntry[] array = new DLFileEntryImpl[3];
8253    
8254                            array[0] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
8255                                            userId, folderId, orderByComparator, true);
8256    
8257                            array[1] = dlFileEntry;
8258    
8259                            array[2] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
8260                                            userId, folderId, orderByComparator, false);
8261    
8262                            return array;
8263                    }
8264                    catch (Exception e) {
8265                            throw processException(e);
8266                    }
8267                    finally {
8268                            closeSession(session);
8269                    }
8270            }
8271    
8272            protected DLFileEntry getByG_U_F_PrevAndNext(Session session,
8273                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
8274                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
8275                    StringBundler query = null;
8276    
8277                    if (orderByComparator != null) {
8278                            query = new StringBundler(6 +
8279                                            (orderByComparator.getOrderByFields().length * 6));
8280                    }
8281                    else {
8282                            query = new StringBundler(3);
8283                    }
8284    
8285                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
8286    
8287                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8288    
8289                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8290    
8291                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8292    
8293                    if (orderByComparator != null) {
8294                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8295    
8296                            if (orderByConditionFields.length > 0) {
8297                                    query.append(WHERE_AND);
8298                            }
8299    
8300                            for (int i = 0; i < orderByConditionFields.length; i++) {
8301                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8302                                    query.append(orderByConditionFields[i]);
8303    
8304                                    if ((i + 1) < orderByConditionFields.length) {
8305                                            if (orderByComparator.isAscending() ^ previous) {
8306                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8307                                            }
8308                                            else {
8309                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8310                                            }
8311                                    }
8312                                    else {
8313                                            if (orderByComparator.isAscending() ^ previous) {
8314                                                    query.append(WHERE_GREATER_THAN);
8315                                            }
8316                                            else {
8317                                                    query.append(WHERE_LESSER_THAN);
8318                                            }
8319                                    }
8320                            }
8321    
8322                            query.append(ORDER_BY_CLAUSE);
8323    
8324                            String[] orderByFields = orderByComparator.getOrderByFields();
8325    
8326                            for (int i = 0; i < orderByFields.length; i++) {
8327                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8328                                    query.append(orderByFields[i]);
8329    
8330                                    if ((i + 1) < orderByFields.length) {
8331                                            if (orderByComparator.isAscending() ^ previous) {
8332                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8333                                            }
8334                                            else {
8335                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8336                                            }
8337                                    }
8338                                    else {
8339                                            if (orderByComparator.isAscending() ^ previous) {
8340                                                    query.append(ORDER_BY_ASC);
8341                                            }
8342                                            else {
8343                                                    query.append(ORDER_BY_DESC);
8344                                            }
8345                                    }
8346                            }
8347                    }
8348                    else {
8349                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8350                    }
8351    
8352                    String sql = query.toString();
8353    
8354                    Query q = session.createQuery(sql);
8355    
8356                    q.setFirstResult(0);
8357                    q.setMaxResults(2);
8358    
8359                    QueryPos qPos = QueryPos.getInstance(q);
8360    
8361                    qPos.add(groupId);
8362    
8363                    qPos.add(userId);
8364    
8365                    qPos.add(folderId);
8366    
8367                    if (orderByComparator != null) {
8368                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
8369    
8370                            for (Object value : values) {
8371                                    qPos.add(value);
8372                            }
8373                    }
8374    
8375                    List<DLFileEntry> list = q.list();
8376    
8377                    if (list.size() == 2) {
8378                            return list.get(1);
8379                    }
8380                    else {
8381                            return null;
8382                    }
8383            }
8384    
8385            /**
8386             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
8387             *
8388             * @param groupId the group ID
8389             * @param userId the user ID
8390             * @param folderId the folder ID
8391             * @return the matching document library file entries that the user has permission to view
8392             */
8393            @Override
8394            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8395                    long folderId) {
8396                    return filterFindByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
8397                            QueryUtil.ALL_POS, null);
8398            }
8399    
8400            /**
8401             * 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;.
8402             *
8403             * <p>
8404             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8405             * </p>
8406             *
8407             * @param groupId the group ID
8408             * @param userId the user ID
8409             * @param folderId the folder ID
8410             * @param start the lower bound of the range of document library file entries
8411             * @param end the upper bound of the range of document library file entries (not inclusive)
8412             * @return the range of matching document library file entries that the user has permission to view
8413             */
8414            @Override
8415            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8416                    long folderId, int start, int end) {
8417                    return filterFindByG_U_F(groupId, userId, folderId, start, end, null);
8418            }
8419    
8420            /**
8421             * 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;.
8422             *
8423             * <p>
8424             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8425             * </p>
8426             *
8427             * @param groupId the group ID
8428             * @param userId the user ID
8429             * @param folderId the folder ID
8430             * @param start the lower bound of the range of document library file entries
8431             * @param end the upper bound of the range of document library file entries (not inclusive)
8432             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8433             * @return the ordered range of matching document library file entries that the user has permission to view
8434             */
8435            @Override
8436            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8437                    long folderId, int start, int end,
8438                    OrderByComparator<DLFileEntry> orderByComparator) {
8439                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8440                            return findByG_U_F(groupId, userId, folderId, start, end,
8441                                    orderByComparator);
8442                    }
8443    
8444                    StringBundler query = null;
8445    
8446                    if (orderByComparator != null) {
8447                            query = new StringBundler(5 +
8448                                            (orderByComparator.getOrderByFields().length * 3));
8449                    }
8450                    else {
8451                            query = new StringBundler(5);
8452                    }
8453    
8454                    if (getDB().isSupportsInlineDistinct()) {
8455                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
8456                    }
8457                    else {
8458                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
8459                    }
8460    
8461                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8462    
8463                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8464    
8465                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8466    
8467                    if (!getDB().isSupportsInlineDistinct()) {
8468                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
8469                    }
8470    
8471                    if (orderByComparator != null) {
8472                            if (getDB().isSupportsInlineDistinct()) {
8473                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8474                                            orderByComparator, true);
8475                            }
8476                            else {
8477                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8478                                            orderByComparator, true);
8479                            }
8480                    }
8481                    else {
8482                            if (getDB().isSupportsInlineDistinct()) {
8483                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8484                            }
8485                            else {
8486                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
8487                            }
8488                    }
8489    
8490                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8491                                    DLFileEntry.class.getName(),
8492                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8493    
8494                    Session session = null;
8495    
8496                    try {
8497                            session = openSession();
8498    
8499                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8500    
8501                            if (getDB().isSupportsInlineDistinct()) {
8502                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
8503                            }
8504                            else {
8505                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
8506                            }
8507    
8508                            QueryPos qPos = QueryPos.getInstance(q);
8509    
8510                            qPos.add(groupId);
8511    
8512                            qPos.add(userId);
8513    
8514                            qPos.add(folderId);
8515    
8516                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
8517                    }
8518                    catch (Exception e) {
8519                            throw processException(e);
8520                    }
8521                    finally {
8522                            closeSession(session);
8523                    }
8524            }
8525    
8526            /**
8527             * 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;.
8528             *
8529             * @param fileEntryId the primary key of the current document library file entry
8530             * @param groupId the group ID
8531             * @param userId the user ID
8532             * @param folderId the folder ID
8533             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8534             * @return the previous, current, and next document library file entry
8535             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
8536             */
8537            @Override
8538            public DLFileEntry[] filterFindByG_U_F_PrevAndNext(long fileEntryId,
8539                    long groupId, long userId, long folderId,
8540                    OrderByComparator<DLFileEntry> orderByComparator)
8541                    throws NoSuchFileEntryException {
8542                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8543                            return findByG_U_F_PrevAndNext(fileEntryId, groupId, userId,
8544                                    folderId, orderByComparator);
8545                    }
8546    
8547                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
8548    
8549                    Session session = null;
8550    
8551                    try {
8552                            session = openSession();
8553    
8554                            DLFileEntry[] array = new DLFileEntryImpl[3];
8555    
8556                            array[0] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
8557                                            groupId, userId, folderId, orderByComparator, true);
8558    
8559                            array[1] = dlFileEntry;
8560    
8561                            array[2] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
8562                                            groupId, userId, folderId, orderByComparator, false);
8563    
8564                            return array;
8565                    }
8566                    catch (Exception e) {
8567                            throw processException(e);
8568                    }
8569                    finally {
8570                            closeSession(session);
8571                    }
8572            }
8573    
8574            protected DLFileEntry filterGetByG_U_F_PrevAndNext(Session session,
8575                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
8576                    OrderByComparator<DLFileEntry> orderByComparator, boolean previous) {
8577                    StringBundler query = null;
8578    
8579                    if (orderByComparator != null) {
8580                            query = new StringBundler(6 +
8581                                            (orderByComparator.getOrderByFields().length * 6));
8582                    }
8583                    else {
8584                            query = new StringBundler(3);
8585                    }
8586    
8587                    if (getDB().isSupportsInlineDistinct()) {
8588                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
8589                    }
8590                    else {
8591                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
8592                    }
8593    
8594                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8595    
8596                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8597    
8598                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
8599    
8600                    if (!getDB().isSupportsInlineDistinct()) {
8601                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
8602                    }
8603    
8604                    if (orderByComparator != null) {
8605                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8606    
8607                            if (orderByConditionFields.length > 0) {
8608                                    query.append(WHERE_AND);
8609                            }
8610    
8611                            for (int i = 0; i < orderByConditionFields.length; i++) {
8612                                    if (getDB().isSupportsInlineDistinct()) {
8613                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8614                                    }
8615                                    else {
8616                                            query.append(_ORDER_BY_ENTITY_TABLE);
8617                                    }
8618    
8619                                    query.append(orderByConditionFields[i]);
8620    
8621                                    if ((i + 1) < orderByConditionFields.length) {
8622                                            if (orderByComparator.isAscending() ^ previous) {
8623                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8624                                            }
8625                                            else {
8626                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8627                                            }
8628                                    }
8629                                    else {
8630                                            if (orderByComparator.isAscending() ^ previous) {
8631                                                    query.append(WHERE_GREATER_THAN);
8632                                            }
8633                                            else {
8634                                                    query.append(WHERE_LESSER_THAN);
8635                                            }
8636                                    }
8637                            }
8638    
8639                            query.append(ORDER_BY_CLAUSE);
8640    
8641                            String[] orderByFields = orderByComparator.getOrderByFields();
8642    
8643                            for (int i = 0; i < orderByFields.length; i++) {
8644                                    if (getDB().isSupportsInlineDistinct()) {
8645                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8646                                    }
8647                                    else {
8648                                            query.append(_ORDER_BY_ENTITY_TABLE);
8649                                    }
8650    
8651                                    query.append(orderByFields[i]);
8652    
8653                                    if ((i + 1) < orderByFields.length) {
8654                                            if (orderByComparator.isAscending() ^ previous) {
8655                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8656                                            }
8657                                            else {
8658                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8659                                            }
8660                                    }
8661                                    else {
8662                                            if (orderByComparator.isAscending() ^ previous) {
8663                                                    query.append(ORDER_BY_ASC);
8664                                            }
8665                                            else {
8666                                                    query.append(ORDER_BY_DESC);
8667                                            }
8668                                    }
8669                            }
8670                    }
8671                    else {
8672                            if (getDB().isSupportsInlineDistinct()) {
8673                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8674                            }
8675                            else {
8676                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
8677                            }
8678                    }
8679    
8680                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8681                                    DLFileEntry.class.getName(),
8682                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8683    
8684                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
8685    
8686                    q.setFirstResult(0);
8687                    q.setMaxResults(2);
8688    
8689                    if (getDB().isSupportsInlineDistinct()) {
8690                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
8691                    }
8692                    else {
8693                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
8694                    }
8695    
8696                    QueryPos qPos = QueryPos.getInstance(q);
8697    
8698                    qPos.add(groupId);
8699    
8700                    qPos.add(userId);
8701    
8702                    qPos.add(folderId);
8703    
8704                    if (orderByComparator != null) {
8705                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
8706    
8707                            for (Object value : values) {
8708                                    qPos.add(value);
8709                            }
8710                    }
8711    
8712                    List<DLFileEntry> list = q.list();
8713    
8714                    if (list.size() == 2) {
8715                            return list.get(1);
8716                    }
8717                    else {
8718                            return null;
8719                    }
8720            }
8721    
8722            /**
8723             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8724             *
8725             * @param groupId the group ID
8726             * @param userId the user ID
8727             * @param folderIds the folder IDs
8728             * @return the matching document library file entries that the user has permission to view
8729             */
8730            @Override
8731            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8732                    long[] folderIds) {
8733                    return filterFindByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
8734                            QueryUtil.ALL_POS, null);
8735            }
8736    
8737            /**
8738             * 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;.
8739             *
8740             * <p>
8741             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8742             * </p>
8743             *
8744             * @param groupId the group ID
8745             * @param userId the user ID
8746             * @param folderIds the folder IDs
8747             * @param start the lower bound of the range of document library file entries
8748             * @param end the upper bound of the range of document library file entries (not inclusive)
8749             * @return the range of matching document library file entries that the user has permission to view
8750             */
8751            @Override
8752            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8753                    long[] folderIds, int start, int end) {
8754                    return filterFindByG_U_F(groupId, userId, folderIds, start, end, null);
8755            }
8756    
8757            /**
8758             * 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;.
8759             *
8760             * <p>
8761             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8762             * </p>
8763             *
8764             * @param groupId the group ID
8765             * @param userId the user ID
8766             * @param folderIds the folder IDs
8767             * @param start the lower bound of the range of document library file entries
8768             * @param end the upper bound of the range of document library file entries (not inclusive)
8769             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8770             * @return the ordered range of matching document library file entries that the user has permission to view
8771             */
8772            @Override
8773            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
8774                    long[] folderIds, int start, int end,
8775                    OrderByComparator<DLFileEntry> orderByComparator) {
8776                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8777                            return findByG_U_F(groupId, userId, folderIds, start, end,
8778                                    orderByComparator);
8779                    }
8780    
8781                    if (folderIds == null) {
8782                            folderIds = new long[0];
8783                    }
8784                    else if (folderIds.length > 1) {
8785                            folderIds = ArrayUtil.unique(folderIds);
8786    
8787                            Arrays.sort(folderIds);
8788                    }
8789    
8790                    StringBundler query = new StringBundler();
8791    
8792                    if (getDB().isSupportsInlineDistinct()) {
8793                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
8794                    }
8795                    else {
8796                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
8797                    }
8798    
8799                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
8800    
8801                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
8802    
8803                    if (folderIds.length > 0) {
8804                            query.append(StringPool.OPEN_PARENTHESIS);
8805    
8806                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_7);
8807    
8808                            query.append(StringUtil.merge(folderIds));
8809    
8810                            query.append(StringPool.CLOSE_PARENTHESIS);
8811    
8812                            query.append(StringPool.CLOSE_PARENTHESIS);
8813                    }
8814    
8815                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8816                            query.index() - 1);
8817    
8818                    if (!getDB().isSupportsInlineDistinct()) {
8819                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
8820                    }
8821    
8822                    if (orderByComparator != null) {
8823                            if (getDB().isSupportsInlineDistinct()) {
8824                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8825                                            orderByComparator, true);
8826                            }
8827                            else {
8828                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8829                                            orderByComparator, true);
8830                            }
8831                    }
8832                    else {
8833                            if (getDB().isSupportsInlineDistinct()) {
8834                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
8835                            }
8836                            else {
8837                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
8838                            }
8839                    }
8840    
8841                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8842                                    DLFileEntry.class.getName(),
8843                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8844    
8845                    Session session = null;
8846    
8847                    try {
8848                            session = openSession();
8849    
8850                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8851    
8852                            if (getDB().isSupportsInlineDistinct()) {
8853                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
8854                            }
8855                            else {
8856                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
8857                            }
8858    
8859                            QueryPos qPos = QueryPos.getInstance(q);
8860    
8861                            qPos.add(groupId);
8862    
8863                            qPos.add(userId);
8864    
8865                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
8866                    }
8867                    catch (Exception e) {
8868                            throw processException(e);
8869                    }
8870                    finally {
8871                            closeSession(session);
8872                    }
8873            }
8874    
8875            /**
8876             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8877             *
8878             * <p>
8879             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8880             * </p>
8881             *
8882             * @param groupId the group ID
8883             * @param userId the user ID
8884             * @param folderIds the folder IDs
8885             * @return the matching document library file entries
8886             */
8887            @Override
8888            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
8889                    long[] folderIds) {
8890                    return findByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
8891                            QueryUtil.ALL_POS, null);
8892            }
8893    
8894            /**
8895             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8896             *
8897             * <p>
8898             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8899             * </p>
8900             *
8901             * @param groupId the group ID
8902             * @param userId the user ID
8903             * @param folderIds the folder IDs
8904             * @param start the lower bound of the range of document library file entries
8905             * @param end the upper bound of the range of document library file entries (not inclusive)
8906             * @return the range of matching document library file entries
8907             */
8908            @Override
8909            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
8910                    long[] folderIds, int start, int end) {
8911                    return findByG_U_F(groupId, userId, folderIds, start, end, null);
8912            }
8913    
8914            /**
8915             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
8916             *
8917             * <p>
8918             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8919             * </p>
8920             *
8921             * @param groupId the group ID
8922             * @param userId the user ID
8923             * @param folderIds the folder IDs
8924             * @param start the lower bound of the range of document library file entries
8925             * @param end the upper bound of the range of document library file entries (not inclusive)
8926             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8927             * @return the ordered range of matching document library file entries
8928             */
8929            @Override
8930            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
8931                    long[] folderIds, int start, int end,
8932                    OrderByComparator<DLFileEntry> orderByComparator) {
8933                    return findByG_U_F(groupId, userId, folderIds, start, end,
8934                            orderByComparator, true);
8935            }
8936    
8937            /**
8938             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;, optionally using the finder cache.
8939             *
8940             * <p>
8941             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8942             * </p>
8943             *
8944             * @param groupId the group ID
8945             * @param userId the user ID
8946             * @param folderId the folder ID
8947             * @param start the lower bound of the range of document library file entries
8948             * @param end the upper bound of the range of document library file entries (not inclusive)
8949             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8950             * @param retrieveFromCache whether to retrieve from the finder cache
8951             * @return the ordered range of matching document library file entries
8952             */
8953            @Override
8954            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
8955                    long[] folderIds, int start, int end,
8956                    OrderByComparator<DLFileEntry> orderByComparator,
8957                    boolean retrieveFromCache) {
8958                    if (folderIds == null) {
8959                            folderIds = new long[0];
8960                    }
8961                    else if (folderIds.length > 1) {
8962                            folderIds = ArrayUtil.unique(folderIds);
8963    
8964                            Arrays.sort(folderIds);
8965                    }
8966    
8967                    if (folderIds.length == 1) {
8968                            return findByG_U_F(groupId, userId, folderIds[0], start, end,
8969                                    orderByComparator);
8970                    }
8971    
8972                    boolean pagination = true;
8973                    Object[] finderArgs = null;
8974    
8975                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8976                                    (orderByComparator == null)) {
8977                            pagination = false;
8978                            finderArgs = new Object[] {
8979                                            groupId, userId, StringUtil.merge(folderIds)
8980                                    };
8981                    }
8982                    else {
8983                            finderArgs = new Object[] {
8984                                            groupId, userId, StringUtil.merge(folderIds),
8985                                            
8986                                            start, end, orderByComparator
8987                                    };
8988                    }
8989    
8990                    List<DLFileEntry> list = null;
8991    
8992                    if (retrieveFromCache) {
8993                            list = (List<DLFileEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
8994                                            finderArgs, this);
8995    
8996                            if ((list != null) && !list.isEmpty()) {
8997                                    for (DLFileEntry dlFileEntry : list) {
8998                                            if ((groupId != dlFileEntry.getGroupId()) ||
8999                                                            (userId != dlFileEntry.getUserId()) ||
9000                                                            !ArrayUtil.contains(folderIds,
9001                                                                    dlFileEntry.getFolderId())) {
9002                                                    list = null;
9003    
9004                                                    break;
9005                                            }
9006                                    }
9007                            }
9008                    }
9009    
9010                    if (list == null) {
9011                            StringBundler query = new StringBundler();
9012    
9013                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9014    
9015                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
9016    
9017                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
9018    
9019                            if (folderIds.length > 0) {
9020                                    query.append(StringPool.OPEN_PARENTHESIS);
9021    
9022                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_7);
9023    
9024                                    query.append(StringUtil.merge(folderIds));
9025    
9026                                    query.append(StringPool.CLOSE_PARENTHESIS);
9027    
9028                                    query.append(StringPool.CLOSE_PARENTHESIS);
9029                            }
9030    
9031                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
9032                                                    1)), query.index() - 1);
9033    
9034                            if (orderByComparator != null) {
9035                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9036                                            orderByComparator);
9037                            }
9038                            else
9039                             if (pagination) {
9040                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
9041                            }
9042    
9043                            String sql = query.toString();
9044    
9045                            Session session = null;
9046    
9047                            try {
9048                                    session = openSession();
9049    
9050                                    Query q = session.createQuery(sql);
9051    
9052                                    QueryPos qPos = QueryPos.getInstance(q);
9053    
9054                                    qPos.add(groupId);
9055    
9056                                    qPos.add(userId);
9057    
9058                                    if (!pagination) {
9059                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
9060                                                            start, end, false);
9061    
9062                                            Collections.sort(list);
9063    
9064                                            list = Collections.unmodifiableList(list);
9065                                    }
9066                                    else {
9067                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
9068                                                            start, end);
9069                                    }
9070    
9071                                    cacheResult(list);
9072    
9073                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
9074                                            finderArgs, list);
9075                            }
9076                            catch (Exception e) {
9077                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F,
9078                                            finderArgs);
9079    
9080                                    throw processException(e);
9081                            }
9082                            finally {
9083                                    closeSession(session);
9084                            }
9085                    }
9086    
9087                    return list;
9088            }
9089    
9090            /**
9091             * Removes all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63; from the database.
9092             *
9093             * @param groupId the group ID
9094             * @param userId the user ID
9095             * @param folderId the folder ID
9096             */
9097            @Override
9098            public void removeByG_U_F(long groupId, long userId, long folderId) {
9099                    for (DLFileEntry dlFileEntry : findByG_U_F(groupId, userId, folderId,
9100                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9101                            remove(dlFileEntry);
9102                    }
9103            }
9104    
9105            /**
9106             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
9107             *
9108             * @param groupId the group ID
9109             * @param userId the user ID
9110             * @param folderId the folder ID
9111             * @return the number of matching document library file entries
9112             */
9113            @Override
9114            public int countByG_U_F(long groupId, long userId, long folderId) {
9115                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_F;
9116    
9117                    Object[] finderArgs = new Object[] { groupId, userId, folderId };
9118    
9119                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9120    
9121                    if (count == null) {
9122                            StringBundler query = new StringBundler(4);
9123    
9124                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
9125    
9126                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
9127    
9128                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
9129    
9130                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
9131    
9132                            String sql = query.toString();
9133    
9134                            Session session = null;
9135    
9136                            try {
9137                                    session = openSession();
9138    
9139                                    Query q = session.createQuery(sql);
9140    
9141                                    QueryPos qPos = QueryPos.getInstance(q);
9142    
9143                                    qPos.add(groupId);
9144    
9145                                    qPos.add(userId);
9146    
9147                                    qPos.add(folderId);
9148    
9149                                    count = (Long)q.uniqueResult();
9150    
9151                                    finderCache.putResult(finderPath, finderArgs, count);
9152                            }
9153                            catch (Exception e) {
9154                                    finderCache.removeResult(finderPath, finderArgs);
9155    
9156                                    throw processException(e);
9157                            }
9158                            finally {
9159                                    closeSession(session);
9160                            }
9161                    }
9162    
9163                    return count.intValue();
9164            }
9165    
9166            /**
9167             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
9168             *
9169             * @param groupId the group ID
9170             * @param userId the user ID
9171             * @param folderIds the folder IDs
9172             * @return the number of matching document library file entries
9173             */
9174            @Override
9175            public int countByG_U_F(long groupId, long userId, long[] folderIds) {
9176                    if (folderIds == null) {
9177                            folderIds = new long[0];
9178                    }
9179                    else if (folderIds.length > 1) {
9180                            folderIds = ArrayUtil.unique(folderIds);
9181    
9182                            Arrays.sort(folderIds);
9183                    }
9184    
9185                    Object[] finderArgs = new Object[] {
9186                                    groupId, userId, StringUtil.merge(folderIds)
9187                            };
9188    
9189                    Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
9190                                    finderArgs, this);
9191    
9192                    if (count == null) {
9193                            StringBundler query = new StringBundler();
9194    
9195                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
9196    
9197                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
9198    
9199                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
9200    
9201                            if (folderIds.length > 0) {
9202                                    query.append(StringPool.OPEN_PARENTHESIS);
9203    
9204                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_7);
9205    
9206                                    query.append(StringUtil.merge(folderIds));
9207    
9208                                    query.append(StringPool.CLOSE_PARENTHESIS);
9209    
9210                                    query.append(StringPool.CLOSE_PARENTHESIS);
9211                            }
9212    
9213                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
9214                                                    1)), query.index() - 1);
9215    
9216                            String sql = query.toString();
9217    
9218                            Session session = null;
9219    
9220                            try {
9221                                    session = openSession();
9222    
9223                                    Query q = session.createQuery(sql);
9224    
9225                                    QueryPos qPos = QueryPos.getInstance(q);
9226    
9227                                    qPos.add(groupId);
9228    
9229                                    qPos.add(userId);
9230    
9231                                    count = (Long)q.uniqueResult();
9232    
9233                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
9234                                            finderArgs, count);
9235                            }
9236                            catch (Exception e) {
9237                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F,
9238                                            finderArgs);
9239    
9240                                    throw processException(e);
9241                            }
9242                            finally {
9243                                    closeSession(session);
9244                            }
9245                    }
9246    
9247                    return count.intValue();
9248            }
9249    
9250            /**
9251             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
9252             *
9253             * @param groupId the group ID
9254             * @param userId the user ID
9255             * @param folderId the folder ID
9256             * @return the number of matching document library file entries that the user has permission to view
9257             */
9258            @Override
9259            public int filterCountByG_U_F(long groupId, long userId, long folderId) {
9260                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9261                            return countByG_U_F(groupId, userId, folderId);
9262                    }
9263    
9264                    StringBundler query = new StringBundler(4);
9265    
9266                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
9267    
9268                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
9269    
9270                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
9271    
9272                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
9273    
9274                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9275                                    DLFileEntry.class.getName(),
9276                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9277    
9278                    Session session = null;
9279    
9280                    try {
9281                            session = openSession();
9282    
9283                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9284    
9285                            q.addScalar(COUNT_COLUMN_NAME,
9286                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9287    
9288                            QueryPos qPos = QueryPos.getInstance(q);
9289    
9290                            qPos.add(groupId);
9291    
9292                            qPos.add(userId);
9293    
9294                            qPos.add(folderId);
9295    
9296                            Long count = (Long)q.uniqueResult();
9297    
9298                            return count.intValue();
9299                    }
9300                    catch (Exception e) {
9301                            throw processException(e);
9302                    }
9303                    finally {
9304                            closeSession(session);
9305                    }
9306            }
9307    
9308            /**
9309             * 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;.
9310             *
9311             * @param groupId the group ID
9312             * @param userId the user ID
9313             * @param folderIds the folder IDs
9314             * @return the number of matching document library file entries that the user has permission to view
9315             */
9316            @Override
9317            public int filterCountByG_U_F(long groupId, long userId, long[] folderIds) {
9318                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9319                            return countByG_U_F(groupId, userId, folderIds);
9320                    }
9321    
9322                    if (folderIds == null) {
9323                            folderIds = new long[0];
9324                    }
9325                    else if (folderIds.length > 1) {
9326                            folderIds = ArrayUtil.unique(folderIds);
9327    
9328                            Arrays.sort(folderIds);
9329                    }
9330    
9331                    StringBundler query = new StringBundler();
9332    
9333                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
9334    
9335                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
9336    
9337                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
9338    
9339                    if (folderIds.length > 0) {
9340                            query.append(StringPool.OPEN_PARENTHESIS);
9341    
9342                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_7);
9343    
9344                            query.append(StringUtil.merge(folderIds));
9345    
9346                            query.append(StringPool.CLOSE_PARENTHESIS);
9347    
9348                            query.append(StringPool.CLOSE_PARENTHESIS);
9349                    }
9350    
9351                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
9352                            query.index() - 1);
9353    
9354                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9355                                    DLFileEntry.class.getName(),
9356                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9357    
9358                    Session session = null;
9359    
9360                    try {
9361                            session = openSession();
9362    
9363                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9364    
9365                            q.addScalar(COUNT_COLUMN_NAME,
9366                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9367    
9368                            QueryPos qPos = QueryPos.getInstance(q);
9369    
9370                            qPos.add(groupId);
9371    
9372                            qPos.add(userId);
9373    
9374                            Long count = (Long)q.uniqueResult();
9375    
9376                            return count.intValue();
9377                    }
9378                    catch (Exception e) {
9379                            throw processException(e);
9380                    }
9381                    finally {
9382                            closeSession(session);
9383                    }
9384            }
9385    
9386            private static final String _FINDER_COLUMN_G_U_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
9387            private static final String _FINDER_COLUMN_G_U_F_USERID_2 = "dlFileEntry.userId = ? AND ";
9388            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
9389            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_7 = "dlFileEntry.folderId IN (";
9390            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9391                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
9392                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_N",
9393                            new String[] {
9394                                    Long.class.getName(), Long.class.getName(),
9395                                    String.class.getName()
9396                            },
9397                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
9398                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
9399                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
9400            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9401                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9402                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_N",
9403                            new String[] {
9404                                    Long.class.getName(), Long.class.getName(),
9405                                    String.class.getName()
9406                            });
9407    
9408            /**
9409             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; or throws a {@link NoSuchFileEntryException} if it could not be found.
9410             *
9411             * @param groupId the group ID
9412             * @param folderId the folder ID
9413             * @param name the name
9414             * @return the matching document library file entry
9415             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
9416             */
9417            @Override
9418            public DLFileEntry findByG_F_N(long groupId, long folderId, String name)
9419                    throws NoSuchFileEntryException {
9420                    DLFileEntry dlFileEntry = fetchByG_F_N(groupId, folderId, name);
9421    
9422                    if (dlFileEntry == null) {
9423                            StringBundler msg = new StringBundler(8);
9424    
9425                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9426    
9427                            msg.append("groupId=");
9428                            msg.append(groupId);
9429    
9430                            msg.append(", folderId=");
9431                            msg.append(folderId);
9432    
9433                            msg.append(", name=");
9434                            msg.append(name);
9435    
9436                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9437    
9438                            if (_log.isWarnEnabled()) {
9439                                    _log.warn(msg.toString());
9440                            }
9441    
9442                            throw new NoSuchFileEntryException(msg.toString());
9443                    }
9444    
9445                    return dlFileEntry;
9446            }
9447    
9448            /**
9449             * 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.
9450             *
9451             * @param groupId the group ID
9452             * @param folderId the folder ID
9453             * @param name the name
9454             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9455             */
9456            @Override
9457            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name) {
9458                    return fetchByG_F_N(groupId, folderId, name, true);
9459            }
9460    
9461            /**
9462             * 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.
9463             *
9464             * @param groupId the group ID
9465             * @param folderId the folder ID
9466             * @param name the name
9467             * @param retrieveFromCache whether to retrieve from the finder cache
9468             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9469             */
9470            @Override
9471            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name,
9472                    boolean retrieveFromCache) {
9473                    Object[] finderArgs = new Object[] { groupId, folderId, name };
9474    
9475                    Object result = null;
9476    
9477                    if (retrieveFromCache) {
9478                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_F_N,
9479                                            finderArgs, this);
9480                    }
9481    
9482                    if (result instanceof DLFileEntry) {
9483                            DLFileEntry dlFileEntry = (DLFileEntry)result;
9484    
9485                            if ((groupId != dlFileEntry.getGroupId()) ||
9486                                            (folderId != dlFileEntry.getFolderId()) ||
9487                                            !Validator.equals(name, dlFileEntry.getName())) {
9488                                    result = null;
9489                            }
9490                    }
9491    
9492                    if (result == null) {
9493                            StringBundler query = new StringBundler(5);
9494    
9495                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9496    
9497                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
9498    
9499                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
9500    
9501                            boolean bindName = false;
9502    
9503                            if (name == null) {
9504                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
9505                            }
9506                            else if (name.equals(StringPool.BLANK)) {
9507                                    query.append(_FINDER_COLUMN_G_F_N_NAME_3);
9508                            }
9509                            else {
9510                                    bindName = true;
9511    
9512                                    query.append(_FINDER_COLUMN_G_F_N_NAME_2);
9513                            }
9514    
9515                            String sql = query.toString();
9516    
9517                            Session session = null;
9518    
9519                            try {
9520                                    session = openSession();
9521    
9522                                    Query q = session.createQuery(sql);
9523    
9524                                    QueryPos qPos = QueryPos.getInstance(q);
9525    
9526                                    qPos.add(groupId);
9527    
9528                                    qPos.add(folderId);
9529    
9530                                    if (bindName) {
9531                                            qPos.add(name);
9532                                    }
9533    
9534                                    List<DLFileEntry> list = q.list();
9535    
9536                                    if (list.isEmpty()) {
9537                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_N,
9538                                                    finderArgs, list);
9539                                    }
9540                                    else {
9541                                            DLFileEntry dlFileEntry = list.get(0);
9542    
9543                                            result = dlFileEntry;
9544    
9545                                            cacheResult(dlFileEntry);
9546    
9547                                            if ((dlFileEntry.getGroupId() != groupId) ||
9548                                                            (dlFileEntry.getFolderId() != folderId) ||
9549                                                            (dlFileEntry.getName() == null) ||
9550                                                            !dlFileEntry.getName().equals(name)) {
9551                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_N,
9552                                                            finderArgs, dlFileEntry);
9553                                            }
9554                                    }
9555                            }
9556                            catch (Exception e) {
9557                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_N, finderArgs);
9558    
9559                                    throw processException(e);
9560                            }
9561                            finally {
9562                                    closeSession(session);
9563                            }
9564                    }
9565    
9566                    if (result instanceof List<?>) {
9567                            return null;
9568                    }
9569                    else {
9570                            return (DLFileEntry)result;
9571                    }
9572            }
9573    
9574            /**
9575             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; from the database.
9576             *
9577             * @param groupId the group ID
9578             * @param folderId the folder ID
9579             * @param name the name
9580             * @return the document library file entry that was removed
9581             */
9582            @Override
9583            public DLFileEntry removeByG_F_N(long groupId, long folderId, String name)
9584                    throws NoSuchFileEntryException {
9585                    DLFileEntry dlFileEntry = findByG_F_N(groupId, folderId, name);
9586    
9587                    return remove(dlFileEntry);
9588            }
9589    
9590            /**
9591             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and name = &#63;.
9592             *
9593             * @param groupId the group ID
9594             * @param folderId the folder ID
9595             * @param name the name
9596             * @return the number of matching document library file entries
9597             */
9598            @Override
9599            public int countByG_F_N(long groupId, long folderId, String name) {
9600                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_N;
9601    
9602                    Object[] finderArgs = new Object[] { groupId, folderId, name };
9603    
9604                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9605    
9606                    if (count == null) {
9607                            StringBundler query = new StringBundler(4);
9608    
9609                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
9610    
9611                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
9612    
9613                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
9614    
9615                            boolean bindName = false;
9616    
9617                            if (name == null) {
9618                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
9619                            }
9620                            else if (name.equals(StringPool.BLANK)) {
9621                                    query.append(_FINDER_COLUMN_G_F_N_NAME_3);
9622                            }
9623                            else {
9624                                    bindName = true;
9625    
9626                                    query.append(_FINDER_COLUMN_G_F_N_NAME_2);
9627                            }
9628    
9629                            String sql = query.toString();
9630    
9631                            Session session = null;
9632    
9633                            try {
9634                                    session = openSession();
9635    
9636                                    Query q = session.createQuery(sql);
9637    
9638                                    QueryPos qPos = QueryPos.getInstance(q);
9639    
9640                                    qPos.add(groupId);
9641    
9642                                    qPos.add(folderId);
9643    
9644                                    if (bindName) {
9645                                            qPos.add(name);
9646                                    }
9647    
9648                                    count = (Long)q.uniqueResult();
9649    
9650                                    finderCache.putResult(finderPath, finderArgs, count);
9651                            }
9652                            catch (Exception e) {
9653                                    finderCache.removeResult(finderPath, finderArgs);
9654    
9655                                    throw processException(e);
9656                            }
9657                            finally {
9658                                    closeSession(session);
9659                            }
9660                    }
9661    
9662                    return count.intValue();
9663            }
9664    
9665            private static final String _FINDER_COLUMN_G_F_N_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
9666            private static final String _FINDER_COLUMN_G_F_N_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
9667            private static final String _FINDER_COLUMN_G_F_N_NAME_1 = "dlFileEntry.name IS NULL";
9668            private static final String _FINDER_COLUMN_G_F_N_NAME_2 = "dlFileEntry.name = ?";
9669            private static final String _FINDER_COLUMN_G_F_N_NAME_3 = "(dlFileEntry.name IS NULL OR dlFileEntry.name = '')";
9670            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_FN = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9671                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
9672                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_FN",
9673                            new String[] {
9674                                    Long.class.getName(), Long.class.getName(),
9675                                    String.class.getName()
9676                            },
9677                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
9678                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
9679                            DLFileEntryModelImpl.FILENAME_COLUMN_BITMASK);
9680            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_FN = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9681                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9682                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_FN",
9683                            new String[] {
9684                                    Long.class.getName(), Long.class.getName(),
9685                                    String.class.getName()
9686                            });
9687    
9688            /**
9689             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and fileName = &#63; or throws a {@link NoSuchFileEntryException} if it could not be found.
9690             *
9691             * @param groupId the group ID
9692             * @param folderId the folder ID
9693             * @param fileName the file name
9694             * @return the matching document library file entry
9695             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
9696             */
9697            @Override
9698            public DLFileEntry findByG_F_FN(long groupId, long folderId, String fileName)
9699                    throws NoSuchFileEntryException {
9700                    DLFileEntry dlFileEntry = fetchByG_F_FN(groupId, folderId, fileName);
9701    
9702                    if (dlFileEntry == null) {
9703                            StringBundler msg = new StringBundler(8);
9704    
9705                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9706    
9707                            msg.append("groupId=");
9708                            msg.append(groupId);
9709    
9710                            msg.append(", folderId=");
9711                            msg.append(folderId);
9712    
9713                            msg.append(", fileName=");
9714                            msg.append(fileName);
9715    
9716                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9717    
9718                            if (_log.isWarnEnabled()) {
9719                                    _log.warn(msg.toString());
9720                            }
9721    
9722                            throw new NoSuchFileEntryException(msg.toString());
9723                    }
9724    
9725                    return dlFileEntry;
9726            }
9727    
9728            /**
9729             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and fileName = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
9730             *
9731             * @param groupId the group ID
9732             * @param folderId the folder ID
9733             * @param fileName the file name
9734             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9735             */
9736            @Override
9737            public DLFileEntry fetchByG_F_FN(long groupId, long folderId,
9738                    String fileName) {
9739                    return fetchByG_F_FN(groupId, folderId, fileName, true);
9740            }
9741    
9742            /**
9743             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and fileName = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
9744             *
9745             * @param groupId the group ID
9746             * @param folderId the folder ID
9747             * @param fileName the file name
9748             * @param retrieveFromCache whether to retrieve from the finder cache
9749             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
9750             */
9751            @Override
9752            public DLFileEntry fetchByG_F_FN(long groupId, long folderId,
9753                    String fileName, boolean retrieveFromCache) {
9754                    Object[] finderArgs = new Object[] { groupId, folderId, fileName };
9755    
9756                    Object result = null;
9757    
9758                    if (retrieveFromCache) {
9759                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_F_FN,
9760                                            finderArgs, this);
9761                    }
9762    
9763                    if (result instanceof DLFileEntry) {
9764                            DLFileEntry dlFileEntry = (DLFileEntry)result;
9765    
9766                            if ((groupId != dlFileEntry.getGroupId()) ||
9767                                            (folderId != dlFileEntry.getFolderId()) ||
9768                                            !Validator.equals(fileName, dlFileEntry.getFileName())) {
9769                                    result = null;
9770                            }
9771                    }
9772    
9773                    if (result == null) {
9774                            StringBundler query = new StringBundler(5);
9775    
9776                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
9777    
9778                            query.append(_FINDER_COLUMN_G_F_FN_GROUPID_2);
9779    
9780                            query.append(_FINDER_COLUMN_G_F_FN_FOLDERID_2);
9781    
9782                            boolean bindFileName = false;
9783    
9784                            if (fileName == null) {
9785                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_1);
9786                            }
9787                            else if (fileName.equals(StringPool.BLANK)) {
9788                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_3);
9789                            }
9790                            else {
9791                                    bindFileName = true;
9792    
9793                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_2);
9794                            }
9795    
9796                            String sql = query.toString();
9797    
9798                            Session session = null;
9799    
9800                            try {
9801                                    session = openSession();
9802    
9803                                    Query q = session.createQuery(sql);
9804    
9805                                    QueryPos qPos = QueryPos.getInstance(q);
9806    
9807                                    qPos.add(groupId);
9808    
9809                                    qPos.add(folderId);
9810    
9811                                    if (bindFileName) {
9812                                            qPos.add(fileName);
9813                                    }
9814    
9815                                    List<DLFileEntry> list = q.list();
9816    
9817                                    if (list.isEmpty()) {
9818                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_FN,
9819                                                    finderArgs, list);
9820                                    }
9821                                    else {
9822                                            DLFileEntry dlFileEntry = list.get(0);
9823    
9824                                            result = dlFileEntry;
9825    
9826                                            cacheResult(dlFileEntry);
9827    
9828                                            if ((dlFileEntry.getGroupId() != groupId) ||
9829                                                            (dlFileEntry.getFolderId() != folderId) ||
9830                                                            (dlFileEntry.getFileName() == null) ||
9831                                                            !dlFileEntry.getFileName().equals(fileName)) {
9832                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_FN,
9833                                                            finderArgs, dlFileEntry);
9834                                            }
9835                                    }
9836                            }
9837                            catch (Exception e) {
9838                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_FN, finderArgs);
9839    
9840                                    throw processException(e);
9841                            }
9842                            finally {
9843                                    closeSession(session);
9844                            }
9845                    }
9846    
9847                    if (result instanceof List<?>) {
9848                            return null;
9849                    }
9850                    else {
9851                            return (DLFileEntry)result;
9852                    }
9853            }
9854    
9855            /**
9856             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and fileName = &#63; from the database.
9857             *
9858             * @param groupId the group ID
9859             * @param folderId the folder ID
9860             * @param fileName the file name
9861             * @return the document library file entry that was removed
9862             */
9863            @Override
9864            public DLFileEntry removeByG_F_FN(long groupId, long folderId,
9865                    String fileName) throws NoSuchFileEntryException {
9866                    DLFileEntry dlFileEntry = findByG_F_FN(groupId, folderId, fileName);
9867    
9868                    return remove(dlFileEntry);
9869            }
9870    
9871            /**
9872             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and fileName = &#63;.
9873             *
9874             * @param groupId the group ID
9875             * @param folderId the folder ID
9876             * @param fileName the file name
9877             * @return the number of matching document library file entries
9878             */
9879            @Override
9880            public int countByG_F_FN(long groupId, long folderId, String fileName) {
9881                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_FN;
9882    
9883                    Object[] finderArgs = new Object[] { groupId, folderId, fileName };
9884    
9885                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9886    
9887                    if (count == null) {
9888                            StringBundler query = new StringBundler(4);
9889    
9890                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
9891    
9892                            query.append(_FINDER_COLUMN_G_F_FN_GROUPID_2);
9893    
9894                            query.append(_FINDER_COLUMN_G_F_FN_FOLDERID_2);
9895    
9896                            boolean bindFileName = false;
9897    
9898                            if (fileName == null) {
9899                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_1);
9900                            }
9901                            else if (fileName.equals(StringPool.BLANK)) {
9902                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_3);
9903                            }
9904                            else {
9905                                    bindFileName = true;
9906    
9907                                    query.append(_FINDER_COLUMN_G_F_FN_FILENAME_2);
9908                            }
9909    
9910                            String sql = query.toString();
9911    
9912                            Session session = null;
9913    
9914                            try {
9915                                    session = openSession();
9916    
9917                                    Query q = session.createQuery(sql);
9918    
9919                                    QueryPos qPos = QueryPos.getInstance(q);
9920    
9921                                    qPos.add(groupId);
9922    
9923                                    qPos.add(folderId);
9924    
9925                                    if (bindFileName) {
9926                                            qPos.add(fileName);
9927                                    }
9928    
9929                                    count = (Long)q.uniqueResult();
9930    
9931                                    finderCache.putResult(finderPath, finderArgs, count);
9932                            }
9933                            catch (Exception e) {
9934                                    finderCache.removeResult(finderPath, finderArgs);
9935    
9936                                    throw processException(e);
9937                            }
9938                            finally {
9939                                    closeSession(session);
9940                            }
9941                    }
9942    
9943                    return count.intValue();
9944            }
9945    
9946            private static final String _FINDER_COLUMN_G_F_FN_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
9947            private static final String _FINDER_COLUMN_G_F_FN_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
9948            private static final String _FINDER_COLUMN_G_F_FN_FILENAME_1 = "dlFileEntry.fileName IS NULL";
9949            private static final String _FINDER_COLUMN_G_F_FN_FILENAME_2 = "dlFileEntry.fileName = ?";
9950            private static final String _FINDER_COLUMN_G_F_FN_FILENAME_3 = "(dlFileEntry.fileName IS NULL OR dlFileEntry.fileName = '')";
9951            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9952                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
9953                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_T",
9954                            new String[] {
9955                                    Long.class.getName(), Long.class.getName(),
9956                                    String.class.getName()
9957                            },
9958                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
9959                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
9960                            DLFileEntryModelImpl.TITLE_COLUMN_BITMASK);
9961            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
9962                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9963                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_T",
9964                            new String[] {
9965                                    Long.class.getName(), Long.class.getName(),
9966                                    String.class.getName()
9967                            });
9968    
9969            /**
9970             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; or throws a {@link NoSuchFileEntryException} if it could not be found.
9971             *
9972             * @param groupId the group ID
9973             * @param folderId the folder ID
9974             * @param title the title
9975             * @return the matching document library file entry
9976             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
9977             */
9978            @Override
9979            public DLFileEntry findByG_F_T(long groupId, long folderId, String title)
9980                    throws NoSuchFileEntryException {
9981                    DLFileEntry dlFileEntry = fetchByG_F_T(groupId, folderId, title);
9982    
9983                    if (dlFileEntry == null) {
9984                            StringBundler msg = new StringBundler(8);
9985    
9986                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9987    
9988                            msg.append("groupId=");
9989                            msg.append(groupId);
9990    
9991                            msg.append(", folderId=");
9992                            msg.append(folderId);
9993    
9994                            msg.append(", title=");
9995                            msg.append(title);
9996    
9997                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9998    
9999                            if (_log.isWarnEnabled()) {
10000                                    _log.warn(msg.toString());
10001                            }
10002    
10003                            throw new NoSuchFileEntryException(msg.toString());
10004                    }
10005    
10006                    return dlFileEntry;
10007            }
10008    
10009            /**
10010             * 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.
10011             *
10012             * @param groupId the group ID
10013             * @param folderId the folder ID
10014             * @param title the title
10015             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
10016             */
10017            @Override
10018            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title) {
10019                    return fetchByG_F_T(groupId, folderId, title, true);
10020            }
10021    
10022            /**
10023             * 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.
10024             *
10025             * @param groupId the group ID
10026             * @param folderId the folder ID
10027             * @param title the title
10028             * @param retrieveFromCache whether to retrieve from the finder cache
10029             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
10030             */
10031            @Override
10032            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title,
10033                    boolean retrieveFromCache) {
10034                    Object[] finderArgs = new Object[] { groupId, folderId, title };
10035    
10036                    Object result = null;
10037    
10038                    if (retrieveFromCache) {
10039                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_F_T,
10040                                            finderArgs, this);
10041                    }
10042    
10043                    if (result instanceof DLFileEntry) {
10044                            DLFileEntry dlFileEntry = (DLFileEntry)result;
10045    
10046                            if ((groupId != dlFileEntry.getGroupId()) ||
10047                                            (folderId != dlFileEntry.getFolderId()) ||
10048                                            !Validator.equals(title, dlFileEntry.getTitle())) {
10049                                    result = null;
10050                            }
10051                    }
10052    
10053                    if (result == null) {
10054                            StringBundler query = new StringBundler(5);
10055    
10056                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
10057    
10058                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
10059    
10060                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
10061    
10062                            boolean bindTitle = false;
10063    
10064                            if (title == null) {
10065                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
10066                            }
10067                            else if (title.equals(StringPool.BLANK)) {
10068                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
10069                            }
10070                            else {
10071                                    bindTitle = true;
10072    
10073                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
10074                            }
10075    
10076                            String sql = query.toString();
10077    
10078                            Session session = null;
10079    
10080                            try {
10081                                    session = openSession();
10082    
10083                                    Query q = session.createQuery(sql);
10084    
10085                                    QueryPos qPos = QueryPos.getInstance(q);
10086    
10087                                    qPos.add(groupId);
10088    
10089                                    qPos.add(folderId);
10090    
10091                                    if (bindTitle) {
10092                                            qPos.add(title);
10093                                    }
10094    
10095                                    List<DLFileEntry> list = q.list();
10096    
10097                                    if (list.isEmpty()) {
10098                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_T,
10099                                                    finderArgs, list);
10100                                    }
10101                                    else {
10102                                            DLFileEntry dlFileEntry = list.get(0);
10103    
10104                                            result = dlFileEntry;
10105    
10106                                            cacheResult(dlFileEntry);
10107    
10108                                            if ((dlFileEntry.getGroupId() != groupId) ||
10109                                                            (dlFileEntry.getFolderId() != folderId) ||
10110                                                            (dlFileEntry.getTitle() == null) ||
10111                                                            !dlFileEntry.getTitle().equals(title)) {
10112                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_T,
10113                                                            finderArgs, dlFileEntry);
10114                                            }
10115                                    }
10116                            }
10117                            catch (Exception e) {
10118                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_T, finderArgs);
10119    
10120                                    throw processException(e);
10121                            }
10122                            finally {
10123                                    closeSession(session);
10124                            }
10125                    }
10126    
10127                    if (result instanceof List<?>) {
10128                            return null;
10129                    }
10130                    else {
10131                            return (DLFileEntry)result;
10132                    }
10133            }
10134    
10135            /**
10136             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; from the database.
10137             *
10138             * @param groupId the group ID
10139             * @param folderId the folder ID
10140             * @param title the title
10141             * @return the document library file entry that was removed
10142             */
10143            @Override
10144            public DLFileEntry removeByG_F_T(long groupId, long folderId, String title)
10145                    throws NoSuchFileEntryException {
10146                    DLFileEntry dlFileEntry = findByG_F_T(groupId, folderId, title);
10147    
10148                    return remove(dlFileEntry);
10149            }
10150    
10151            /**
10152             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and title = &#63;.
10153             *
10154             * @param groupId the group ID
10155             * @param folderId the folder ID
10156             * @param title the title
10157             * @return the number of matching document library file entries
10158             */
10159            @Override
10160            public int countByG_F_T(long groupId, long folderId, String title) {
10161                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_T;
10162    
10163                    Object[] finderArgs = new Object[] { groupId, folderId, title };
10164    
10165                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10166    
10167                    if (count == null) {
10168                            StringBundler query = new StringBundler(4);
10169    
10170                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
10171    
10172                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
10173    
10174                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
10175    
10176                            boolean bindTitle = false;
10177    
10178                            if (title == null) {
10179                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
10180                            }
10181                            else if (title.equals(StringPool.BLANK)) {
10182                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
10183                            }
10184                            else {
10185                                    bindTitle = true;
10186    
10187                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
10188                            }
10189    
10190                            String sql = query.toString();
10191    
10192                            Session session = null;
10193    
10194                            try {
10195                                    session = openSession();
10196    
10197                                    Query q = session.createQuery(sql);
10198    
10199                                    QueryPos qPos = QueryPos.getInstance(q);
10200    
10201                                    qPos.add(groupId);
10202    
10203                                    qPos.add(folderId);
10204    
10205                                    if (bindTitle) {
10206                                            qPos.add(title);
10207                                    }
10208    
10209                                    count = (Long)q.uniqueResult();
10210    
10211                                    finderCache.putResult(finderPath, finderArgs, count);
10212                            }
10213                            catch (Exception e) {
10214                                    finderCache.removeResult(finderPath, finderArgs);
10215    
10216                                    throw processException(e);
10217                            }
10218                            finally {
10219                                    closeSession(session);
10220                            }
10221                    }
10222    
10223                    return count.intValue();
10224            }
10225    
10226            private static final String _FINDER_COLUMN_G_F_T_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
10227            private static final String _FINDER_COLUMN_G_F_T_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
10228            private static final String _FINDER_COLUMN_G_F_T_TITLE_1 = "dlFileEntry.title IS NULL";
10229            private static final String _FINDER_COLUMN_G_F_T_TITLE_2 = "dlFileEntry.title = ?";
10230            private static final String _FINDER_COLUMN_G_F_T_TITLE_3 = "(dlFileEntry.title IS NULL OR dlFileEntry.title = '')";
10231            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
10232                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
10233                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F_F",
10234                            new String[] {
10235                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10236                                    
10237                            Integer.class.getName(), Integer.class.getName(),
10238                                    OrderByComparator.class.getName()
10239                            });
10240            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
10241                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
10242                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_F",
10243                            new String[] {
10244                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
10245                            },
10246                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
10247                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
10248                            DLFileEntryModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK |
10249                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
10250            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
10251                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10252                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_F",
10253                            new String[] {
10254                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
10255                            });
10256            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
10257                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10258                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_F",
10259                            new String[] {
10260                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
10261                            });
10262    
10263            /**
10264             * Returns all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10265             *
10266             * @param groupId the group ID
10267             * @param folderId the folder ID
10268             * @param fileEntryTypeId the file entry type ID
10269             * @return the matching document library file entries
10270             */
10271            @Override
10272            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
10273                    long fileEntryTypeId) {
10274                    return findByG_F_F(groupId, folderId, fileEntryTypeId,
10275                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10276            }
10277    
10278            /**
10279             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10280             *
10281             * <p>
10282             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10283             * </p>
10284             *
10285             * @param groupId the group ID
10286             * @param folderId the folder ID
10287             * @param fileEntryTypeId the file entry type ID
10288             * @param start the lower bound of the range of document library file entries
10289             * @param end the upper bound of the range of document library file entries (not inclusive)
10290             * @return the range of matching document library file entries
10291             */
10292            @Override
10293            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
10294                    long fileEntryTypeId, int start, int end) {
10295                    return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end, null);
10296            }
10297    
10298            /**
10299             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10300             *
10301             * <p>
10302             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10303             * </p>
10304             *
10305             * @param groupId the group ID
10306             * @param folderId the folder ID
10307             * @param fileEntryTypeId the file entry type ID
10308             * @param start the lower bound of the range of document library file entries
10309             * @param end the upper bound of the range of document library file entries (not inclusive)
10310             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10311             * @return the ordered range of matching document library file entries
10312             */
10313            @Override
10314            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
10315                    long fileEntryTypeId, int start, int end,
10316                    OrderByComparator<DLFileEntry> orderByComparator) {
10317                    return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end,
10318                            orderByComparator, true);
10319            }
10320    
10321            /**
10322             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10323             *
10324             * <p>
10325             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10326             * </p>
10327             *
10328             * @param groupId the group ID
10329             * @param folderId the folder ID
10330             * @param fileEntryTypeId the file entry type ID
10331             * @param start the lower bound of the range of document library file entries
10332             * @param end the upper bound of the range of document library file entries (not inclusive)
10333             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10334             * @param retrieveFromCache whether to retrieve from the finder cache
10335             * @return the ordered range of matching document library file entries
10336             */
10337            @Override
10338            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
10339                    long fileEntryTypeId, int start, int end,
10340                    OrderByComparator<DLFileEntry> orderByComparator,
10341                    boolean retrieveFromCache) {
10342                    boolean pagination = true;
10343                    FinderPath finderPath = null;
10344                    Object[] finderArgs = null;
10345    
10346                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10347                                    (orderByComparator == null)) {
10348                            pagination = false;
10349                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F;
10350                            finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
10351                    }
10352                    else {
10353                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F;
10354                            finderArgs = new Object[] {
10355                                            groupId, folderId, fileEntryTypeId,
10356                                            
10357                                            start, end, orderByComparator
10358                                    };
10359                    }
10360    
10361                    List<DLFileEntry> list = null;
10362    
10363                    if (retrieveFromCache) {
10364                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
10365                                            finderArgs, this);
10366    
10367                            if ((list != null) && !list.isEmpty()) {
10368                                    for (DLFileEntry dlFileEntry : list) {
10369                                            if ((groupId != dlFileEntry.getGroupId()) ||
10370                                                            (folderId != dlFileEntry.getFolderId()) ||
10371                                                            (fileEntryTypeId != dlFileEntry.getFileEntryTypeId())) {
10372                                                    list = null;
10373    
10374                                                    break;
10375                                            }
10376                                    }
10377                            }
10378                    }
10379    
10380                    if (list == null) {
10381                            StringBundler query = null;
10382    
10383                            if (orderByComparator != null) {
10384                                    query = new StringBundler(5 +
10385                                                    (orderByComparator.getOrderByFields().length * 3));
10386                            }
10387                            else {
10388                                    query = new StringBundler(5);
10389                            }
10390    
10391                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
10392    
10393                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10394    
10395                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10396    
10397                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10398    
10399                            if (orderByComparator != null) {
10400                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10401                                            orderByComparator);
10402                            }
10403                            else
10404                             if (pagination) {
10405                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10406                            }
10407    
10408                            String sql = query.toString();
10409    
10410                            Session session = null;
10411    
10412                            try {
10413                                    session = openSession();
10414    
10415                                    Query q = session.createQuery(sql);
10416    
10417                                    QueryPos qPos = QueryPos.getInstance(q);
10418    
10419                                    qPos.add(groupId);
10420    
10421                                    qPos.add(folderId);
10422    
10423                                    qPos.add(fileEntryTypeId);
10424    
10425                                    if (!pagination) {
10426                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
10427                                                            start, end, false);
10428    
10429                                            Collections.sort(list);
10430    
10431                                            list = Collections.unmodifiableList(list);
10432                                    }
10433                                    else {
10434                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
10435                                                            start, end);
10436                                    }
10437    
10438                                    cacheResult(list);
10439    
10440                                    finderCache.putResult(finderPath, finderArgs, list);
10441                            }
10442                            catch (Exception e) {
10443                                    finderCache.removeResult(finderPath, finderArgs);
10444    
10445                                    throw processException(e);
10446                            }
10447                            finally {
10448                                    closeSession(session);
10449                            }
10450                    }
10451    
10452                    return list;
10453            }
10454    
10455            /**
10456             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10457             *
10458             * @param groupId the group ID
10459             * @param folderId the folder ID
10460             * @param fileEntryTypeId the file entry type ID
10461             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10462             * @return the first matching document library file entry
10463             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
10464             */
10465            @Override
10466            public DLFileEntry findByG_F_F_First(long groupId, long folderId,
10467                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator)
10468                    throws NoSuchFileEntryException {
10469                    DLFileEntry dlFileEntry = fetchByG_F_F_First(groupId, folderId,
10470                                    fileEntryTypeId, orderByComparator);
10471    
10472                    if (dlFileEntry != null) {
10473                            return dlFileEntry;
10474                    }
10475    
10476                    StringBundler msg = new StringBundler(8);
10477    
10478                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10479    
10480                    msg.append("groupId=");
10481                    msg.append(groupId);
10482    
10483                    msg.append(", folderId=");
10484                    msg.append(folderId);
10485    
10486                    msg.append(", fileEntryTypeId=");
10487                    msg.append(fileEntryTypeId);
10488    
10489                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10490    
10491                    throw new NoSuchFileEntryException(msg.toString());
10492            }
10493    
10494            /**
10495             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10496             *
10497             * @param groupId the group ID
10498             * @param folderId the folder ID
10499             * @param fileEntryTypeId the file entry type ID
10500             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10501             * @return the first matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
10502             */
10503            @Override
10504            public DLFileEntry fetchByG_F_F_First(long groupId, long folderId,
10505                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator) {
10506                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
10507                                    fileEntryTypeId, 0, 1, orderByComparator);
10508    
10509                    if (!list.isEmpty()) {
10510                            return list.get(0);
10511                    }
10512    
10513                    return null;
10514            }
10515    
10516            /**
10517             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10518             *
10519             * @param groupId the group ID
10520             * @param folderId the folder ID
10521             * @param fileEntryTypeId the file entry type ID
10522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10523             * @return the last matching document library file entry
10524             * @throws NoSuchFileEntryException if a matching document library file entry could not be found
10525             */
10526            @Override
10527            public DLFileEntry findByG_F_F_Last(long groupId, long folderId,
10528                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator)
10529                    throws NoSuchFileEntryException {
10530                    DLFileEntry dlFileEntry = fetchByG_F_F_Last(groupId, folderId,
10531                                    fileEntryTypeId, orderByComparator);
10532    
10533                    if (dlFileEntry != null) {
10534                            return dlFileEntry;
10535                    }
10536    
10537                    StringBundler msg = new StringBundler(8);
10538    
10539                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10540    
10541                    msg.append("groupId=");
10542                    msg.append(groupId);
10543    
10544                    msg.append(", folderId=");
10545                    msg.append(folderId);
10546    
10547                    msg.append(", fileEntryTypeId=");
10548                    msg.append(fileEntryTypeId);
10549    
10550                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10551    
10552                    throw new NoSuchFileEntryException(msg.toString());
10553            }
10554    
10555            /**
10556             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10557             *
10558             * @param groupId the group ID
10559             * @param folderId the folder ID
10560             * @param fileEntryTypeId the file entry type ID
10561             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10562             * @return the last matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
10563             */
10564            @Override
10565            public DLFileEntry fetchByG_F_F_Last(long groupId, long folderId,
10566                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator) {
10567                    int count = countByG_F_F(groupId, folderId, fileEntryTypeId);
10568    
10569                    if (count == 0) {
10570                            return null;
10571                    }
10572    
10573                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
10574                                    fileEntryTypeId, count - 1, count, orderByComparator);
10575    
10576                    if (!list.isEmpty()) {
10577                            return list.get(0);
10578                    }
10579    
10580                    return null;
10581            }
10582    
10583            /**
10584             * 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;.
10585             *
10586             * @param fileEntryId the primary key of the current document library file entry
10587             * @param groupId the group ID
10588             * @param folderId the folder ID
10589             * @param fileEntryTypeId the file entry type ID
10590             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10591             * @return the previous, current, and next document library file entry
10592             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
10593             */
10594            @Override
10595            public DLFileEntry[] findByG_F_F_PrevAndNext(long fileEntryId,
10596                    long groupId, long folderId, long fileEntryTypeId,
10597                    OrderByComparator<DLFileEntry> orderByComparator)
10598                    throws NoSuchFileEntryException {
10599                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
10600    
10601                    Session session = null;
10602    
10603                    try {
10604                            session = openSession();
10605    
10606                            DLFileEntry[] array = new DLFileEntryImpl[3];
10607    
10608                            array[0] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
10609                                            folderId, fileEntryTypeId, orderByComparator, true);
10610    
10611                            array[1] = dlFileEntry;
10612    
10613                            array[2] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
10614                                            folderId, fileEntryTypeId, orderByComparator, false);
10615    
10616                            return array;
10617                    }
10618                    catch (Exception e) {
10619                            throw processException(e);
10620                    }
10621                    finally {
10622                            closeSession(session);
10623                    }
10624            }
10625    
10626            protected DLFileEntry getByG_F_F_PrevAndNext(Session session,
10627                    DLFileEntry dlFileEntry, long groupId, long folderId,
10628                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator,
10629                    boolean previous) {
10630                    StringBundler query = null;
10631    
10632                    if (orderByComparator != null) {
10633                            query = new StringBundler(6 +
10634                                            (orderByComparator.getOrderByFields().length * 6));
10635                    }
10636                    else {
10637                            query = new StringBundler(3);
10638                    }
10639    
10640                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
10641    
10642                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10643    
10644                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10645    
10646                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10647    
10648                    if (orderByComparator != null) {
10649                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10650    
10651                            if (orderByConditionFields.length > 0) {
10652                                    query.append(WHERE_AND);
10653                            }
10654    
10655                            for (int i = 0; i < orderByConditionFields.length; i++) {
10656                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10657                                    query.append(orderByConditionFields[i]);
10658    
10659                                    if ((i + 1) < orderByConditionFields.length) {
10660                                            if (orderByComparator.isAscending() ^ previous) {
10661                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10662                                            }
10663                                            else {
10664                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10665                                            }
10666                                    }
10667                                    else {
10668                                            if (orderByComparator.isAscending() ^ previous) {
10669                                                    query.append(WHERE_GREATER_THAN);
10670                                            }
10671                                            else {
10672                                                    query.append(WHERE_LESSER_THAN);
10673                                            }
10674                                    }
10675                            }
10676    
10677                            query.append(ORDER_BY_CLAUSE);
10678    
10679                            String[] orderByFields = orderByComparator.getOrderByFields();
10680    
10681                            for (int i = 0; i < orderByFields.length; i++) {
10682                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10683                                    query.append(orderByFields[i]);
10684    
10685                                    if ((i + 1) < orderByFields.length) {
10686                                            if (orderByComparator.isAscending() ^ previous) {
10687                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10688                                            }
10689                                            else {
10690                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10691                                            }
10692                                    }
10693                                    else {
10694                                            if (orderByComparator.isAscending() ^ previous) {
10695                                                    query.append(ORDER_BY_ASC);
10696                                            }
10697                                            else {
10698                                                    query.append(ORDER_BY_DESC);
10699                                            }
10700                                    }
10701                            }
10702                    }
10703                    else {
10704                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10705                    }
10706    
10707                    String sql = query.toString();
10708    
10709                    Query q = session.createQuery(sql);
10710    
10711                    q.setFirstResult(0);
10712                    q.setMaxResults(2);
10713    
10714                    QueryPos qPos = QueryPos.getInstance(q);
10715    
10716                    qPos.add(groupId);
10717    
10718                    qPos.add(folderId);
10719    
10720                    qPos.add(fileEntryTypeId);
10721    
10722                    if (orderByComparator != null) {
10723                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
10724    
10725                            for (Object value : values) {
10726                                    qPos.add(value);
10727                            }
10728                    }
10729    
10730                    List<DLFileEntry> list = q.list();
10731    
10732                    if (list.size() == 2) {
10733                            return list.get(1);
10734                    }
10735                    else {
10736                            return null;
10737                    }
10738            }
10739    
10740            /**
10741             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
10742             *
10743             * @param groupId the group ID
10744             * @param folderId the folder ID
10745             * @param fileEntryTypeId the file entry type ID
10746             * @return the matching document library file entries that the user has permission to view
10747             */
10748            @Override
10749            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
10750                    long fileEntryTypeId) {
10751                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId,
10752                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10753            }
10754    
10755            /**
10756             * 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;.
10757             *
10758             * <p>
10759             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10760             * </p>
10761             *
10762             * @param groupId the group ID
10763             * @param folderId the folder ID
10764             * @param fileEntryTypeId the file entry type ID
10765             * @param start the lower bound of the range of document library file entries
10766             * @param end the upper bound of the range of document library file entries (not inclusive)
10767             * @return the range of matching document library file entries that the user has permission to view
10768             */
10769            @Override
10770            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
10771                    long fileEntryTypeId, int start, int end) {
10772                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId, start,
10773                            end, null);
10774            }
10775    
10776            /**
10777             * 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;.
10778             *
10779             * <p>
10780             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10781             * </p>
10782             *
10783             * @param groupId the group ID
10784             * @param folderId the folder ID
10785             * @param fileEntryTypeId the file entry type ID
10786             * @param start the lower bound of the range of document library file entries
10787             * @param end the upper bound of the range of document library file entries (not inclusive)
10788             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10789             * @return the ordered range of matching document library file entries that the user has permission to view
10790             */
10791            @Override
10792            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
10793                    long fileEntryTypeId, int start, int end,
10794                    OrderByComparator<DLFileEntry> orderByComparator) {
10795                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10796                            return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end,
10797                                    orderByComparator);
10798                    }
10799    
10800                    StringBundler query = null;
10801    
10802                    if (orderByComparator != null) {
10803                            query = new StringBundler(5 +
10804                                            (orderByComparator.getOrderByFields().length * 3));
10805                    }
10806                    else {
10807                            query = new StringBundler(5);
10808                    }
10809    
10810                    if (getDB().isSupportsInlineDistinct()) {
10811                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
10812                    }
10813                    else {
10814                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
10815                    }
10816    
10817                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10818    
10819                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10820    
10821                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10822    
10823                    if (!getDB().isSupportsInlineDistinct()) {
10824                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
10825                    }
10826    
10827                    if (orderByComparator != null) {
10828                            if (getDB().isSupportsInlineDistinct()) {
10829                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10830                                            orderByComparator, true);
10831                            }
10832                            else {
10833                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10834                                            orderByComparator, true);
10835                            }
10836                    }
10837                    else {
10838                            if (getDB().isSupportsInlineDistinct()) {
10839                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
10840                            }
10841                            else {
10842                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
10843                            }
10844                    }
10845    
10846                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10847                                    DLFileEntry.class.getName(),
10848                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10849    
10850                    Session session = null;
10851    
10852                    try {
10853                            session = openSession();
10854    
10855                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10856    
10857                            if (getDB().isSupportsInlineDistinct()) {
10858                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
10859                            }
10860                            else {
10861                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
10862                            }
10863    
10864                            QueryPos qPos = QueryPos.getInstance(q);
10865    
10866                            qPos.add(groupId);
10867    
10868                            qPos.add(folderId);
10869    
10870                            qPos.add(fileEntryTypeId);
10871    
10872                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
10873                    }
10874                    catch (Exception e) {
10875                            throw processException(e);
10876                    }
10877                    finally {
10878                            closeSession(session);
10879                    }
10880            }
10881    
10882            /**
10883             * 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;.
10884             *
10885             * @param fileEntryId the primary key of the current document library file entry
10886             * @param groupId the group ID
10887             * @param folderId the folder ID
10888             * @param fileEntryTypeId the file entry type ID
10889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10890             * @return the previous, current, and next document library file entry
10891             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
10892             */
10893            @Override
10894            public DLFileEntry[] filterFindByG_F_F_PrevAndNext(long fileEntryId,
10895                    long groupId, long folderId, long fileEntryTypeId,
10896                    OrderByComparator<DLFileEntry> orderByComparator)
10897                    throws NoSuchFileEntryException {
10898                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10899                            return findByG_F_F_PrevAndNext(fileEntryId, groupId, folderId,
10900                                    fileEntryTypeId, orderByComparator);
10901                    }
10902    
10903                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
10904    
10905                    Session session = null;
10906    
10907                    try {
10908                            session = openSession();
10909    
10910                            DLFileEntry[] array = new DLFileEntryImpl[3];
10911    
10912                            array[0] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
10913                                            groupId, folderId, fileEntryTypeId, orderByComparator, true);
10914    
10915                            array[1] = dlFileEntry;
10916    
10917                            array[2] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
10918                                            groupId, folderId, fileEntryTypeId, orderByComparator, false);
10919    
10920                            return array;
10921                    }
10922                    catch (Exception e) {
10923                            throw processException(e);
10924                    }
10925                    finally {
10926                            closeSession(session);
10927                    }
10928            }
10929    
10930            protected DLFileEntry filterGetByG_F_F_PrevAndNext(Session session,
10931                    DLFileEntry dlFileEntry, long groupId, long folderId,
10932                    long fileEntryTypeId, OrderByComparator<DLFileEntry> orderByComparator,
10933                    boolean previous) {
10934                    StringBundler query = null;
10935    
10936                    if (orderByComparator != null) {
10937                            query = new StringBundler(6 +
10938                                            (orderByComparator.getOrderByFields().length * 6));
10939                    }
10940                    else {
10941                            query = new StringBundler(3);
10942                    }
10943    
10944                    if (getDB().isSupportsInlineDistinct()) {
10945                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
10946                    }
10947                    else {
10948                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
10949                    }
10950    
10951                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
10952    
10953                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
10954    
10955                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
10956    
10957                    if (!getDB().isSupportsInlineDistinct()) {
10958                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
10959                    }
10960    
10961                    if (orderByComparator != null) {
10962                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10963    
10964                            if (orderByConditionFields.length > 0) {
10965                                    query.append(WHERE_AND);
10966                            }
10967    
10968                            for (int i = 0; i < orderByConditionFields.length; i++) {
10969                                    if (getDB().isSupportsInlineDistinct()) {
10970                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10971                                    }
10972                                    else {
10973                                            query.append(_ORDER_BY_ENTITY_TABLE);
10974                                    }
10975    
10976                                    query.append(orderByConditionFields[i]);
10977    
10978                                    if ((i + 1) < orderByConditionFields.length) {
10979                                            if (orderByComparator.isAscending() ^ previous) {
10980                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10981                                            }
10982                                            else {
10983                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10984                                            }
10985                                    }
10986                                    else {
10987                                            if (orderByComparator.isAscending() ^ previous) {
10988                                                    query.append(WHERE_GREATER_THAN);
10989                                            }
10990                                            else {
10991                                                    query.append(WHERE_LESSER_THAN);
10992                                            }
10993                                    }
10994                            }
10995    
10996                            query.append(ORDER_BY_CLAUSE);
10997    
10998                            String[] orderByFields = orderByComparator.getOrderByFields();
10999    
11000                            for (int i = 0; i < orderByFields.length; i++) {
11001                                    if (getDB().isSupportsInlineDistinct()) {
11002                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11003                                    }
11004                                    else {
11005                                            query.append(_ORDER_BY_ENTITY_TABLE);
11006                                    }
11007    
11008                                    query.append(orderByFields[i]);
11009    
11010                                    if ((i + 1) < orderByFields.length) {
11011                                            if (orderByComparator.isAscending() ^ previous) {
11012                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11013                                            }
11014                                            else {
11015                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11016                                            }
11017                                    }
11018                                    else {
11019                                            if (orderByComparator.isAscending() ^ previous) {
11020                                                    query.append(ORDER_BY_ASC);
11021                                            }
11022                                            else {
11023                                                    query.append(ORDER_BY_DESC);
11024                                            }
11025                                    }
11026                            }
11027                    }
11028                    else {
11029                            if (getDB().isSupportsInlineDistinct()) {
11030                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
11031                            }
11032                            else {
11033                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
11034                            }
11035                    }
11036    
11037                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11038                                    DLFileEntry.class.getName(),
11039                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11040    
11041                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11042    
11043                    q.setFirstResult(0);
11044                    q.setMaxResults(2);
11045    
11046                    if (getDB().isSupportsInlineDistinct()) {
11047                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
11048                    }
11049                    else {
11050                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
11051                    }
11052    
11053                    QueryPos qPos = QueryPos.getInstance(q);
11054    
11055                    qPos.add(groupId);
11056    
11057                    qPos.add(folderId);
11058    
11059                    qPos.add(fileEntryTypeId);
11060    
11061                    if (orderByComparator != null) {
11062                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
11063    
11064                            for (Object value : values) {
11065                                    qPos.add(value);
11066                            }
11067                    }
11068    
11069                    List<DLFileEntry> list = q.list();
11070    
11071                    if (list.size() == 2) {
11072                            return list.get(1);
11073                    }
11074                    else {
11075                            return null;
11076                    }
11077            }
11078    
11079            /**
11080             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
11081             *
11082             * @param groupId the group ID
11083             * @param folderIds the folder IDs
11084             * @param fileEntryTypeId the file entry type ID
11085             * @return the matching document library file entries that the user has permission to view
11086             */
11087            @Override
11088            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
11089                    long fileEntryTypeId) {
11090                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId,
11091                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11092            }
11093    
11094            /**
11095             * 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;.
11096             *
11097             * <p>
11098             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11099             * </p>
11100             *
11101             * @param groupId the group ID
11102             * @param folderIds the folder IDs
11103             * @param fileEntryTypeId the file entry type ID
11104             * @param start the lower bound of the range of document library file entries
11105             * @param end the upper bound of the range of document library file entries (not inclusive)
11106             * @return the range of matching document library file entries that the user has permission to view
11107             */
11108            @Override
11109            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
11110                    long fileEntryTypeId, int start, int end) {
11111                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId, start,
11112                            end, null);
11113            }
11114    
11115            /**
11116             * 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;.
11117             *
11118             * <p>
11119             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11120             * </p>
11121             *
11122             * @param groupId the group ID
11123             * @param folderIds the folder IDs
11124             * @param fileEntryTypeId the file entry type ID
11125             * @param start the lower bound of the range of document library file entries
11126             * @param end the upper bound of the range of document library file entries (not inclusive)
11127             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11128             * @return the ordered range of matching document library file entries that the user has permission to view
11129             */
11130            @Override
11131            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
11132                    long fileEntryTypeId, int start, int end,
11133                    OrderByComparator<DLFileEntry> orderByComparator) {
11134                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11135                            return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end,
11136                                    orderByComparator);
11137                    }
11138    
11139                    if (folderIds == null) {
11140                            folderIds = new long[0];
11141                    }
11142                    else if (folderIds.length > 1) {
11143                            folderIds = ArrayUtil.unique(folderIds);
11144    
11145                            Arrays.sort(folderIds);
11146                    }
11147    
11148                    StringBundler query = new StringBundler();
11149    
11150                    if (getDB().isSupportsInlineDistinct()) {
11151                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
11152                    }
11153                    else {
11154                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
11155                    }
11156    
11157                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11158    
11159                    if (folderIds.length > 0) {
11160                            query.append(StringPool.OPEN_PARENTHESIS);
11161    
11162                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_7);
11163    
11164                            query.append(StringUtil.merge(folderIds));
11165    
11166                            query.append(StringPool.CLOSE_PARENTHESIS);
11167    
11168                            query.append(StringPool.CLOSE_PARENTHESIS);
11169    
11170                            query.append(WHERE_AND);
11171                    }
11172    
11173                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11174    
11175                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
11176                            query.index() - 1);
11177    
11178                    if (!getDB().isSupportsInlineDistinct()) {
11179                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
11180                    }
11181    
11182                    if (orderByComparator != null) {
11183                            if (getDB().isSupportsInlineDistinct()) {
11184                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11185                                            orderByComparator, true);
11186                            }
11187                            else {
11188                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11189                                            orderByComparator, true);
11190                            }
11191                    }
11192                    else {
11193                            if (getDB().isSupportsInlineDistinct()) {
11194                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
11195                            }
11196                            else {
11197                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
11198                            }
11199                    }
11200    
11201                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11202                                    DLFileEntry.class.getName(),
11203                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11204    
11205                    Session session = null;
11206    
11207                    try {
11208                            session = openSession();
11209    
11210                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11211    
11212                            if (getDB().isSupportsInlineDistinct()) {
11213                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
11214                            }
11215                            else {
11216                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
11217                            }
11218    
11219                            QueryPos qPos = QueryPos.getInstance(q);
11220    
11221                            qPos.add(groupId);
11222    
11223                            qPos.add(fileEntryTypeId);
11224    
11225                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
11226                    }
11227                    catch (Exception e) {
11228                            throw processException(e);
11229                    }
11230                    finally {
11231                            closeSession(session);
11232                    }
11233            }
11234    
11235            /**
11236             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
11237             *
11238             * <p>
11239             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11240             * </p>
11241             *
11242             * @param groupId the group ID
11243             * @param folderIds the folder IDs
11244             * @param fileEntryTypeId the file entry type ID
11245             * @return the matching document library file entries
11246             */
11247            @Override
11248            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
11249                    long fileEntryTypeId) {
11250                    return findByG_F_F(groupId, folderIds, fileEntryTypeId,
11251                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11252            }
11253    
11254            /**
11255             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
11256             *
11257             * <p>
11258             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11259             * </p>
11260             *
11261             * @param groupId the group ID
11262             * @param folderIds the folder IDs
11263             * @param fileEntryTypeId the file entry type ID
11264             * @param start the lower bound of the range of document library file entries
11265             * @param end the upper bound of the range of document library file entries (not inclusive)
11266             * @return the range of matching document library file entries
11267             */
11268            @Override
11269            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
11270                    long fileEntryTypeId, int start, int end) {
11271                    return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end, null);
11272            }
11273    
11274            /**
11275             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
11276             *
11277             * <p>
11278             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11279             * </p>
11280             *
11281             * @param groupId the group ID
11282             * @param folderIds the folder IDs
11283             * @param fileEntryTypeId the file entry type ID
11284             * @param start the lower bound of the range of document library file entries
11285             * @param end the upper bound of the range of document library file entries (not inclusive)
11286             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11287             * @return the ordered range of matching document library file entries
11288             */
11289            @Override
11290            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
11291                    long fileEntryTypeId, int start, int end,
11292                    OrderByComparator<DLFileEntry> orderByComparator) {
11293                    return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end,
11294                            orderByComparator, true);
11295            }
11296    
11297            /**
11298             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;, optionally using the finder cache.
11299             *
11300             * <p>
11301             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11302             * </p>
11303             *
11304             * @param groupId the group ID
11305             * @param folderId the folder ID
11306             * @param fileEntryTypeId the file entry type ID
11307             * @param start the lower bound of the range of document library file entries
11308             * @param end the upper bound of the range of document library file entries (not inclusive)
11309             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11310             * @param retrieveFromCache whether to retrieve from the finder cache
11311             * @return the ordered range of matching document library file entries
11312             */
11313            @Override
11314            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
11315                    long fileEntryTypeId, int start, int end,
11316                    OrderByComparator<DLFileEntry> orderByComparator,
11317                    boolean retrieveFromCache) {
11318                    if (folderIds == null) {
11319                            folderIds = new long[0];
11320                    }
11321                    else if (folderIds.length > 1) {
11322                            folderIds = ArrayUtil.unique(folderIds);
11323    
11324                            Arrays.sort(folderIds);
11325                    }
11326    
11327                    if (folderIds.length == 1) {
11328                            return findByG_F_F(groupId, folderIds[0], fileEntryTypeId, start,
11329                                    end, orderByComparator);
11330                    }
11331    
11332                    boolean pagination = true;
11333                    Object[] finderArgs = null;
11334    
11335                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11336                                    (orderByComparator == null)) {
11337                            pagination = false;
11338                            finderArgs = new Object[] {
11339                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId
11340                                    };
11341                    }
11342                    else {
11343                            finderArgs = new Object[] {
11344                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId,
11345                                            
11346                                            start, end, orderByComparator
11347                                    };
11348                    }
11349    
11350                    List<DLFileEntry> list = null;
11351    
11352                    if (retrieveFromCache) {
11353                            list = (List<DLFileEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
11354                                            finderArgs, this);
11355    
11356                            if ((list != null) && !list.isEmpty()) {
11357                                    for (DLFileEntry dlFileEntry : list) {
11358                                            if ((groupId != dlFileEntry.getGroupId()) ||
11359                                                            !ArrayUtil.contains(folderIds,
11360                                                                    dlFileEntry.getFolderId()) ||
11361                                                            (fileEntryTypeId != dlFileEntry.getFileEntryTypeId())) {
11362                                                    list = null;
11363    
11364                                                    break;
11365                                            }
11366                                    }
11367                            }
11368                    }
11369    
11370                    if (list == null) {
11371                            StringBundler query = new StringBundler();
11372    
11373                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
11374    
11375                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11376    
11377                            if (folderIds.length > 0) {
11378                                    query.append(StringPool.OPEN_PARENTHESIS);
11379    
11380                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_7);
11381    
11382                                    query.append(StringUtil.merge(folderIds));
11383    
11384                                    query.append(StringPool.CLOSE_PARENTHESIS);
11385    
11386                                    query.append(StringPool.CLOSE_PARENTHESIS);
11387    
11388                                    query.append(WHERE_AND);
11389                            }
11390    
11391                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11392    
11393                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
11394                                                    1)), query.index() - 1);
11395    
11396                            if (orderByComparator != null) {
11397                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11398                                            orderByComparator);
11399                            }
11400                            else
11401                             if (pagination) {
11402                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
11403                            }
11404    
11405                            String sql = query.toString();
11406    
11407                            Session session = null;
11408    
11409                            try {
11410                                    session = openSession();
11411    
11412                                    Query q = session.createQuery(sql);
11413    
11414                                    QueryPos qPos = QueryPos.getInstance(q);
11415    
11416                                    qPos.add(groupId);
11417    
11418                                    qPos.add(fileEntryTypeId);
11419    
11420                                    if (!pagination) {
11421                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
11422                                                            start, end, false);
11423    
11424                                            Collections.sort(list);
11425    
11426                                            list = Collections.unmodifiableList(list);
11427                                    }
11428                                    else {
11429                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
11430                                                            start, end);
11431                                    }
11432    
11433                                    cacheResult(list);
11434    
11435                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
11436                                            finderArgs, list);
11437                            }
11438                            catch (Exception e) {
11439                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F,
11440                                            finderArgs);
11441    
11442                                    throw processException(e);
11443                            }
11444                            finally {
11445                                    closeSession(session);
11446                            }
11447                    }
11448    
11449                    return list;
11450            }
11451    
11452            /**
11453             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63; from the database.
11454             *
11455             * @param groupId the group ID
11456             * @param folderId the folder ID
11457             * @param fileEntryTypeId the file entry type ID
11458             */
11459            @Override
11460            public void removeByG_F_F(long groupId, long folderId, long fileEntryTypeId) {
11461                    for (DLFileEntry dlFileEntry : findByG_F_F(groupId, folderId,
11462                                    fileEntryTypeId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11463                            remove(dlFileEntry);
11464                    }
11465            }
11466    
11467            /**
11468             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
11469             *
11470             * @param groupId the group ID
11471             * @param folderId the folder ID
11472             * @param fileEntryTypeId the file entry type ID
11473             * @return the number of matching document library file entries
11474             */
11475            @Override
11476            public int countByG_F_F(long groupId, long folderId, long fileEntryTypeId) {
11477                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_F;
11478    
11479                    Object[] finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
11480    
11481                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
11482    
11483                    if (count == null) {
11484                            StringBundler query = new StringBundler(4);
11485    
11486                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
11487    
11488                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11489    
11490                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
11491    
11492                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11493    
11494                            String sql = query.toString();
11495    
11496                            Session session = null;
11497    
11498                            try {
11499                                    session = openSession();
11500    
11501                                    Query q = session.createQuery(sql);
11502    
11503                                    QueryPos qPos = QueryPos.getInstance(q);
11504    
11505                                    qPos.add(groupId);
11506    
11507                                    qPos.add(folderId);
11508    
11509                                    qPos.add(fileEntryTypeId);
11510    
11511                                    count = (Long)q.uniqueResult();
11512    
11513                                    finderCache.putResult(finderPath, finderArgs, count);
11514                            }
11515                            catch (Exception e) {
11516                                    finderCache.removeResult(finderPath, finderArgs);
11517    
11518                                    throw processException(e);
11519                            }
11520                            finally {
11521                                    closeSession(session);
11522                            }
11523                    }
11524    
11525                    return count.intValue();
11526            }
11527    
11528            /**
11529             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
11530             *
11531             * @param groupId the group ID
11532             * @param folderIds the folder IDs
11533             * @param fileEntryTypeId the file entry type ID
11534             * @return the number of matching document library file entries
11535             */
11536            @Override
11537            public int countByG_F_F(long groupId, long[] folderIds, long fileEntryTypeId) {
11538                    if (folderIds == null) {
11539                            folderIds = new long[0];
11540                    }
11541                    else if (folderIds.length > 1) {
11542                            folderIds = ArrayUtil.unique(folderIds);
11543    
11544                            Arrays.sort(folderIds);
11545                    }
11546    
11547                    Object[] finderArgs = new Object[] {
11548                                    groupId, StringUtil.merge(folderIds), fileEntryTypeId
11549                            };
11550    
11551                    Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
11552                                    finderArgs, this);
11553    
11554                    if (count == null) {
11555                            StringBundler query = new StringBundler();
11556    
11557                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
11558    
11559                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11560    
11561                            if (folderIds.length > 0) {
11562                                    query.append(StringPool.OPEN_PARENTHESIS);
11563    
11564                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_7);
11565    
11566                                    query.append(StringUtil.merge(folderIds));
11567    
11568                                    query.append(StringPool.CLOSE_PARENTHESIS);
11569    
11570                                    query.append(StringPool.CLOSE_PARENTHESIS);
11571    
11572                                    query.append(WHERE_AND);
11573                            }
11574    
11575                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11576    
11577                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
11578                                                    1)), query.index() - 1);
11579    
11580                            String sql = query.toString();
11581    
11582                            Session session = null;
11583    
11584                            try {
11585                                    session = openSession();
11586    
11587                                    Query q = session.createQuery(sql);
11588    
11589                                    QueryPos qPos = QueryPos.getInstance(q);
11590    
11591                                    qPos.add(groupId);
11592    
11593                                    qPos.add(fileEntryTypeId);
11594    
11595                                    count = (Long)q.uniqueResult();
11596    
11597                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
11598                                            finderArgs, count);
11599                            }
11600                            catch (Exception e) {
11601                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_F,
11602                                            finderArgs);
11603    
11604                                    throw processException(e);
11605                            }
11606                            finally {
11607                                    closeSession(session);
11608                            }
11609                    }
11610    
11611                    return count.intValue();
11612            }
11613    
11614            /**
11615             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
11616             *
11617             * @param groupId the group ID
11618             * @param folderId the folder ID
11619             * @param fileEntryTypeId the file entry type ID
11620             * @return the number of matching document library file entries that the user has permission to view
11621             */
11622            @Override
11623            public int filterCountByG_F_F(long groupId, long folderId,
11624                    long fileEntryTypeId) {
11625                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11626                            return countByG_F_F(groupId, folderId, fileEntryTypeId);
11627                    }
11628    
11629                    StringBundler query = new StringBundler(4);
11630    
11631                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
11632    
11633                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11634    
11635                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
11636    
11637                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11638    
11639                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11640                                    DLFileEntry.class.getName(),
11641                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11642    
11643                    Session session = null;
11644    
11645                    try {
11646                            session = openSession();
11647    
11648                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11649    
11650                            q.addScalar(COUNT_COLUMN_NAME,
11651                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11652    
11653                            QueryPos qPos = QueryPos.getInstance(q);
11654    
11655                            qPos.add(groupId);
11656    
11657                            qPos.add(folderId);
11658    
11659                            qPos.add(fileEntryTypeId);
11660    
11661                            Long count = (Long)q.uniqueResult();
11662    
11663                            return count.intValue();
11664                    }
11665                    catch (Exception e) {
11666                            throw processException(e);
11667                    }
11668                    finally {
11669                            closeSession(session);
11670                    }
11671            }
11672    
11673            /**
11674             * 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;.
11675             *
11676             * @param groupId the group ID
11677             * @param folderIds the folder IDs
11678             * @param fileEntryTypeId the file entry type ID
11679             * @return the number of matching document library file entries that the user has permission to view
11680             */
11681            @Override
11682            public int filterCountByG_F_F(long groupId, long[] folderIds,
11683                    long fileEntryTypeId) {
11684                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11685                            return countByG_F_F(groupId, folderIds, fileEntryTypeId);
11686                    }
11687    
11688                    if (folderIds == null) {
11689                            folderIds = new long[0];
11690                    }
11691                    else if (folderIds.length > 1) {
11692                            folderIds = ArrayUtil.unique(folderIds);
11693    
11694                            Arrays.sort(folderIds);
11695                    }
11696    
11697                    StringBundler query = new StringBundler();
11698    
11699                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
11700    
11701                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
11702    
11703                    if (folderIds.length > 0) {
11704                            query.append(StringPool.OPEN_PARENTHESIS);
11705    
11706                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_7);
11707    
11708                            query.append(StringUtil.merge(folderIds));
11709    
11710                            query.append(StringPool.CLOSE_PARENTHESIS);
11711    
11712                            query.append(StringPool.CLOSE_PARENTHESIS);
11713    
11714                            query.append(WHERE_AND);
11715                    }
11716    
11717                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
11718    
11719                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
11720                            query.index() - 1);
11721    
11722                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11723                                    DLFileEntry.class.getName(),
11724                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11725    
11726                    Session session = null;
11727    
11728                    try {
11729                            session = openSession();
11730    
11731                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11732    
11733                            q.addScalar(COUNT_COLUMN_NAME,
11734                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11735    
11736                            QueryPos qPos = QueryPos.getInstance(q);
11737    
11738                            qPos.add(groupId);
11739    
11740                            qPos.add(fileEntryTypeId);
11741    
11742                            Long count = (Long)q.uniqueResult();
11743    
11744                            return count.intValue();
11745                    }
11746                    catch (Exception e) {
11747                            throw processException(e);
11748                    }
11749                    finally {
11750                            closeSession(session);
11751                    }
11752            }
11753    
11754            private static final String _FINDER_COLUMN_G_F_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
11755            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
11756            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_7 = "dlFileEntry.folderId IN (";
11757            private static final String _FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2 = "dlFileEntry.fileEntryTypeId = ?";
11758    
11759            public DLFileEntryPersistenceImpl() {
11760                    setModelClass(DLFileEntry.class);
11761            }
11762    
11763            /**
11764             * Caches the document library file entry in the entity cache if it is enabled.
11765             *
11766             * @param dlFileEntry the document library file entry
11767             */
11768            @Override
11769            public void cacheResult(DLFileEntry dlFileEntry) {
11770                    entityCache.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11771                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
11772    
11773                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
11774                            new Object[] { dlFileEntry.getUuid(), dlFileEntry.getGroupId() },
11775                            dlFileEntry);
11776    
11777                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_N,
11778                            new Object[] {
11779                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11780                                    dlFileEntry.getName()
11781                            }, dlFileEntry);
11782    
11783                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_FN,
11784                            new Object[] {
11785                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11786                                    dlFileEntry.getFileName()
11787                            }, dlFileEntry);
11788    
11789                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_T,
11790                            new Object[] {
11791                                    dlFileEntry.getGroupId(), dlFileEntry.getFolderId(),
11792                                    dlFileEntry.getTitle()
11793                            }, dlFileEntry);
11794    
11795                    dlFileEntry.resetOriginalValues();
11796            }
11797    
11798            /**
11799             * Caches the document library file entries in the entity cache if it is enabled.
11800             *
11801             * @param dlFileEntries the document library file entries
11802             */
11803            @Override
11804            public void cacheResult(List<DLFileEntry> dlFileEntries) {
11805                    for (DLFileEntry dlFileEntry : dlFileEntries) {
11806                            if (entityCache.getResult(
11807                                                    DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11808                                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey()) == null) {
11809                                    cacheResult(dlFileEntry);
11810                            }
11811                            else {
11812                                    dlFileEntry.resetOriginalValues();
11813                            }
11814                    }
11815            }
11816    
11817            /**
11818             * Clears the cache for all document library file entries.
11819             *
11820             * <p>
11821             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
11822             * </p>
11823             */
11824            @Override
11825            public void clearCache() {
11826                    entityCache.clearCache(DLFileEntryImpl.class);
11827    
11828                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
11829                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11830                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11831            }
11832    
11833            /**
11834             * Clears the cache for the document library file entry.
11835             *
11836             * <p>
11837             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
11838             * </p>
11839             */
11840            @Override
11841            public void clearCache(DLFileEntry dlFileEntry) {
11842                    entityCache.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11843                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
11844    
11845                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11846                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11847    
11848                    clearUniqueFindersCache((DLFileEntryModelImpl)dlFileEntry);
11849            }
11850    
11851            @Override
11852            public void clearCache(List<DLFileEntry> dlFileEntries) {
11853                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11854                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11855    
11856                    for (DLFileEntry dlFileEntry : dlFileEntries) {
11857                            entityCache.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
11858                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
11859    
11860                            clearUniqueFindersCache((DLFileEntryModelImpl)dlFileEntry);
11861                    }
11862            }
11863    
11864            protected void cacheUniqueFindersCache(
11865                    DLFileEntryModelImpl dlFileEntryModelImpl, boolean isNew) {
11866                    if (isNew) {
11867                            Object[] args = new Object[] {
11868                                            dlFileEntryModelImpl.getUuid(),
11869                                            dlFileEntryModelImpl.getGroupId()
11870                                    };
11871    
11872                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
11873                                    Long.valueOf(1));
11874                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
11875                                    dlFileEntryModelImpl);
11876    
11877                            args = new Object[] {
11878                                            dlFileEntryModelImpl.getGroupId(),
11879                                            dlFileEntryModelImpl.getFolderId(),
11880                                            dlFileEntryModelImpl.getName()
11881                                    };
11882    
11883                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_F_N, args,
11884                                    Long.valueOf(1));
11885                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_N, args,
11886                                    dlFileEntryModelImpl);
11887    
11888                            args = new Object[] {
11889                                            dlFileEntryModelImpl.getGroupId(),
11890                                            dlFileEntryModelImpl.getFolderId(),
11891                                            dlFileEntryModelImpl.getFileName()
11892                                    };
11893    
11894                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_F_FN, args,
11895                                    Long.valueOf(1));
11896                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_FN, args,
11897                                    dlFileEntryModelImpl);
11898    
11899                            args = new Object[] {
11900                                            dlFileEntryModelImpl.getGroupId(),
11901                                            dlFileEntryModelImpl.getFolderId(),
11902                                            dlFileEntryModelImpl.getTitle()
11903                                    };
11904    
11905                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_F_T, args,
11906                                    Long.valueOf(1));
11907                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_T, args,
11908                                    dlFileEntryModelImpl);
11909                    }
11910                    else {
11911                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11912                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
11913                                    Object[] args = new Object[] {
11914                                                    dlFileEntryModelImpl.getUuid(),
11915                                                    dlFileEntryModelImpl.getGroupId()
11916                                            };
11917    
11918                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
11919                                            Long.valueOf(1));
11920                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
11921                                            dlFileEntryModelImpl);
11922                            }
11923    
11924                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11925                                            FINDER_PATH_FETCH_BY_G_F_N.getColumnBitmask()) != 0) {
11926                                    Object[] args = new Object[] {
11927                                                    dlFileEntryModelImpl.getGroupId(),
11928                                                    dlFileEntryModelImpl.getFolderId(),
11929                                                    dlFileEntryModelImpl.getName()
11930                                            };
11931    
11932                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_F_N, args,
11933                                            Long.valueOf(1));
11934                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_N, args,
11935                                            dlFileEntryModelImpl);
11936                            }
11937    
11938                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11939                                            FINDER_PATH_FETCH_BY_G_F_FN.getColumnBitmask()) != 0) {
11940                                    Object[] args = new Object[] {
11941                                                    dlFileEntryModelImpl.getGroupId(),
11942                                                    dlFileEntryModelImpl.getFolderId(),
11943                                                    dlFileEntryModelImpl.getFileName()
11944                                            };
11945    
11946                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_F_FN, args,
11947                                            Long.valueOf(1));
11948                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_FN, args,
11949                                            dlFileEntryModelImpl);
11950                            }
11951    
11952                            if ((dlFileEntryModelImpl.getColumnBitmask() &
11953                                            FINDER_PATH_FETCH_BY_G_F_T.getColumnBitmask()) != 0) {
11954                                    Object[] args = new Object[] {
11955                                                    dlFileEntryModelImpl.getGroupId(),
11956                                                    dlFileEntryModelImpl.getFolderId(),
11957                                                    dlFileEntryModelImpl.getTitle()
11958                                            };
11959    
11960                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_F_T, args,
11961                                            Long.valueOf(1));
11962                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F_T, args,
11963                                            dlFileEntryModelImpl);
11964                            }
11965                    }
11966            }
11967    
11968            protected void clearUniqueFindersCache(
11969                    DLFileEntryModelImpl dlFileEntryModelImpl) {
11970                    Object[] args = new Object[] {
11971                                    dlFileEntryModelImpl.getUuid(),
11972                                    dlFileEntryModelImpl.getGroupId()
11973                            };
11974    
11975                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
11976                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
11977    
11978                    if ((dlFileEntryModelImpl.getColumnBitmask() &
11979                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
11980                            args = new Object[] {
11981                                            dlFileEntryModelImpl.getOriginalUuid(),
11982                                            dlFileEntryModelImpl.getOriginalGroupId()
11983                                    };
11984    
11985                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
11986                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
11987                    }
11988    
11989                    args = new Object[] {
11990                                    dlFileEntryModelImpl.getGroupId(),
11991                                    dlFileEntryModelImpl.getFolderId(),
11992                                    dlFileEntryModelImpl.getName()
11993                            };
11994    
11995                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_N, args);
11996                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_N, args);
11997    
11998                    if ((dlFileEntryModelImpl.getColumnBitmask() &
11999                                    FINDER_PATH_FETCH_BY_G_F_N.getColumnBitmask()) != 0) {
12000                            args = new Object[] {
12001                                            dlFileEntryModelImpl.getOriginalGroupId(),
12002                                            dlFileEntryModelImpl.getOriginalFolderId(),
12003                                            dlFileEntryModelImpl.getOriginalName()
12004                                    };
12005    
12006                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_N, args);
12007                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_N, args);
12008                    }
12009    
12010                    args = new Object[] {
12011                                    dlFileEntryModelImpl.getGroupId(),
12012                                    dlFileEntryModelImpl.getFolderId(),
12013                                    dlFileEntryModelImpl.getFileName()
12014                            };
12015    
12016                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_FN, args);
12017                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_FN, args);
12018    
12019                    if ((dlFileEntryModelImpl.getColumnBitmask() &
12020                                    FINDER_PATH_FETCH_BY_G_F_FN.getColumnBitmask()) != 0) {
12021                            args = new Object[] {
12022                                            dlFileEntryModelImpl.getOriginalGroupId(),
12023                                            dlFileEntryModelImpl.getOriginalFolderId(),
12024                                            dlFileEntryModelImpl.getOriginalFileName()
12025                                    };
12026    
12027                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_FN, args);
12028                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_FN, args);
12029                    }
12030    
12031                    args = new Object[] {
12032                                    dlFileEntryModelImpl.getGroupId(),
12033                                    dlFileEntryModelImpl.getFolderId(),
12034                                    dlFileEntryModelImpl.getTitle()
12035                            };
12036    
12037                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_T, args);
12038                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_T, args);
12039    
12040                    if ((dlFileEntryModelImpl.getColumnBitmask() &
12041                                    FINDER_PATH_FETCH_BY_G_F_T.getColumnBitmask()) != 0) {
12042                            args = new Object[] {
12043                                            dlFileEntryModelImpl.getOriginalGroupId(),
12044                                            dlFileEntryModelImpl.getOriginalFolderId(),
12045                                            dlFileEntryModelImpl.getOriginalTitle()
12046                                    };
12047    
12048                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_T, args);
12049                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F_T, args);
12050                    }
12051            }
12052    
12053            /**
12054             * Creates a new document library file entry with the primary key. Does not add the document library file entry to the database.
12055             *
12056             * @param fileEntryId the primary key for the new document library file entry
12057             * @return the new document library file entry
12058             */
12059            @Override
12060            public DLFileEntry create(long fileEntryId) {
12061                    DLFileEntry dlFileEntry = new DLFileEntryImpl();
12062    
12063                    dlFileEntry.setNew(true);
12064                    dlFileEntry.setPrimaryKey(fileEntryId);
12065    
12066                    String uuid = PortalUUIDUtil.generate();
12067    
12068                    dlFileEntry.setUuid(uuid);
12069    
12070                    return dlFileEntry;
12071            }
12072    
12073            /**
12074             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
12075             *
12076             * @param fileEntryId the primary key of the document library file entry
12077             * @return the document library file entry that was removed
12078             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
12079             */
12080            @Override
12081            public DLFileEntry remove(long fileEntryId) throws NoSuchFileEntryException {
12082                    return remove((Serializable)fileEntryId);
12083            }
12084    
12085            /**
12086             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
12087             *
12088             * @param primaryKey the primary key of the document library file entry
12089             * @return the document library file entry that was removed
12090             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
12091             */
12092            @Override
12093            public DLFileEntry remove(Serializable primaryKey)
12094                    throws NoSuchFileEntryException {
12095                    Session session = null;
12096    
12097                    try {
12098                            session = openSession();
12099    
12100                            DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
12101                                            primaryKey);
12102    
12103                            if (dlFileEntry == null) {
12104                                    if (_log.isWarnEnabled()) {
12105                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
12106                                    }
12107    
12108                                    throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
12109                                            primaryKey);
12110                            }
12111    
12112                            return remove(dlFileEntry);
12113                    }
12114                    catch (NoSuchFileEntryException nsee) {
12115                            throw nsee;
12116                    }
12117                    catch (Exception e) {
12118                            throw processException(e);
12119                    }
12120                    finally {
12121                            closeSession(session);
12122                    }
12123            }
12124    
12125            @Override
12126            protected DLFileEntry removeImpl(DLFileEntry dlFileEntry) {
12127                    dlFileEntry = toUnwrappedModel(dlFileEntry);
12128    
12129                    Session session = null;
12130    
12131                    try {
12132                            session = openSession();
12133    
12134                            if (!session.contains(dlFileEntry)) {
12135                                    dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
12136                                                    dlFileEntry.getPrimaryKeyObj());
12137                            }
12138    
12139                            if (dlFileEntry != null) {
12140                                    session.delete(dlFileEntry);
12141                            }
12142                    }
12143                    catch (Exception e) {
12144                            throw processException(e);
12145                    }
12146                    finally {
12147                            closeSession(session);
12148                    }
12149    
12150                    if (dlFileEntry != null) {
12151                            clearCache(dlFileEntry);
12152                    }
12153    
12154                    return dlFileEntry;
12155            }
12156    
12157            @Override
12158            public DLFileEntry updateImpl(DLFileEntry dlFileEntry) {
12159                    dlFileEntry = toUnwrappedModel(dlFileEntry);
12160    
12161                    boolean isNew = dlFileEntry.isNew();
12162    
12163                    DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
12164    
12165                    if (Validator.isNull(dlFileEntry.getUuid())) {
12166                            String uuid = PortalUUIDUtil.generate();
12167    
12168                            dlFileEntry.setUuid(uuid);
12169                    }
12170    
12171                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
12172    
12173                    Date now = new Date();
12174    
12175                    if (isNew && (dlFileEntry.getCreateDate() == null)) {
12176                            if (serviceContext == null) {
12177                                    dlFileEntry.setCreateDate(now);
12178                            }
12179                            else {
12180                                    dlFileEntry.setCreateDate(serviceContext.getCreateDate(now));
12181                            }
12182                    }
12183    
12184                    if (!dlFileEntryModelImpl.hasSetModifiedDate()) {
12185                            if (serviceContext == null) {
12186                                    dlFileEntry.setModifiedDate(now);
12187                            }
12188                            else {
12189                                    dlFileEntry.setModifiedDate(serviceContext.getModifiedDate(now));
12190                            }
12191                    }
12192    
12193                    Session session = null;
12194    
12195                    try {
12196                            session = openSession();
12197    
12198                            if (dlFileEntry.isNew()) {
12199                                    session.save(dlFileEntry);
12200    
12201                                    dlFileEntry.setNew(false);
12202                            }
12203                            else {
12204                                    dlFileEntry = (DLFileEntry)session.merge(dlFileEntry);
12205                            }
12206                    }
12207                    catch (Exception e) {
12208                            throw processException(e);
12209                    }
12210                    finally {
12211                            closeSession(session);
12212                    }
12213    
12214                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12215    
12216                    if (isNew || !DLFileEntryModelImpl.COLUMN_BITMASK_ENABLED) {
12217                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12218                    }
12219    
12220                    else {
12221                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12222                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
12223                                    Object[] args = new Object[] {
12224                                                    dlFileEntryModelImpl.getOriginalUuid()
12225                                            };
12226    
12227                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
12228                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
12229                                            args);
12230    
12231                                    args = new Object[] { dlFileEntryModelImpl.getUuid() };
12232    
12233                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
12234                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
12235                                            args);
12236                            }
12237    
12238                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12239                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
12240                                    Object[] args = new Object[] {
12241                                                    dlFileEntryModelImpl.getOriginalUuid(),
12242                                                    dlFileEntryModelImpl.getOriginalCompanyId()
12243                                            };
12244    
12245                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
12246                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
12247                                            args);
12248    
12249                                    args = new Object[] {
12250                                                    dlFileEntryModelImpl.getUuid(),
12251                                                    dlFileEntryModelImpl.getCompanyId()
12252                                            };
12253    
12254                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
12255                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
12256                                            args);
12257                            }
12258    
12259                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12260                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
12261                                    Object[] args = new Object[] {
12262                                                    dlFileEntryModelImpl.getOriginalGroupId()
12263                                            };
12264    
12265                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
12266                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
12267                                            args);
12268    
12269                                    args = new Object[] { dlFileEntryModelImpl.getGroupId() };
12270    
12271                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
12272                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
12273                                            args);
12274                            }
12275    
12276                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12277                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
12278                                    Object[] args = new Object[] {
12279                                                    dlFileEntryModelImpl.getOriginalCompanyId()
12280                                            };
12281    
12282                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
12283                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
12284                                            args);
12285    
12286                                    args = new Object[] { dlFileEntryModelImpl.getCompanyId() };
12287    
12288                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
12289                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
12290                                            args);
12291                            }
12292    
12293                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12294                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID.getColumnBitmask()) != 0) {
12295                                    Object[] args = new Object[] {
12296                                                    dlFileEntryModelImpl.getOriginalRepositoryId()
12297                                            };
12298    
12299                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID, args);
12300                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
12301                                            args);
12302    
12303                                    args = new Object[] { dlFileEntryModelImpl.getRepositoryId() };
12304    
12305                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID, args);
12306                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
12307                                            args);
12308                            }
12309    
12310                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12311                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE.getColumnBitmask()) != 0) {
12312                                    Object[] args = new Object[] {
12313                                                    dlFileEntryModelImpl.getOriginalMimeType()
12314                                            };
12315    
12316                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_MIMETYPE, args);
12317                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE,
12318                                            args);
12319    
12320                                    args = new Object[] { dlFileEntryModelImpl.getMimeType() };
12321    
12322                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_MIMETYPE, args);
12323                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MIMETYPE,
12324                                            args);
12325                            }
12326    
12327                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12328                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID.getColumnBitmask()) != 0) {
12329                                    Object[] args = new Object[] {
12330                                                    dlFileEntryModelImpl.getOriginalFileEntryTypeId()
12331                                            };
12332    
12333                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
12334                                            args);
12335                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
12336                                            args);
12337    
12338                                    args = new Object[] { dlFileEntryModelImpl.getFileEntryTypeId() };
12339    
12340                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
12341                                            args);
12342                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
12343                                            args);
12344                            }
12345    
12346                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12347                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
12348                                    Object[] args = new Object[] {
12349                                                    dlFileEntryModelImpl.getOriginalGroupId(),
12350                                                    dlFileEntryModelImpl.getOriginalUserId()
12351                                            };
12352    
12353                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
12354                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
12355                                            args);
12356    
12357                                    args = new Object[] {
12358                                                    dlFileEntryModelImpl.getGroupId(),
12359                                                    dlFileEntryModelImpl.getUserId()
12360                                            };
12361    
12362                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
12363                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
12364                                            args);
12365                            }
12366    
12367                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12368                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
12369                                    Object[] args = new Object[] {
12370                                                    dlFileEntryModelImpl.getOriginalGroupId(),
12371                                                    dlFileEntryModelImpl.getOriginalFolderId()
12372                                            };
12373    
12374                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
12375                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
12376                                            args);
12377    
12378                                    args = new Object[] {
12379                                                    dlFileEntryModelImpl.getGroupId(),
12380                                                    dlFileEntryModelImpl.getFolderId()
12381                                            };
12382    
12383                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
12384                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
12385                                            args);
12386                            }
12387    
12388                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12389                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F.getColumnBitmask()) != 0) {
12390                                    Object[] args = new Object[] {
12391                                                    dlFileEntryModelImpl.getOriginalRepositoryId(),
12392                                                    dlFileEntryModelImpl.getOriginalFolderId()
12393                                            };
12394    
12395                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_R_F, args);
12396                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F,
12397                                            args);
12398    
12399                                    args = new Object[] {
12400                                                    dlFileEntryModelImpl.getRepositoryId(),
12401                                                    dlFileEntryModelImpl.getFolderId()
12402                                            };
12403    
12404                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_R_F, args);
12405                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_F,
12406                                            args);
12407                            }
12408    
12409                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12410                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N.getColumnBitmask()) != 0) {
12411                                    Object[] args = new Object[] {
12412                                                    dlFileEntryModelImpl.getOriginalFolderId(),
12413                                                    dlFileEntryModelImpl.getOriginalName()
12414                                            };
12415    
12416                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_F_N, args);
12417                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N,
12418                                            args);
12419    
12420                                    args = new Object[] {
12421                                                    dlFileEntryModelImpl.getFolderId(),
12422                                                    dlFileEntryModelImpl.getName()
12423                                            };
12424    
12425                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_F_N, args);
12426                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_N,
12427                                            args);
12428                            }
12429    
12430                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12431                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F.getColumnBitmask()) != 0) {
12432                                    Object[] args = new Object[] {
12433                                                    dlFileEntryModelImpl.getOriginalGroupId(),
12434                                                    dlFileEntryModelImpl.getOriginalUserId(),
12435                                                    dlFileEntryModelImpl.getOriginalFolderId()
12436                                            };
12437    
12438                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
12439                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
12440                                            args);
12441    
12442                                    args = new Object[] {
12443                                                    dlFileEntryModelImpl.getGroupId(),
12444                                                    dlFileEntryModelImpl.getUserId(),
12445                                                    dlFileEntryModelImpl.getFolderId()
12446                                            };
12447    
12448                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
12449                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
12450                                            args);
12451                            }
12452    
12453                            if ((dlFileEntryModelImpl.getColumnBitmask() &
12454                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F.getColumnBitmask()) != 0) {
12455                                    Object[] args = new Object[] {
12456                                                    dlFileEntryModelImpl.getOriginalGroupId(),
12457                                                    dlFileEntryModelImpl.getOriginalFolderId(),
12458                                                    dlFileEntryModelImpl.getOriginalFileEntryTypeId()
12459                                            };
12460    
12461                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
12462                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
12463                                            args);
12464    
12465                                    args = new Object[] {
12466                                                    dlFileEntryModelImpl.getGroupId(),
12467                                                    dlFileEntryModelImpl.getFolderId(),
12468                                                    dlFileEntryModelImpl.getFileEntryTypeId()
12469                                            };
12470    
12471                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
12472                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
12473                                            args);
12474                            }
12475                    }
12476    
12477                    entityCache.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12478                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry,
12479                            false);
12480    
12481                    clearUniqueFindersCache(dlFileEntryModelImpl);
12482                    cacheUniqueFindersCache(dlFileEntryModelImpl, isNew);
12483    
12484                    dlFileEntry.resetOriginalValues();
12485    
12486                    return dlFileEntry;
12487            }
12488    
12489            protected DLFileEntry toUnwrappedModel(DLFileEntry dlFileEntry) {
12490                    if (dlFileEntry instanceof DLFileEntryImpl) {
12491                            return dlFileEntry;
12492                    }
12493    
12494                    DLFileEntryImpl dlFileEntryImpl = new DLFileEntryImpl();
12495    
12496                    dlFileEntryImpl.setNew(dlFileEntry.isNew());
12497                    dlFileEntryImpl.setPrimaryKey(dlFileEntry.getPrimaryKey());
12498    
12499                    dlFileEntryImpl.setUuid(dlFileEntry.getUuid());
12500                    dlFileEntryImpl.setFileEntryId(dlFileEntry.getFileEntryId());
12501                    dlFileEntryImpl.setGroupId(dlFileEntry.getGroupId());
12502                    dlFileEntryImpl.setCompanyId(dlFileEntry.getCompanyId());
12503                    dlFileEntryImpl.setUserId(dlFileEntry.getUserId());
12504                    dlFileEntryImpl.setUserName(dlFileEntry.getUserName());
12505                    dlFileEntryImpl.setCreateDate(dlFileEntry.getCreateDate());
12506                    dlFileEntryImpl.setModifiedDate(dlFileEntry.getModifiedDate());
12507                    dlFileEntryImpl.setClassNameId(dlFileEntry.getClassNameId());
12508                    dlFileEntryImpl.setClassPK(dlFileEntry.getClassPK());
12509                    dlFileEntryImpl.setRepositoryId(dlFileEntry.getRepositoryId());
12510                    dlFileEntryImpl.setFolderId(dlFileEntry.getFolderId());
12511                    dlFileEntryImpl.setTreePath(dlFileEntry.getTreePath());
12512                    dlFileEntryImpl.setName(dlFileEntry.getName());
12513                    dlFileEntryImpl.setFileName(dlFileEntry.getFileName());
12514                    dlFileEntryImpl.setExtension(dlFileEntry.getExtension());
12515                    dlFileEntryImpl.setMimeType(dlFileEntry.getMimeType());
12516                    dlFileEntryImpl.setTitle(dlFileEntry.getTitle());
12517                    dlFileEntryImpl.setDescription(dlFileEntry.getDescription());
12518                    dlFileEntryImpl.setExtraSettings(dlFileEntry.getExtraSettings());
12519                    dlFileEntryImpl.setFileEntryTypeId(dlFileEntry.getFileEntryTypeId());
12520                    dlFileEntryImpl.setVersion(dlFileEntry.getVersion());
12521                    dlFileEntryImpl.setSize(dlFileEntry.getSize());
12522                    dlFileEntryImpl.setReadCount(dlFileEntry.getReadCount());
12523                    dlFileEntryImpl.setSmallImageId(dlFileEntry.getSmallImageId());
12524                    dlFileEntryImpl.setLargeImageId(dlFileEntry.getLargeImageId());
12525                    dlFileEntryImpl.setCustom1ImageId(dlFileEntry.getCustom1ImageId());
12526                    dlFileEntryImpl.setCustom2ImageId(dlFileEntry.getCustom2ImageId());
12527                    dlFileEntryImpl.setManualCheckInRequired(dlFileEntry.isManualCheckInRequired());
12528                    dlFileEntryImpl.setLastPublishDate(dlFileEntry.getLastPublishDate());
12529    
12530                    return dlFileEntryImpl;
12531            }
12532    
12533            /**
12534             * Returns the document library file entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
12535             *
12536             * @param primaryKey the primary key of the document library file entry
12537             * @return the document library file entry
12538             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
12539             */
12540            @Override
12541            public DLFileEntry findByPrimaryKey(Serializable primaryKey)
12542                    throws NoSuchFileEntryException {
12543                    DLFileEntry dlFileEntry = fetchByPrimaryKey(primaryKey);
12544    
12545                    if (dlFileEntry == null) {
12546                            if (_log.isWarnEnabled()) {
12547                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
12548                            }
12549    
12550                            throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
12551                                    primaryKey);
12552                    }
12553    
12554                    return dlFileEntry;
12555            }
12556    
12557            /**
12558             * Returns the document library file entry with the primary key or throws a {@link NoSuchFileEntryException} if it could not be found.
12559             *
12560             * @param fileEntryId the primary key of the document library file entry
12561             * @return the document library file entry
12562             * @throws NoSuchFileEntryException if a document library file entry with the primary key could not be found
12563             */
12564            @Override
12565            public DLFileEntry findByPrimaryKey(long fileEntryId)
12566                    throws NoSuchFileEntryException {
12567                    return findByPrimaryKey((Serializable)fileEntryId);
12568            }
12569    
12570            /**
12571             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
12572             *
12573             * @param primaryKey the primary key of the document library file entry
12574             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
12575             */
12576            @Override
12577            public DLFileEntry fetchByPrimaryKey(Serializable primaryKey) {
12578                    DLFileEntry dlFileEntry = (DLFileEntry)entityCache.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12579                                    DLFileEntryImpl.class, primaryKey);
12580    
12581                    if (dlFileEntry == _nullDLFileEntry) {
12582                            return null;
12583                    }
12584    
12585                    if (dlFileEntry == null) {
12586                            Session session = null;
12587    
12588                            try {
12589                                    session = openSession();
12590    
12591                                    dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
12592                                                    primaryKey);
12593    
12594                                    if (dlFileEntry != null) {
12595                                            cacheResult(dlFileEntry);
12596                                    }
12597                                    else {
12598                                            entityCache.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12599                                                    DLFileEntryImpl.class, primaryKey, _nullDLFileEntry);
12600                                    }
12601                            }
12602                            catch (Exception e) {
12603                                    entityCache.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12604                                            DLFileEntryImpl.class, primaryKey);
12605    
12606                                    throw processException(e);
12607                            }
12608                            finally {
12609                                    closeSession(session);
12610                            }
12611                    }
12612    
12613                    return dlFileEntry;
12614            }
12615    
12616            /**
12617             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
12618             *
12619             * @param fileEntryId the primary key of the document library file entry
12620             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
12621             */
12622            @Override
12623            public DLFileEntry fetchByPrimaryKey(long fileEntryId) {
12624                    return fetchByPrimaryKey((Serializable)fileEntryId);
12625            }
12626    
12627            @Override
12628            public Map<Serializable, DLFileEntry> fetchByPrimaryKeys(
12629                    Set<Serializable> primaryKeys) {
12630                    if (primaryKeys.isEmpty()) {
12631                            return Collections.emptyMap();
12632                    }
12633    
12634                    Map<Serializable, DLFileEntry> map = new HashMap<Serializable, DLFileEntry>();
12635    
12636                    if (primaryKeys.size() == 1) {
12637                            Iterator<Serializable> iterator = primaryKeys.iterator();
12638    
12639                            Serializable primaryKey = iterator.next();
12640    
12641                            DLFileEntry dlFileEntry = fetchByPrimaryKey(primaryKey);
12642    
12643                            if (dlFileEntry != null) {
12644                                    map.put(primaryKey, dlFileEntry);
12645                            }
12646    
12647                            return map;
12648                    }
12649    
12650                    Set<Serializable> uncachedPrimaryKeys = null;
12651    
12652                    for (Serializable primaryKey : primaryKeys) {
12653                            DLFileEntry dlFileEntry = (DLFileEntry)entityCache.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12654                                            DLFileEntryImpl.class, primaryKey);
12655    
12656                            if (dlFileEntry == null) {
12657                                    if (uncachedPrimaryKeys == null) {
12658                                            uncachedPrimaryKeys = new HashSet<Serializable>();
12659                                    }
12660    
12661                                    uncachedPrimaryKeys.add(primaryKey);
12662                            }
12663                            else {
12664                                    map.put(primaryKey, dlFileEntry);
12665                            }
12666                    }
12667    
12668                    if (uncachedPrimaryKeys == null) {
12669                            return map;
12670                    }
12671    
12672                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
12673                                    1);
12674    
12675                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE_PKS_IN);
12676    
12677                    for (Serializable primaryKey : uncachedPrimaryKeys) {
12678                            query.append(String.valueOf(primaryKey));
12679    
12680                            query.append(StringPool.COMMA);
12681                    }
12682    
12683                    query.setIndex(query.index() - 1);
12684    
12685                    query.append(StringPool.CLOSE_PARENTHESIS);
12686    
12687                    String sql = query.toString();
12688    
12689                    Session session = null;
12690    
12691                    try {
12692                            session = openSession();
12693    
12694                            Query q = session.createQuery(sql);
12695    
12696                            for (DLFileEntry dlFileEntry : (List<DLFileEntry>)q.list()) {
12697                                    map.put(dlFileEntry.getPrimaryKeyObj(), dlFileEntry);
12698    
12699                                    cacheResult(dlFileEntry);
12700    
12701                                    uncachedPrimaryKeys.remove(dlFileEntry.getPrimaryKeyObj());
12702                            }
12703    
12704                            for (Serializable primaryKey : uncachedPrimaryKeys) {
12705                                    entityCache.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
12706                                            DLFileEntryImpl.class, primaryKey, _nullDLFileEntry);
12707                            }
12708                    }
12709                    catch (Exception e) {
12710                            throw processException(e);
12711                    }
12712                    finally {
12713                            closeSession(session);
12714                    }
12715    
12716                    return map;
12717            }
12718    
12719            /**
12720             * Returns all the document library file entries.
12721             *
12722             * @return the document library file entries
12723             */
12724            @Override
12725            public List<DLFileEntry> findAll() {
12726                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12727            }
12728    
12729            /**
12730             * Returns a range of all the document library file entries.
12731             *
12732             * <p>
12733             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12734             * </p>
12735             *
12736             * @param start the lower bound of the range of document library file entries
12737             * @param end the upper bound of the range of document library file entries (not inclusive)
12738             * @return the range of document library file entries
12739             */
12740            @Override
12741            public List<DLFileEntry> findAll(int start, int end) {
12742                    return findAll(start, end, null);
12743            }
12744    
12745            /**
12746             * Returns an ordered range of all the document library file entries.
12747             *
12748             * <p>
12749             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12750             * </p>
12751             *
12752             * @param start the lower bound of the range of document library file entries
12753             * @param end the upper bound of the range of document library file entries (not inclusive)
12754             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12755             * @return the ordered range of document library file entries
12756             */
12757            @Override
12758            public List<DLFileEntry> findAll(int start, int end,
12759                    OrderByComparator<DLFileEntry> orderByComparator) {
12760                    return findAll(start, end, orderByComparator, true);
12761            }
12762    
12763            /**
12764             * Returns an ordered range of all the document library file entries.
12765             *
12766             * <p>
12767             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12768             * </p>
12769             *
12770             * @param start the lower bound of the range of document library file entries
12771             * @param end the upper bound of the range of document library file entries (not inclusive)
12772             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12773             * @param retrieveFromCache whether to retrieve from the finder cache
12774             * @return the ordered range of document library file entries
12775             */
12776            @Override
12777            public List<DLFileEntry> findAll(int start, int end,
12778                    OrderByComparator<DLFileEntry> orderByComparator,
12779                    boolean retrieveFromCache) {
12780                    boolean pagination = true;
12781                    FinderPath finderPath = null;
12782                    Object[] finderArgs = null;
12783    
12784                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12785                                    (orderByComparator == null)) {
12786                            pagination = false;
12787                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
12788                            finderArgs = FINDER_ARGS_EMPTY;
12789                    }
12790                    else {
12791                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
12792                            finderArgs = new Object[] { start, end, orderByComparator };
12793                    }
12794    
12795                    List<DLFileEntry> list = null;
12796    
12797                    if (retrieveFromCache) {
12798                            list = (List<DLFileEntry>)finderCache.getResult(finderPath,
12799                                            finderArgs, this);
12800                    }
12801    
12802                    if (list == null) {
12803                            StringBundler query = null;
12804                            String sql = null;
12805    
12806                            if (orderByComparator != null) {
12807                                    query = new StringBundler(2 +
12808                                                    (orderByComparator.getOrderByFields().length * 3));
12809    
12810                                    query.append(_SQL_SELECT_DLFILEENTRY);
12811    
12812                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12813                                            orderByComparator);
12814    
12815                                    sql = query.toString();
12816                            }
12817                            else {
12818                                    sql = _SQL_SELECT_DLFILEENTRY;
12819    
12820                                    if (pagination) {
12821                                            sql = sql.concat(DLFileEntryModelImpl.ORDER_BY_JPQL);
12822                                    }
12823                            }
12824    
12825                            Session session = null;
12826    
12827                            try {
12828                                    session = openSession();
12829    
12830                                    Query q = session.createQuery(sql);
12831    
12832                                    if (!pagination) {
12833                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
12834                                                            start, end, false);
12835    
12836                                            Collections.sort(list);
12837    
12838                                            list = Collections.unmodifiableList(list);
12839                                    }
12840                                    else {
12841                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
12842                                                            start, end);
12843                                    }
12844    
12845                                    cacheResult(list);
12846    
12847                                    finderCache.putResult(finderPath, finderArgs, list);
12848                            }
12849                            catch (Exception e) {
12850                                    finderCache.removeResult(finderPath, finderArgs);
12851    
12852                                    throw processException(e);
12853                            }
12854                            finally {
12855                                    closeSession(session);
12856                            }
12857                    }
12858    
12859                    return list;
12860            }
12861    
12862            /**
12863             * Removes all the document library file entries from the database.
12864             *
12865             */
12866            @Override
12867            public void removeAll() {
12868                    for (DLFileEntry dlFileEntry : findAll()) {
12869                            remove(dlFileEntry);
12870                    }
12871            }
12872    
12873            /**
12874             * Returns the number of document library file entries.
12875             *
12876             * @return the number of document library file entries
12877             */
12878            @Override
12879            public int countAll() {
12880                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
12881                                    FINDER_ARGS_EMPTY, this);
12882    
12883                    if (count == null) {
12884                            Session session = null;
12885    
12886                            try {
12887                                    session = openSession();
12888    
12889                                    Query q = session.createQuery(_SQL_COUNT_DLFILEENTRY);
12890    
12891                                    count = (Long)q.uniqueResult();
12892    
12893                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
12894                                            count);
12895                            }
12896                            catch (Exception e) {
12897                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
12898                                            FINDER_ARGS_EMPTY);
12899    
12900                                    throw processException(e);
12901                            }
12902                            finally {
12903                                    closeSession(session);
12904                            }
12905                    }
12906    
12907                    return count.intValue();
12908            }
12909    
12910            @Override
12911            public Set<String> getBadColumnNames() {
12912                    return _badColumnNames;
12913            }
12914    
12915            @Override
12916            protected Map<String, Integer> getTableColumnsMap() {
12917                    return DLFileEntryModelImpl.TABLE_COLUMNS_MAP;
12918            }
12919    
12920            /**
12921             * Initializes the document library file entry persistence.
12922             */
12923            public void afterPropertiesSet() {
12924            }
12925    
12926            public void destroy() {
12927                    entityCache.removeCache(DLFileEntryImpl.class.getName());
12928                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
12929                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12930                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12931            }
12932    
12933            @BeanReference(type = CompanyProvider.class)
12934            protected CompanyProvider companyProvider;
12935            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
12936            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
12937            private static final String _SQL_SELECT_DLFILEENTRY = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry";
12938            private static final String _SQL_SELECT_DLFILEENTRY_WHERE_PKS_IN = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE fileEntryId IN (";
12939            private static final String _SQL_SELECT_DLFILEENTRY_WHERE = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ";
12940            private static final String _SQL_COUNT_DLFILEENTRY = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry";
12941            private static final String _SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry WHERE ";
12942            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntry.fileEntryId";
12943            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_WHERE = "SELECT DISTINCT {dlFileEntry.*} FROM DLFileEntry dlFileEntry WHERE ";
12944            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1 =
12945                    "SELECT {DLFileEntry.*} FROM (SELECT DISTINCT dlFileEntry.fileEntryId FROM DLFileEntry dlFileEntry WHERE ";
12946            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2 =
12947                    ") TEMP_TABLE INNER JOIN DLFileEntry ON TEMP_TABLE.fileEntryId = DLFileEntry.fileEntryId";
12948            private static final String _FILTER_SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(DISTINCT dlFileEntry.fileEntryId) AS COUNT_VALUE FROM DLFileEntry dlFileEntry WHERE ";
12949            private static final String _FILTER_ENTITY_ALIAS = "dlFileEntry";
12950            private static final String _FILTER_ENTITY_TABLE = "DLFileEntry";
12951            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntry.";
12952            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntry.";
12953            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntry exists with the primary key ";
12954            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntry exists with the key {";
12955            private static final Log _log = LogFactoryUtil.getLog(DLFileEntryPersistenceImpl.class);
12956            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12957                                    "uuid", "size"
12958                            });
12959            private static final DLFileEntry _nullDLFileEntry = new DLFileEntryImpl() {
12960                            @Override
12961                            public Object clone() {
12962                                    return this;
12963                            }
12964    
12965                            @Override
12966                            public CacheModel<DLFileEntry> toCacheModel() {
12967                                    return _nullDLFileEntryCacheModel;
12968                            }
12969                    };
12970    
12971            private static final CacheModel<DLFileEntry> _nullDLFileEntryCacheModel = new CacheModel<DLFileEntry>() {
12972                            @Override
12973                            public DLFileEntry toEntityModel() {
12974                                    return _nullDLFileEntry;
12975                            }
12976                    };
12977    }