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