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