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