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