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.OrderByComparator;
033    import com.liferay.portal.kernel.util.SetUtil;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
040    import com.liferay.portal.service.ServiceContext;
041    import com.liferay.portal.service.ServiceContextThreadLocal;
042    import com.liferay.portal.service.persistence.CompanyProvider;
043    import com.liferay.portal.service.persistence.CompanyProviderWrapper;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import com.liferay.portlet.documentlibrary.exception.NoSuchFileShortcutException;
047    import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
048    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutImpl;
049    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutModelImpl;
050    import com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence;
051    
052    import java.io.Serializable;
053    
054    import java.util.Collections;
055    import java.util.Date;
056    import java.util.HashMap;
057    import java.util.HashSet;
058    import java.util.Iterator;
059    import java.util.List;
060    import java.util.Map;
061    import java.util.Set;
062    
063    /**
064     * The persistence implementation for the document library file shortcut service.
065     *
066     * <p>
067     * Caching information and settings can be found in <code>portal.properties</code>
068     * </p>
069     *
070     * @author Brian Wing Shun Chan
071     * @see DLFileShortcutPersistence
072     * @see com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutUtil
073     * @generated
074     */
075    @ProviderType
076    public class DLFileShortcutPersistenceImpl extends BasePersistenceImpl<DLFileShortcut>
077            implements DLFileShortcutPersistence {
078            /*
079             * NOTE FOR DEVELOPERS:
080             *
081             * Never modify or reference this class directly. Always use {@link DLFileShortcutUtil} to access the document library file shortcut persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
082             */
083            public static final String FINDER_CLASS_NAME_ENTITY = DLFileShortcutImpl.class.getName();
084            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085                    ".List1";
086            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087                    ".List2";
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
089                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
090                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
091                            "findAll", new String[0]);
092            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
093                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
094                            DLFileShortcutImpl.class,
095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
096            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
097                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
099            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
100                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
101                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
102                            "findByUuid",
103                            new String[] {
104                                    String.class.getName(),
105                                    
106                            Integer.class.getName(), Integer.class.getName(),
107                                    OrderByComparator.class.getName()
108                            });
109            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
110                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
111                            DLFileShortcutImpl.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
113                            new String[] { String.class.getName() },
114                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK);
115            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
116                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
118                            new String[] { String.class.getName() });
119    
120            /**
121             * Returns all the document library file shortcuts where uuid = &#63;.
122             *
123             * @param uuid the uuid
124             * @return the matching document library file shortcuts
125             */
126            @Override
127            public List<DLFileShortcut> findByUuid(String uuid) {
128                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
129            }
130    
131            /**
132             * Returns a range of all the document library file shortcuts where uuid = &#63;.
133             *
134             * <p>
135             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
136             * </p>
137             *
138             * @param uuid the uuid
139             * @param start the lower bound of the range of document library file shortcuts
140             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
141             * @return the range of matching document library file shortcuts
142             */
143            @Override
144            public List<DLFileShortcut> findByUuid(String uuid, int start, int end) {
145                    return findByUuid(uuid, start, end, null);
146            }
147    
148            /**
149             * Returns an ordered range of all the document library file shortcuts where uuid = &#63;.
150             *
151             * <p>
152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
153             * </p>
154             *
155             * @param uuid the uuid
156             * @param start the lower bound of the range of document library file shortcuts
157             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
159             * @return the ordered range of matching document library file shortcuts
160             */
161            @Override
162            public List<DLFileShortcut> findByUuid(String uuid, int start, int end,
163                    OrderByComparator<DLFileShortcut> orderByComparator) {
164                    return findByUuid(uuid, start, end, orderByComparator, true);
165            }
166    
167            /**
168             * Returns an ordered range of all the document library file shortcuts where uuid = &#63;.
169             *
170             * <p>
171             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
172             * </p>
173             *
174             * @param uuid the uuid
175             * @param start the lower bound of the range of document library file shortcuts
176             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
177             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
178             * @param retrieveFromCache whether to retrieve from the finder cache
179             * @return the ordered range of matching document library file shortcuts
180             */
181            @Override
182            public List<DLFileShortcut> findByUuid(String uuid, int start, int end,
183                    OrderByComparator<DLFileShortcut> orderByComparator,
184                    boolean retrieveFromCache) {
185                    boolean pagination = true;
186                    FinderPath finderPath = null;
187                    Object[] finderArgs = null;
188    
189                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
190                                    (orderByComparator == null)) {
191                            pagination = false;
192                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
193                            finderArgs = new Object[] { uuid };
194                    }
195                    else {
196                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
197                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
198                    }
199    
200                    List<DLFileShortcut> list = null;
201    
202                    if (retrieveFromCache) {
203                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
204                                            finderArgs, this);
205    
206                            if ((list != null) && !list.isEmpty()) {
207                                    for (DLFileShortcut dlFileShortcut : list) {
208                                            if (!Validator.equals(uuid, dlFileShortcut.getUuid())) {
209                                                    list = null;
210    
211                                                    break;
212                                            }
213                                    }
214                            }
215                    }
216    
217                    if (list == null) {
218                            StringBundler query = null;
219    
220                            if (orderByComparator != null) {
221                                    query = new StringBundler(3 +
222                                                    (orderByComparator.getOrderByFields().length * 3));
223                            }
224                            else {
225                                    query = new StringBundler(3);
226                            }
227    
228                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
229    
230                            boolean bindUuid = false;
231    
232                            if (uuid == null) {
233                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
234                            }
235                            else if (uuid.equals(StringPool.BLANK)) {
236                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
237                            }
238                            else {
239                                    bindUuid = true;
240    
241                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
242                            }
243    
244                            if (orderByComparator != null) {
245                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
246                                            orderByComparator);
247                            }
248                            else
249                             if (pagination) {
250                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
251                            }
252    
253                            String sql = query.toString();
254    
255                            Session session = null;
256    
257                            try {
258                                    session = openSession();
259    
260                                    Query q = session.createQuery(sql);
261    
262                                    QueryPos qPos = QueryPos.getInstance(q);
263    
264                                    if (bindUuid) {
265                                            qPos.add(uuid);
266                                    }
267    
268                                    if (!pagination) {
269                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
270                                                            getDialect(), start, end, false);
271    
272                                            Collections.sort(list);
273    
274                                            list = Collections.unmodifiableList(list);
275                                    }
276                                    else {
277                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
278                                                            getDialect(), start, end);
279                                    }
280    
281                                    cacheResult(list);
282    
283                                    finderCache.putResult(finderPath, finderArgs, list);
284                            }
285                            catch (Exception e) {
286                                    finderCache.removeResult(finderPath, finderArgs);
287    
288                                    throw processException(e);
289                            }
290                            finally {
291                                    closeSession(session);
292                            }
293                    }
294    
295                    return list;
296            }
297    
298            /**
299             * Returns the first document library file shortcut in the ordered set where uuid = &#63;.
300             *
301             * @param uuid the uuid
302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
303             * @return the first matching document library file shortcut
304             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
305             */
306            @Override
307            public DLFileShortcut findByUuid_First(String uuid,
308                    OrderByComparator<DLFileShortcut> orderByComparator)
309                    throws NoSuchFileShortcutException {
310                    DLFileShortcut dlFileShortcut = fetchByUuid_First(uuid,
311                                    orderByComparator);
312    
313                    if (dlFileShortcut != null) {
314                            return dlFileShortcut;
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 NoSuchFileShortcutException(msg.toString());
327            }
328    
329            /**
330             * Returns the first document library file shortcut in the ordered set where uuid = &#63;.
331             *
332             * @param uuid the uuid
333             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
334             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
335             */
336            @Override
337            public DLFileShortcut fetchByUuid_First(String uuid,
338                    OrderByComparator<DLFileShortcut> orderByComparator) {
339                    List<DLFileShortcut> list = findByUuid(uuid, 0, 1, orderByComparator);
340    
341                    if (!list.isEmpty()) {
342                            return list.get(0);
343                    }
344    
345                    return null;
346            }
347    
348            /**
349             * Returns the last document library file shortcut in the ordered set where uuid = &#63;.
350             *
351             * @param uuid the uuid
352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
353             * @return the last matching document library file shortcut
354             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
355             */
356            @Override
357            public DLFileShortcut findByUuid_Last(String uuid,
358                    OrderByComparator<DLFileShortcut> orderByComparator)
359                    throws NoSuchFileShortcutException {
360                    DLFileShortcut dlFileShortcut = fetchByUuid_Last(uuid, orderByComparator);
361    
362                    if (dlFileShortcut != null) {
363                            return dlFileShortcut;
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 NoSuchFileShortcutException(msg.toString());
376            }
377    
378            /**
379             * Returns the last document library file shortcut in the ordered set where uuid = &#63;.
380             *
381             * @param uuid the uuid
382             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
383             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
384             */
385            @Override
386            public DLFileShortcut fetchByUuid_Last(String uuid,
387                    OrderByComparator<DLFileShortcut> orderByComparator) {
388                    int count = countByUuid(uuid);
389    
390                    if (count == 0) {
391                            return null;
392                    }
393    
394                    List<DLFileShortcut> list = findByUuid(uuid, count - 1, count,
395                                    orderByComparator);
396    
397                    if (!list.isEmpty()) {
398                            return list.get(0);
399                    }
400    
401                    return null;
402            }
403    
404            /**
405             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where uuid = &#63;.
406             *
407             * @param fileShortcutId the primary key of the current document library file shortcut
408             * @param uuid the uuid
409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
410             * @return the previous, current, and next document library file shortcut
411             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
412             */
413            @Override
414            public DLFileShortcut[] findByUuid_PrevAndNext(long fileShortcutId,
415                    String uuid, OrderByComparator<DLFileShortcut> orderByComparator)
416                    throws NoSuchFileShortcutException {
417                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
418    
419                    Session session = null;
420    
421                    try {
422                            session = openSession();
423    
424                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
425    
426                            array[0] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
427                                            orderByComparator, true);
428    
429                            array[1] = dlFileShortcut;
430    
431                            array[2] = getByUuid_PrevAndNext(session, dlFileShortcut, 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 DLFileShortcut getByUuid_PrevAndNext(Session session,
445                    DLFileShortcut dlFileShortcut, String uuid,
446                    OrderByComparator<DLFileShortcut> 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_DLFILESHORTCUT_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(DLFileShortcutModelImpl.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(dlFileShortcut);
547    
548                            for (Object value : values) {
549                                    qPos.add(value);
550                            }
551                    }
552    
553                    List<DLFileShortcut> list = q.list();
554    
555                    if (list.size() == 2) {
556                            return list.get(1);
557                    }
558                    else {
559                            return null;
560                    }
561            }
562    
563            /**
564             * Removes all the document library file shortcuts where uuid = &#63; from the database.
565             *
566             * @param uuid the uuid
567             */
568            @Override
569            public void removeByUuid(String uuid) {
570                    for (DLFileShortcut dlFileShortcut : findByUuid(uuid,
571                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
572                            remove(dlFileShortcut);
573                    }
574            }
575    
576            /**
577             * Returns the number of document library file shortcuts where uuid = &#63;.
578             *
579             * @param uuid the uuid
580             * @return the number of matching document library file shortcuts
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_DLFILESHORTCUT_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 = "dlFileShortcut.uuid IS NULL";
642            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileShortcut.uuid = ?";
643            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = '')";
644            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
645                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
646                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_ENTITY,
647                            "fetchByUUID_G",
648                            new String[] { String.class.getName(), Long.class.getName() },
649                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK |
650                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK);
651            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
652                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
653                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
654                            new String[] { String.class.getName(), Long.class.getName() });
655    
656            /**
657             * Returns the document library file shortcut where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchFileShortcutException} if it could not be found.
658             *
659             * @param uuid the uuid
660             * @param groupId the group ID
661             * @return the matching document library file shortcut
662             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
663             */
664            @Override
665            public DLFileShortcut findByUUID_G(String uuid, long groupId)
666                    throws NoSuchFileShortcutException {
667                    DLFileShortcut dlFileShortcut = fetchByUUID_G(uuid, groupId);
668    
669                    if (dlFileShortcut == null) {
670                            StringBundler msg = new StringBundler(6);
671    
672                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
673    
674                            msg.append("uuid=");
675                            msg.append(uuid);
676    
677                            msg.append(", groupId=");
678                            msg.append(groupId);
679    
680                            msg.append(StringPool.CLOSE_CURLY_BRACE);
681    
682                            if (_log.isWarnEnabled()) {
683                                    _log.warn(msg.toString());
684                            }
685    
686                            throw new NoSuchFileShortcutException(msg.toString());
687                    }
688    
689                    return dlFileShortcut;
690            }
691    
692            /**
693             * Returns the document library file shortcut where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
694             *
695             * @param uuid the uuid
696             * @param groupId the group ID
697             * @return the matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
698             */
699            @Override
700            public DLFileShortcut fetchByUUID_G(String uuid, long groupId) {
701                    return fetchByUUID_G(uuid, groupId, true);
702            }
703    
704            /**
705             * Returns the document library file shortcut where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
706             *
707             * @param uuid the uuid
708             * @param groupId the group ID
709             * @param retrieveFromCache whether to retrieve from the finder cache
710             * @return the matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
711             */
712            @Override
713            public DLFileShortcut fetchByUUID_G(String uuid, long groupId,
714                    boolean retrieveFromCache) {
715                    Object[] finderArgs = new Object[] { uuid, groupId };
716    
717                    Object result = null;
718    
719                    if (retrieveFromCache) {
720                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
721                                            finderArgs, this);
722                    }
723    
724                    if (result instanceof DLFileShortcut) {
725                            DLFileShortcut dlFileShortcut = (DLFileShortcut)result;
726    
727                            if (!Validator.equals(uuid, dlFileShortcut.getUuid()) ||
728                                            (groupId != dlFileShortcut.getGroupId())) {
729                                    result = null;
730                            }
731                    }
732    
733                    if (result == null) {
734                            StringBundler query = new StringBundler(4);
735    
736                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
737    
738                            boolean bindUuid = false;
739    
740                            if (uuid == null) {
741                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
742                            }
743                            else if (uuid.equals(StringPool.BLANK)) {
744                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
745                            }
746                            else {
747                                    bindUuid = true;
748    
749                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
750                            }
751    
752                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
753    
754                            String sql = query.toString();
755    
756                            Session session = null;
757    
758                            try {
759                                    session = openSession();
760    
761                                    Query q = session.createQuery(sql);
762    
763                                    QueryPos qPos = QueryPos.getInstance(q);
764    
765                                    if (bindUuid) {
766                                            qPos.add(uuid);
767                                    }
768    
769                                    qPos.add(groupId);
770    
771                                    List<DLFileShortcut> list = q.list();
772    
773                                    if (list.isEmpty()) {
774                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
775                                                    finderArgs, list);
776                                    }
777                                    else {
778                                            DLFileShortcut dlFileShortcut = list.get(0);
779    
780                                            result = dlFileShortcut;
781    
782                                            cacheResult(dlFileShortcut);
783    
784                                            if ((dlFileShortcut.getUuid() == null) ||
785                                                            !dlFileShortcut.getUuid().equals(uuid) ||
786                                                            (dlFileShortcut.getGroupId() != groupId)) {
787                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
788                                                            finderArgs, dlFileShortcut);
789                                            }
790                                    }
791                            }
792                            catch (Exception e) {
793                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
794    
795                                    throw processException(e);
796                            }
797                            finally {
798                                    closeSession(session);
799                            }
800                    }
801    
802                    if (result instanceof List<?>) {
803                            return null;
804                    }
805                    else {
806                            return (DLFileShortcut)result;
807                    }
808            }
809    
810            /**
811             * Removes the document library file shortcut where uuid = &#63; and groupId = &#63; from the database.
812             *
813             * @param uuid the uuid
814             * @param groupId the group ID
815             * @return the document library file shortcut that was removed
816             */
817            @Override
818            public DLFileShortcut removeByUUID_G(String uuid, long groupId)
819                    throws NoSuchFileShortcutException {
820                    DLFileShortcut dlFileShortcut = findByUUID_G(uuid, groupId);
821    
822                    return remove(dlFileShortcut);
823            }
824    
825            /**
826             * Returns the number of document library file shortcuts where uuid = &#63; and groupId = &#63;.
827             *
828             * @param uuid the uuid
829             * @param groupId the group ID
830             * @return the number of matching document library file shortcuts
831             */
832            @Override
833            public int countByUUID_G(String uuid, long groupId) {
834                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
835    
836                    Object[] finderArgs = new Object[] { uuid, groupId };
837    
838                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
839    
840                    if (count == null) {
841                            StringBundler query = new StringBundler(3);
842    
843                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
844    
845                            boolean bindUuid = false;
846    
847                            if (uuid == null) {
848                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
849                            }
850                            else if (uuid.equals(StringPool.BLANK)) {
851                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
852                            }
853                            else {
854                                    bindUuid = true;
855    
856                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
857                            }
858    
859                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
860    
861                            String sql = query.toString();
862    
863                            Session session = null;
864    
865                            try {
866                                    session = openSession();
867    
868                                    Query q = session.createQuery(sql);
869    
870                                    QueryPos qPos = QueryPos.getInstance(q);
871    
872                                    if (bindUuid) {
873                                            qPos.add(uuid);
874                                    }
875    
876                                    qPos.add(groupId);
877    
878                                    count = (Long)q.uniqueResult();
879    
880                                    finderCache.putResult(finderPath, finderArgs, count);
881                            }
882                            catch (Exception e) {
883                                    finderCache.removeResult(finderPath, finderArgs);
884    
885                                    throw processException(e);
886                            }
887                            finally {
888                                    closeSession(session);
889                            }
890                    }
891    
892                    return count.intValue();
893            }
894    
895            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileShortcut.uuid IS NULL AND ";
896            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileShortcut.uuid = ? AND ";
897            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = '') AND ";
898            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileShortcut.groupId = ?";
899            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
900                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
901                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
902                            "findByUuid_C",
903                            new String[] {
904                                    String.class.getName(), Long.class.getName(),
905                                    
906                            Integer.class.getName(), Integer.class.getName(),
907                                    OrderByComparator.class.getName()
908                            });
909            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
910                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
911                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
912                            DLFileShortcutImpl.class,
913                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
914                            new String[] { String.class.getName(), Long.class.getName() },
915                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK |
916                            DLFileShortcutModelImpl.COMPANYID_COLUMN_BITMASK);
917            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
918                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
919                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
920                            new String[] { String.class.getName(), Long.class.getName() });
921    
922            /**
923             * Returns all the document library file shortcuts where uuid = &#63; and companyId = &#63;.
924             *
925             * @param uuid the uuid
926             * @param companyId the company ID
927             * @return the matching document library file shortcuts
928             */
929            @Override
930            public List<DLFileShortcut> findByUuid_C(String uuid, long companyId) {
931                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
932                            QueryUtil.ALL_POS, null);
933            }
934    
935            /**
936             * Returns a range of all the document library file shortcuts where uuid = &#63; and companyId = &#63;.
937             *
938             * <p>
939             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
940             * </p>
941             *
942             * @param uuid the uuid
943             * @param companyId the company ID
944             * @param start the lower bound of the range of document library file shortcuts
945             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
946             * @return the range of matching document library file shortcuts
947             */
948            @Override
949            public List<DLFileShortcut> findByUuid_C(String uuid, long companyId,
950                    int start, int end) {
951                    return findByUuid_C(uuid, companyId, start, end, null);
952            }
953    
954            /**
955             * Returns an ordered range of all the document library file shortcuts where uuid = &#63; and companyId = &#63;.
956             *
957             * <p>
958             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
959             * </p>
960             *
961             * @param uuid the uuid
962             * @param companyId the company ID
963             * @param start the lower bound of the range of document library file shortcuts
964             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
965             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
966             * @return the ordered range of matching document library file shortcuts
967             */
968            @Override
969            public List<DLFileShortcut> findByUuid_C(String uuid, long companyId,
970                    int start, int end, OrderByComparator<DLFileShortcut> orderByComparator) {
971                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
972            }
973    
974            /**
975             * Returns an ordered range of all the document library file shortcuts where uuid = &#63; and companyId = &#63;.
976             *
977             * <p>
978             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
979             * </p>
980             *
981             * @param uuid the uuid
982             * @param companyId the company ID
983             * @param start the lower bound of the range of document library file shortcuts
984             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
985             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
986             * @param retrieveFromCache whether to retrieve from the finder cache
987             * @return the ordered range of matching document library file shortcuts
988             */
989            @Override
990            public List<DLFileShortcut> findByUuid_C(String uuid, long companyId,
991                    int start, int end,
992                    OrderByComparator<DLFileShortcut> orderByComparator,
993                    boolean retrieveFromCache) {
994                    boolean pagination = true;
995                    FinderPath finderPath = null;
996                    Object[] finderArgs = null;
997    
998                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
999                                    (orderByComparator == null)) {
1000                            pagination = false;
1001                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1002                            finderArgs = new Object[] { uuid, companyId };
1003                    }
1004                    else {
1005                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1006                            finderArgs = new Object[] {
1007                                            uuid, companyId,
1008                                            
1009                                            start, end, orderByComparator
1010                                    };
1011                    }
1012    
1013                    List<DLFileShortcut> list = null;
1014    
1015                    if (retrieveFromCache) {
1016                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
1017                                            finderArgs, this);
1018    
1019                            if ((list != null) && !list.isEmpty()) {
1020                                    for (DLFileShortcut dlFileShortcut : list) {
1021                                            if (!Validator.equals(uuid, dlFileShortcut.getUuid()) ||
1022                                                            (companyId != dlFileShortcut.getCompanyId())) {
1023                                                    list = null;
1024    
1025                                                    break;
1026                                            }
1027                                    }
1028                            }
1029                    }
1030    
1031                    if (list == null) {
1032                            StringBundler query = null;
1033    
1034                            if (orderByComparator != null) {
1035                                    query = new StringBundler(4 +
1036                                                    (orderByComparator.getOrderByFields().length * 3));
1037                            }
1038                            else {
1039                                    query = new StringBundler(4);
1040                            }
1041    
1042                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1043    
1044                            boolean bindUuid = false;
1045    
1046                            if (uuid == null) {
1047                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1048                            }
1049                            else if (uuid.equals(StringPool.BLANK)) {
1050                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1051                            }
1052                            else {
1053                                    bindUuid = true;
1054    
1055                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1056                            }
1057    
1058                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1059    
1060                            if (orderByComparator != null) {
1061                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1062                                            orderByComparator);
1063                            }
1064                            else
1065                             if (pagination) {
1066                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
1067                            }
1068    
1069                            String sql = query.toString();
1070    
1071                            Session session = null;
1072    
1073                            try {
1074                                    session = openSession();
1075    
1076                                    Query q = session.createQuery(sql);
1077    
1078                                    QueryPos qPos = QueryPos.getInstance(q);
1079    
1080                                    if (bindUuid) {
1081                                            qPos.add(uuid);
1082                                    }
1083    
1084                                    qPos.add(companyId);
1085    
1086                                    if (!pagination) {
1087                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
1088                                                            getDialect(), start, end, false);
1089    
1090                                            Collections.sort(list);
1091    
1092                                            list = Collections.unmodifiableList(list);
1093                                    }
1094                                    else {
1095                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
1096                                                            getDialect(), start, end);
1097                                    }
1098    
1099                                    cacheResult(list);
1100    
1101                                    finderCache.putResult(finderPath, finderArgs, list);
1102                            }
1103                            catch (Exception e) {
1104                                    finderCache.removeResult(finderPath, finderArgs);
1105    
1106                                    throw processException(e);
1107                            }
1108                            finally {
1109                                    closeSession(session);
1110                            }
1111                    }
1112    
1113                    return list;
1114            }
1115    
1116            /**
1117             * Returns the first document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1118             *
1119             * @param uuid the uuid
1120             * @param companyId the company ID
1121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1122             * @return the first matching document library file shortcut
1123             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
1124             */
1125            @Override
1126            public DLFileShortcut findByUuid_C_First(String uuid, long companyId,
1127                    OrderByComparator<DLFileShortcut> orderByComparator)
1128                    throws NoSuchFileShortcutException {
1129                    DLFileShortcut dlFileShortcut = fetchByUuid_C_First(uuid, companyId,
1130                                    orderByComparator);
1131    
1132                    if (dlFileShortcut != null) {
1133                            return dlFileShortcut;
1134                    }
1135    
1136                    StringBundler msg = new StringBundler(6);
1137    
1138                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1139    
1140                    msg.append("uuid=");
1141                    msg.append(uuid);
1142    
1143                    msg.append(", companyId=");
1144                    msg.append(companyId);
1145    
1146                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1147    
1148                    throw new NoSuchFileShortcutException(msg.toString());
1149            }
1150    
1151            /**
1152             * Returns the first document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1153             *
1154             * @param uuid the uuid
1155             * @param companyId the company ID
1156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1157             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1158             */
1159            @Override
1160            public DLFileShortcut fetchByUuid_C_First(String uuid, long companyId,
1161                    OrderByComparator<DLFileShortcut> orderByComparator) {
1162                    List<DLFileShortcut> list = findByUuid_C(uuid, companyId, 0, 1,
1163                                    orderByComparator);
1164    
1165                    if (!list.isEmpty()) {
1166                            return list.get(0);
1167                    }
1168    
1169                    return null;
1170            }
1171    
1172            /**
1173             * Returns the last document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1174             *
1175             * @param uuid the uuid
1176             * @param companyId the company ID
1177             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1178             * @return the last matching document library file shortcut
1179             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
1180             */
1181            @Override
1182            public DLFileShortcut findByUuid_C_Last(String uuid, long companyId,
1183                    OrderByComparator<DLFileShortcut> orderByComparator)
1184                    throws NoSuchFileShortcutException {
1185                    DLFileShortcut dlFileShortcut = fetchByUuid_C_Last(uuid, companyId,
1186                                    orderByComparator);
1187    
1188                    if (dlFileShortcut != null) {
1189                            return dlFileShortcut;
1190                    }
1191    
1192                    StringBundler msg = new StringBundler(6);
1193    
1194                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1195    
1196                    msg.append("uuid=");
1197                    msg.append(uuid);
1198    
1199                    msg.append(", companyId=");
1200                    msg.append(companyId);
1201    
1202                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1203    
1204                    throw new NoSuchFileShortcutException(msg.toString());
1205            }
1206    
1207            /**
1208             * Returns the last document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1209             *
1210             * @param uuid the uuid
1211             * @param companyId the company ID
1212             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1213             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1214             */
1215            @Override
1216            public DLFileShortcut fetchByUuid_C_Last(String uuid, long companyId,
1217                    OrderByComparator<DLFileShortcut> orderByComparator) {
1218                    int count = countByUuid_C(uuid, companyId);
1219    
1220                    if (count == 0) {
1221                            return null;
1222                    }
1223    
1224                    List<DLFileShortcut> list = findByUuid_C(uuid, companyId, count - 1,
1225                                    count, orderByComparator);
1226    
1227                    if (!list.isEmpty()) {
1228                            return list.get(0);
1229                    }
1230    
1231                    return null;
1232            }
1233    
1234            /**
1235             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1236             *
1237             * @param fileShortcutId the primary key of the current document library file shortcut
1238             * @param uuid the uuid
1239             * @param companyId the company ID
1240             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1241             * @return the previous, current, and next document library file shortcut
1242             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
1243             */
1244            @Override
1245            public DLFileShortcut[] findByUuid_C_PrevAndNext(long fileShortcutId,
1246                    String uuid, long companyId,
1247                    OrderByComparator<DLFileShortcut> orderByComparator)
1248                    throws NoSuchFileShortcutException {
1249                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1250    
1251                    Session session = null;
1252    
1253                    try {
1254                            session = openSession();
1255    
1256                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1257    
1258                            array[0] = getByUuid_C_PrevAndNext(session, dlFileShortcut, uuid,
1259                                            companyId, orderByComparator, true);
1260    
1261                            array[1] = dlFileShortcut;
1262    
1263                            array[2] = getByUuid_C_PrevAndNext(session, dlFileShortcut, uuid,
1264                                            companyId, orderByComparator, false);
1265    
1266                            return array;
1267                    }
1268                    catch (Exception e) {
1269                            throw processException(e);
1270                    }
1271                    finally {
1272                            closeSession(session);
1273                    }
1274            }
1275    
1276            protected DLFileShortcut getByUuid_C_PrevAndNext(Session session,
1277                    DLFileShortcut dlFileShortcut, String uuid, long companyId,
1278                    OrderByComparator<DLFileShortcut> orderByComparator, boolean previous) {
1279                    StringBundler query = null;
1280    
1281                    if (orderByComparator != null) {
1282                            query = new StringBundler(6 +
1283                                            (orderByComparator.getOrderByFields().length * 6));
1284                    }
1285                    else {
1286                            query = new StringBundler(3);
1287                    }
1288    
1289                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1290    
1291                    boolean bindUuid = false;
1292    
1293                    if (uuid == null) {
1294                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1295                    }
1296                    else if (uuid.equals(StringPool.BLANK)) {
1297                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1298                    }
1299                    else {
1300                            bindUuid = true;
1301    
1302                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1303                    }
1304    
1305                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1306    
1307                    if (orderByComparator != null) {
1308                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1309    
1310                            if (orderByConditionFields.length > 0) {
1311                                    query.append(WHERE_AND);
1312                            }
1313    
1314                            for (int i = 0; i < orderByConditionFields.length; i++) {
1315                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1316                                    query.append(orderByConditionFields[i]);
1317    
1318                                    if ((i + 1) < orderByConditionFields.length) {
1319                                            if (orderByComparator.isAscending() ^ previous) {
1320                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1321                                            }
1322                                            else {
1323                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1324                                            }
1325                                    }
1326                                    else {
1327                                            if (orderByComparator.isAscending() ^ previous) {
1328                                                    query.append(WHERE_GREATER_THAN);
1329                                            }
1330                                            else {
1331                                                    query.append(WHERE_LESSER_THAN);
1332                                            }
1333                                    }
1334                            }
1335    
1336                            query.append(ORDER_BY_CLAUSE);
1337    
1338                            String[] orderByFields = orderByComparator.getOrderByFields();
1339    
1340                            for (int i = 0; i < orderByFields.length; i++) {
1341                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1342                                    query.append(orderByFields[i]);
1343    
1344                                    if ((i + 1) < orderByFields.length) {
1345                                            if (orderByComparator.isAscending() ^ previous) {
1346                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1347                                            }
1348                                            else {
1349                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1350                                            }
1351                                    }
1352                                    else {
1353                                            if (orderByComparator.isAscending() ^ previous) {
1354                                                    query.append(ORDER_BY_ASC);
1355                                            }
1356                                            else {
1357                                                    query.append(ORDER_BY_DESC);
1358                                            }
1359                                    }
1360                            }
1361                    }
1362                    else {
1363                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
1364                    }
1365    
1366                    String sql = query.toString();
1367    
1368                    Query q = session.createQuery(sql);
1369    
1370                    q.setFirstResult(0);
1371                    q.setMaxResults(2);
1372    
1373                    QueryPos qPos = QueryPos.getInstance(q);
1374    
1375                    if (bindUuid) {
1376                            qPos.add(uuid);
1377                    }
1378    
1379                    qPos.add(companyId);
1380    
1381                    if (orderByComparator != null) {
1382                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1383    
1384                            for (Object value : values) {
1385                                    qPos.add(value);
1386                            }
1387                    }
1388    
1389                    List<DLFileShortcut> list = q.list();
1390    
1391                    if (list.size() == 2) {
1392                            return list.get(1);
1393                    }
1394                    else {
1395                            return null;
1396                    }
1397            }
1398    
1399            /**
1400             * Removes all the document library file shortcuts where uuid = &#63; and companyId = &#63; from the database.
1401             *
1402             * @param uuid the uuid
1403             * @param companyId the company ID
1404             */
1405            @Override
1406            public void removeByUuid_C(String uuid, long companyId) {
1407                    for (DLFileShortcut dlFileShortcut : findByUuid_C(uuid, companyId,
1408                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1409                            remove(dlFileShortcut);
1410                    }
1411            }
1412    
1413            /**
1414             * Returns the number of document library file shortcuts where uuid = &#63; and companyId = &#63;.
1415             *
1416             * @param uuid the uuid
1417             * @param companyId the company ID
1418             * @return the number of matching document library file shortcuts
1419             */
1420            @Override
1421            public int countByUuid_C(String uuid, long companyId) {
1422                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1423    
1424                    Object[] finderArgs = new Object[] { uuid, companyId };
1425    
1426                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1427    
1428                    if (count == null) {
1429                            StringBundler query = new StringBundler(3);
1430    
1431                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
1432    
1433                            boolean bindUuid = false;
1434    
1435                            if (uuid == null) {
1436                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1437                            }
1438                            else if (uuid.equals(StringPool.BLANK)) {
1439                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1440                            }
1441                            else {
1442                                    bindUuid = true;
1443    
1444                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1445                            }
1446    
1447                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1448    
1449                            String sql = query.toString();
1450    
1451                            Session session = null;
1452    
1453                            try {
1454                                    session = openSession();
1455    
1456                                    Query q = session.createQuery(sql);
1457    
1458                                    QueryPos qPos = QueryPos.getInstance(q);
1459    
1460                                    if (bindUuid) {
1461                                            qPos.add(uuid);
1462                                    }
1463    
1464                                    qPos.add(companyId);
1465    
1466                                    count = (Long)q.uniqueResult();
1467    
1468                                    finderCache.putResult(finderPath, finderArgs, count);
1469                            }
1470                            catch (Exception e) {
1471                                    finderCache.removeResult(finderPath, finderArgs);
1472    
1473                                    throw processException(e);
1474                            }
1475                            finally {
1476                                    closeSession(session);
1477                            }
1478                    }
1479    
1480                    return count.intValue();
1481            }
1482    
1483            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "dlFileShortcut.uuid IS NULL AND ";
1484            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dlFileShortcut.uuid = ? AND ";
1485            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = '') AND ";
1486            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dlFileShortcut.companyId = ?";
1487            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1488                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1489                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
1490                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1491                            "findByCompanyId",
1492                            new String[] {
1493                                    Long.class.getName(),
1494                                    
1495                            Integer.class.getName(), Integer.class.getName(),
1496                                    OrderByComparator.class.getName()
1497                            });
1498            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1499                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1500                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
1501                            DLFileShortcutImpl.class,
1502                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1503                            new String[] { Long.class.getName() },
1504                            DLFileShortcutModelImpl.COMPANYID_COLUMN_BITMASK);
1505            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1506                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
1507                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1508                            new String[] { Long.class.getName() });
1509    
1510            /**
1511             * Returns all the document library file shortcuts where companyId = &#63;.
1512             *
1513             * @param companyId the company ID
1514             * @return the matching document library file shortcuts
1515             */
1516            @Override
1517            public List<DLFileShortcut> findByCompanyId(long companyId) {
1518                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1519                            null);
1520            }
1521    
1522            /**
1523             * Returns a range of all the document library file shortcuts where companyId = &#63;.
1524             *
1525             * <p>
1526             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1527             * </p>
1528             *
1529             * @param companyId the company ID
1530             * @param start the lower bound of the range of document library file shortcuts
1531             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1532             * @return the range of matching document library file shortcuts
1533             */
1534            @Override
1535            public List<DLFileShortcut> findByCompanyId(long companyId, int start,
1536                    int end) {
1537                    return findByCompanyId(companyId, start, end, null);
1538            }
1539    
1540            /**
1541             * Returns an ordered range of all the document library file shortcuts where companyId = &#63;.
1542             *
1543             * <p>
1544             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1545             * </p>
1546             *
1547             * @param companyId the company ID
1548             * @param start the lower bound of the range of document library file shortcuts
1549             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1550             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1551             * @return the ordered range of matching document library file shortcuts
1552             */
1553            @Override
1554            public List<DLFileShortcut> findByCompanyId(long companyId, int start,
1555                    int end, OrderByComparator<DLFileShortcut> orderByComparator) {
1556                    return findByCompanyId(companyId, start, end, orderByComparator, true);
1557            }
1558    
1559            /**
1560             * Returns an ordered range of all the document library file shortcuts where companyId = &#63;.
1561             *
1562             * <p>
1563             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1564             * </p>
1565             *
1566             * @param companyId the company ID
1567             * @param start the lower bound of the range of document library file shortcuts
1568             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1569             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1570             * @param retrieveFromCache whether to retrieve from the finder cache
1571             * @return the ordered range of matching document library file shortcuts
1572             */
1573            @Override
1574            public List<DLFileShortcut> findByCompanyId(long companyId, int start,
1575                    int end, OrderByComparator<DLFileShortcut> orderByComparator,
1576                    boolean retrieveFromCache) {
1577                    boolean pagination = true;
1578                    FinderPath finderPath = null;
1579                    Object[] finderArgs = null;
1580    
1581                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1582                                    (orderByComparator == null)) {
1583                            pagination = false;
1584                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1585                            finderArgs = new Object[] { companyId };
1586                    }
1587                    else {
1588                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1589                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1590                    }
1591    
1592                    List<DLFileShortcut> list = null;
1593    
1594                    if (retrieveFromCache) {
1595                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
1596                                            finderArgs, this);
1597    
1598                            if ((list != null) && !list.isEmpty()) {
1599                                    for (DLFileShortcut dlFileShortcut : list) {
1600                                            if ((companyId != dlFileShortcut.getCompanyId())) {
1601                                                    list = null;
1602    
1603                                                    break;
1604                                            }
1605                                    }
1606                            }
1607                    }
1608    
1609                    if (list == null) {
1610                            StringBundler query = null;
1611    
1612                            if (orderByComparator != null) {
1613                                    query = new StringBundler(3 +
1614                                                    (orderByComparator.getOrderByFields().length * 3));
1615                            }
1616                            else {
1617                                    query = new StringBundler(3);
1618                            }
1619    
1620                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1621    
1622                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1623    
1624                            if (orderByComparator != null) {
1625                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1626                                            orderByComparator);
1627                            }
1628                            else
1629                             if (pagination) {
1630                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
1631                            }
1632    
1633                            String sql = query.toString();
1634    
1635                            Session session = null;
1636    
1637                            try {
1638                                    session = openSession();
1639    
1640                                    Query q = session.createQuery(sql);
1641    
1642                                    QueryPos qPos = QueryPos.getInstance(q);
1643    
1644                                    qPos.add(companyId);
1645    
1646                                    if (!pagination) {
1647                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
1648                                                            getDialect(), start, end, false);
1649    
1650                                            Collections.sort(list);
1651    
1652                                            list = Collections.unmodifiableList(list);
1653                                    }
1654                                    else {
1655                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
1656                                                            getDialect(), start, end);
1657                                    }
1658    
1659                                    cacheResult(list);
1660    
1661                                    finderCache.putResult(finderPath, finderArgs, list);
1662                            }
1663                            catch (Exception e) {
1664                                    finderCache.removeResult(finderPath, finderArgs);
1665    
1666                                    throw processException(e);
1667                            }
1668                            finally {
1669                                    closeSession(session);
1670                            }
1671                    }
1672    
1673                    return list;
1674            }
1675    
1676            /**
1677             * Returns the first document library file shortcut in the ordered set where companyId = &#63;.
1678             *
1679             * @param companyId the company ID
1680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1681             * @return the first matching document library file shortcut
1682             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
1683             */
1684            @Override
1685            public DLFileShortcut findByCompanyId_First(long companyId,
1686                    OrderByComparator<DLFileShortcut> orderByComparator)
1687                    throws NoSuchFileShortcutException {
1688                    DLFileShortcut dlFileShortcut = fetchByCompanyId_First(companyId,
1689                                    orderByComparator);
1690    
1691                    if (dlFileShortcut != null) {
1692                            return dlFileShortcut;
1693                    }
1694    
1695                    StringBundler msg = new StringBundler(4);
1696    
1697                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1698    
1699                    msg.append("companyId=");
1700                    msg.append(companyId);
1701    
1702                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1703    
1704                    throw new NoSuchFileShortcutException(msg.toString());
1705            }
1706    
1707            /**
1708             * Returns the first document library file shortcut in the ordered set where companyId = &#63;.
1709             *
1710             * @param companyId the company ID
1711             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1712             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1713             */
1714            @Override
1715            public DLFileShortcut fetchByCompanyId_First(long companyId,
1716                    OrderByComparator<DLFileShortcut> orderByComparator) {
1717                    List<DLFileShortcut> list = findByCompanyId(companyId, 0, 1,
1718                                    orderByComparator);
1719    
1720                    if (!list.isEmpty()) {
1721                            return list.get(0);
1722                    }
1723    
1724                    return null;
1725            }
1726    
1727            /**
1728             * Returns the last document library file shortcut in the ordered set where companyId = &#63;.
1729             *
1730             * @param companyId the company ID
1731             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1732             * @return the last matching document library file shortcut
1733             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
1734             */
1735            @Override
1736            public DLFileShortcut findByCompanyId_Last(long companyId,
1737                    OrderByComparator<DLFileShortcut> orderByComparator)
1738                    throws NoSuchFileShortcutException {
1739                    DLFileShortcut dlFileShortcut = fetchByCompanyId_Last(companyId,
1740                                    orderByComparator);
1741    
1742                    if (dlFileShortcut != null) {
1743                            return dlFileShortcut;
1744                    }
1745    
1746                    StringBundler msg = new StringBundler(4);
1747    
1748                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1749    
1750                    msg.append("companyId=");
1751                    msg.append(companyId);
1752    
1753                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1754    
1755                    throw new NoSuchFileShortcutException(msg.toString());
1756            }
1757    
1758            /**
1759             * Returns the last document library file shortcut in the ordered set where companyId = &#63;.
1760             *
1761             * @param companyId the company ID
1762             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1763             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1764             */
1765            @Override
1766            public DLFileShortcut fetchByCompanyId_Last(long companyId,
1767                    OrderByComparator<DLFileShortcut> orderByComparator) {
1768                    int count = countByCompanyId(companyId);
1769    
1770                    if (count == 0) {
1771                            return null;
1772                    }
1773    
1774                    List<DLFileShortcut> list = findByCompanyId(companyId, count - 1,
1775                                    count, orderByComparator);
1776    
1777                    if (!list.isEmpty()) {
1778                            return list.get(0);
1779                    }
1780    
1781                    return null;
1782            }
1783    
1784            /**
1785             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where companyId = &#63;.
1786             *
1787             * @param fileShortcutId the primary key of the current document library file shortcut
1788             * @param companyId the company ID
1789             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1790             * @return the previous, current, and next document library file shortcut
1791             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
1792             */
1793            @Override
1794            public DLFileShortcut[] findByCompanyId_PrevAndNext(long fileShortcutId,
1795                    long companyId, OrderByComparator<DLFileShortcut> orderByComparator)
1796                    throws NoSuchFileShortcutException {
1797                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1798    
1799                    Session session = null;
1800    
1801                    try {
1802                            session = openSession();
1803    
1804                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1805    
1806                            array[0] = getByCompanyId_PrevAndNext(session, dlFileShortcut,
1807                                            companyId, orderByComparator, true);
1808    
1809                            array[1] = dlFileShortcut;
1810    
1811                            array[2] = getByCompanyId_PrevAndNext(session, dlFileShortcut,
1812                                            companyId, orderByComparator, false);
1813    
1814                            return array;
1815                    }
1816                    catch (Exception e) {
1817                            throw processException(e);
1818                    }
1819                    finally {
1820                            closeSession(session);
1821                    }
1822            }
1823    
1824            protected DLFileShortcut getByCompanyId_PrevAndNext(Session session,
1825                    DLFileShortcut dlFileShortcut, long companyId,
1826                    OrderByComparator<DLFileShortcut> orderByComparator, boolean previous) {
1827                    StringBundler query = null;
1828    
1829                    if (orderByComparator != null) {
1830                            query = new StringBundler(6 +
1831                                            (orderByComparator.getOrderByFields().length * 6));
1832                    }
1833                    else {
1834                            query = new StringBundler(3);
1835                    }
1836    
1837                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1838    
1839                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1840    
1841                    if (orderByComparator != null) {
1842                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1843    
1844                            if (orderByConditionFields.length > 0) {
1845                                    query.append(WHERE_AND);
1846                            }
1847    
1848                            for (int i = 0; i < orderByConditionFields.length; i++) {
1849                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1850                                    query.append(orderByConditionFields[i]);
1851    
1852                                    if ((i + 1) < orderByConditionFields.length) {
1853                                            if (orderByComparator.isAscending() ^ previous) {
1854                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1855                                            }
1856                                            else {
1857                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1858                                            }
1859                                    }
1860                                    else {
1861                                            if (orderByComparator.isAscending() ^ previous) {
1862                                                    query.append(WHERE_GREATER_THAN);
1863                                            }
1864                                            else {
1865                                                    query.append(WHERE_LESSER_THAN);
1866                                            }
1867                                    }
1868                            }
1869    
1870                            query.append(ORDER_BY_CLAUSE);
1871    
1872                            String[] orderByFields = orderByComparator.getOrderByFields();
1873    
1874                            for (int i = 0; i < orderByFields.length; i++) {
1875                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1876                                    query.append(orderByFields[i]);
1877    
1878                                    if ((i + 1) < orderByFields.length) {
1879                                            if (orderByComparator.isAscending() ^ previous) {
1880                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1881                                            }
1882                                            else {
1883                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1884                                            }
1885                                    }
1886                                    else {
1887                                            if (orderByComparator.isAscending() ^ previous) {
1888                                                    query.append(ORDER_BY_ASC);
1889                                            }
1890                                            else {
1891                                                    query.append(ORDER_BY_DESC);
1892                                            }
1893                                    }
1894                            }
1895                    }
1896                    else {
1897                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
1898                    }
1899    
1900                    String sql = query.toString();
1901    
1902                    Query q = session.createQuery(sql);
1903    
1904                    q.setFirstResult(0);
1905                    q.setMaxResults(2);
1906    
1907                    QueryPos qPos = QueryPos.getInstance(q);
1908    
1909                    qPos.add(companyId);
1910    
1911                    if (orderByComparator != null) {
1912                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1913    
1914                            for (Object value : values) {
1915                                    qPos.add(value);
1916                            }
1917                    }
1918    
1919                    List<DLFileShortcut> list = q.list();
1920    
1921                    if (list.size() == 2) {
1922                            return list.get(1);
1923                    }
1924                    else {
1925                            return null;
1926                    }
1927            }
1928    
1929            /**
1930             * Removes all the document library file shortcuts where companyId = &#63; from the database.
1931             *
1932             * @param companyId the company ID
1933             */
1934            @Override
1935            public void removeByCompanyId(long companyId) {
1936                    for (DLFileShortcut dlFileShortcut : findByCompanyId(companyId,
1937                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1938                            remove(dlFileShortcut);
1939                    }
1940            }
1941    
1942            /**
1943             * Returns the number of document library file shortcuts where companyId = &#63;.
1944             *
1945             * @param companyId the company ID
1946             * @return the number of matching document library file shortcuts
1947             */
1948            @Override
1949            public int countByCompanyId(long companyId) {
1950                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1951    
1952                    Object[] finderArgs = new Object[] { companyId };
1953    
1954                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1955    
1956                    if (count == null) {
1957                            StringBundler query = new StringBundler(2);
1958    
1959                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
1960    
1961                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1962    
1963                            String sql = query.toString();
1964    
1965                            Session session = null;
1966    
1967                            try {
1968                                    session = openSession();
1969    
1970                                    Query q = session.createQuery(sql);
1971    
1972                                    QueryPos qPos = QueryPos.getInstance(q);
1973    
1974                                    qPos.add(companyId);
1975    
1976                                    count = (Long)q.uniqueResult();
1977    
1978                                    finderCache.putResult(finderPath, finderArgs, count);
1979                            }
1980                            catch (Exception e) {
1981                                    finderCache.removeResult(finderPath, finderArgs);
1982    
1983                                    throw processException(e);
1984                            }
1985                            finally {
1986                                    closeSession(session);
1987                            }
1988                    }
1989    
1990                    return count.intValue();
1991            }
1992    
1993            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFileShortcut.companyId = ?";
1994            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TOFILEENTRYID =
1995                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1996                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
1997                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1998                            "findByToFileEntryId",
1999                            new String[] {
2000                                    Long.class.getName(),
2001                                    
2002                            Integer.class.getName(), Integer.class.getName(),
2003                                    OrderByComparator.class.getName()
2004                            });
2005            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID =
2006                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
2007                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
2008                            DLFileShortcutImpl.class,
2009                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByToFileEntryId",
2010                            new String[] { Long.class.getName() },
2011                            DLFileShortcutModelImpl.TOFILEENTRYID_COLUMN_BITMASK);
2012            public static final FinderPath FINDER_PATH_COUNT_BY_TOFILEENTRYID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
2013                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
2014                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByToFileEntryId",
2015                            new String[] { Long.class.getName() });
2016    
2017            /**
2018             * Returns all the document library file shortcuts where toFileEntryId = &#63;.
2019             *
2020             * @param toFileEntryId the to file entry ID
2021             * @return the matching document library file shortcuts
2022             */
2023            @Override
2024            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId) {
2025                    return findByToFileEntryId(toFileEntryId, QueryUtil.ALL_POS,
2026                            QueryUtil.ALL_POS, null);
2027            }
2028    
2029            /**
2030             * Returns a range of all the document library file shortcuts where toFileEntryId = &#63;.
2031             *
2032             * <p>
2033             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2034             * </p>
2035             *
2036             * @param toFileEntryId the to file entry ID
2037             * @param start the lower bound of the range of document library file shortcuts
2038             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2039             * @return the range of matching document library file shortcuts
2040             */
2041            @Override
2042            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
2043                    int start, int end) {
2044                    return findByToFileEntryId(toFileEntryId, start, end, null);
2045            }
2046    
2047            /**
2048             * Returns an ordered range of all the document library file shortcuts where toFileEntryId = &#63;.
2049             *
2050             * <p>
2051             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2052             * </p>
2053             *
2054             * @param toFileEntryId the to file entry ID
2055             * @param start the lower bound of the range of document library file shortcuts
2056             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2057             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2058             * @return the ordered range of matching document library file shortcuts
2059             */
2060            @Override
2061            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
2062                    int start, int end, OrderByComparator<DLFileShortcut> orderByComparator) {
2063                    return findByToFileEntryId(toFileEntryId, start, end,
2064                            orderByComparator, true);
2065            }
2066    
2067            /**
2068             * Returns an ordered range of all the document library file shortcuts where toFileEntryId = &#63;.
2069             *
2070             * <p>
2071             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2072             * </p>
2073             *
2074             * @param toFileEntryId the to file entry ID
2075             * @param start the lower bound of the range of document library file shortcuts
2076             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2077             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2078             * @param retrieveFromCache whether to retrieve from the finder cache
2079             * @return the ordered range of matching document library file shortcuts
2080             */
2081            @Override
2082            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
2083                    int start, int end,
2084                    OrderByComparator<DLFileShortcut> orderByComparator,
2085                    boolean retrieveFromCache) {
2086                    boolean pagination = true;
2087                    FinderPath finderPath = null;
2088                    Object[] finderArgs = null;
2089    
2090                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2091                                    (orderByComparator == null)) {
2092                            pagination = false;
2093                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID;
2094                            finderArgs = new Object[] { toFileEntryId };
2095                    }
2096                    else {
2097                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TOFILEENTRYID;
2098                            finderArgs = new Object[] {
2099                                            toFileEntryId,
2100                                            
2101                                            start, end, orderByComparator
2102                                    };
2103                    }
2104    
2105                    List<DLFileShortcut> list = null;
2106    
2107                    if (retrieveFromCache) {
2108                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
2109                                            finderArgs, this);
2110    
2111                            if ((list != null) && !list.isEmpty()) {
2112                                    for (DLFileShortcut dlFileShortcut : list) {
2113                                            if ((toFileEntryId != dlFileShortcut.getToFileEntryId())) {
2114                                                    list = null;
2115    
2116                                                    break;
2117                                            }
2118                                    }
2119                            }
2120                    }
2121    
2122                    if (list == null) {
2123                            StringBundler query = null;
2124    
2125                            if (orderByComparator != null) {
2126                                    query = new StringBundler(3 +
2127                                                    (orderByComparator.getOrderByFields().length * 3));
2128                            }
2129                            else {
2130                                    query = new StringBundler(3);
2131                            }
2132    
2133                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2134    
2135                            query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
2136    
2137                            if (orderByComparator != null) {
2138                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2139                                            orderByComparator);
2140                            }
2141                            else
2142                             if (pagination) {
2143                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2144                            }
2145    
2146                            String sql = query.toString();
2147    
2148                            Session session = null;
2149    
2150                            try {
2151                                    session = openSession();
2152    
2153                                    Query q = session.createQuery(sql);
2154    
2155                                    QueryPos qPos = QueryPos.getInstance(q);
2156    
2157                                    qPos.add(toFileEntryId);
2158    
2159                                    if (!pagination) {
2160                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2161                                                            getDialect(), start, end, false);
2162    
2163                                            Collections.sort(list);
2164    
2165                                            list = Collections.unmodifiableList(list);
2166                                    }
2167                                    else {
2168                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2169                                                            getDialect(), start, end);
2170                                    }
2171    
2172                                    cacheResult(list);
2173    
2174                                    finderCache.putResult(finderPath, finderArgs, list);
2175                            }
2176                            catch (Exception e) {
2177                                    finderCache.removeResult(finderPath, finderArgs);
2178    
2179                                    throw processException(e);
2180                            }
2181                            finally {
2182                                    closeSession(session);
2183                            }
2184                    }
2185    
2186                    return list;
2187            }
2188    
2189            /**
2190             * Returns the first document library file shortcut in the ordered set where toFileEntryId = &#63;.
2191             *
2192             * @param toFileEntryId the to file entry ID
2193             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2194             * @return the first matching document library file shortcut
2195             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
2196             */
2197            @Override
2198            public DLFileShortcut findByToFileEntryId_First(long toFileEntryId,
2199                    OrderByComparator<DLFileShortcut> orderByComparator)
2200                    throws NoSuchFileShortcutException {
2201                    DLFileShortcut dlFileShortcut = fetchByToFileEntryId_First(toFileEntryId,
2202                                    orderByComparator);
2203    
2204                    if (dlFileShortcut != null) {
2205                            return dlFileShortcut;
2206                    }
2207    
2208                    StringBundler msg = new StringBundler(4);
2209    
2210                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2211    
2212                    msg.append("toFileEntryId=");
2213                    msg.append(toFileEntryId);
2214    
2215                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2216    
2217                    throw new NoSuchFileShortcutException(msg.toString());
2218            }
2219    
2220            /**
2221             * Returns the first document library file shortcut in the ordered set where toFileEntryId = &#63;.
2222             *
2223             * @param toFileEntryId the to file entry ID
2224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2225             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
2226             */
2227            @Override
2228            public DLFileShortcut fetchByToFileEntryId_First(long toFileEntryId,
2229                    OrderByComparator<DLFileShortcut> orderByComparator) {
2230                    List<DLFileShortcut> list = findByToFileEntryId(toFileEntryId, 0, 1,
2231                                    orderByComparator);
2232    
2233                    if (!list.isEmpty()) {
2234                            return list.get(0);
2235                    }
2236    
2237                    return null;
2238            }
2239    
2240            /**
2241             * Returns the last document library file shortcut in the ordered set where toFileEntryId = &#63;.
2242             *
2243             * @param toFileEntryId the to file entry ID
2244             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2245             * @return the last matching document library file shortcut
2246             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
2247             */
2248            @Override
2249            public DLFileShortcut findByToFileEntryId_Last(long toFileEntryId,
2250                    OrderByComparator<DLFileShortcut> orderByComparator)
2251                    throws NoSuchFileShortcutException {
2252                    DLFileShortcut dlFileShortcut = fetchByToFileEntryId_Last(toFileEntryId,
2253                                    orderByComparator);
2254    
2255                    if (dlFileShortcut != null) {
2256                            return dlFileShortcut;
2257                    }
2258    
2259                    StringBundler msg = new StringBundler(4);
2260    
2261                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2262    
2263                    msg.append("toFileEntryId=");
2264                    msg.append(toFileEntryId);
2265    
2266                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2267    
2268                    throw new NoSuchFileShortcutException(msg.toString());
2269            }
2270    
2271            /**
2272             * Returns the last document library file shortcut in the ordered set where toFileEntryId = &#63;.
2273             *
2274             * @param toFileEntryId the to file entry ID
2275             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2276             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
2277             */
2278            @Override
2279            public DLFileShortcut fetchByToFileEntryId_Last(long toFileEntryId,
2280                    OrderByComparator<DLFileShortcut> orderByComparator) {
2281                    int count = countByToFileEntryId(toFileEntryId);
2282    
2283                    if (count == 0) {
2284                            return null;
2285                    }
2286    
2287                    List<DLFileShortcut> list = findByToFileEntryId(toFileEntryId,
2288                                    count - 1, count, orderByComparator);
2289    
2290                    if (!list.isEmpty()) {
2291                            return list.get(0);
2292                    }
2293    
2294                    return null;
2295            }
2296    
2297            /**
2298             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where toFileEntryId = &#63;.
2299             *
2300             * @param fileShortcutId the primary key of the current document library file shortcut
2301             * @param toFileEntryId the to file entry ID
2302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2303             * @return the previous, current, and next document library file shortcut
2304             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2305             */
2306            @Override
2307            public DLFileShortcut[] findByToFileEntryId_PrevAndNext(
2308                    long fileShortcutId, long toFileEntryId,
2309                    OrderByComparator<DLFileShortcut> orderByComparator)
2310                    throws NoSuchFileShortcutException {
2311                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2312    
2313                    Session session = null;
2314    
2315                    try {
2316                            session = openSession();
2317    
2318                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2319    
2320                            array[0] = getByToFileEntryId_PrevAndNext(session, dlFileShortcut,
2321                                            toFileEntryId, orderByComparator, true);
2322    
2323                            array[1] = dlFileShortcut;
2324    
2325                            array[2] = getByToFileEntryId_PrevAndNext(session, dlFileShortcut,
2326                                            toFileEntryId, orderByComparator, false);
2327    
2328                            return array;
2329                    }
2330                    catch (Exception e) {
2331                            throw processException(e);
2332                    }
2333                    finally {
2334                            closeSession(session);
2335                    }
2336            }
2337    
2338            protected DLFileShortcut getByToFileEntryId_PrevAndNext(Session session,
2339                    DLFileShortcut dlFileShortcut, long toFileEntryId,
2340                    OrderByComparator<DLFileShortcut> orderByComparator, boolean previous) {
2341                    StringBundler query = null;
2342    
2343                    if (orderByComparator != null) {
2344                            query = new StringBundler(6 +
2345                                            (orderByComparator.getOrderByFields().length * 6));
2346                    }
2347                    else {
2348                            query = new StringBundler(3);
2349                    }
2350    
2351                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2352    
2353                    query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
2354    
2355                    if (orderByComparator != null) {
2356                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2357    
2358                            if (orderByConditionFields.length > 0) {
2359                                    query.append(WHERE_AND);
2360                            }
2361    
2362                            for (int i = 0; i < orderByConditionFields.length; i++) {
2363                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2364                                    query.append(orderByConditionFields[i]);
2365    
2366                                    if ((i + 1) < orderByConditionFields.length) {
2367                                            if (orderByComparator.isAscending() ^ previous) {
2368                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2369                                            }
2370                                            else {
2371                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2372                                            }
2373                                    }
2374                                    else {
2375                                            if (orderByComparator.isAscending() ^ previous) {
2376                                                    query.append(WHERE_GREATER_THAN);
2377                                            }
2378                                            else {
2379                                                    query.append(WHERE_LESSER_THAN);
2380                                            }
2381                                    }
2382                            }
2383    
2384                            query.append(ORDER_BY_CLAUSE);
2385    
2386                            String[] orderByFields = orderByComparator.getOrderByFields();
2387    
2388                            for (int i = 0; i < orderByFields.length; i++) {
2389                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2390                                    query.append(orderByFields[i]);
2391    
2392                                    if ((i + 1) < orderByFields.length) {
2393                                            if (orderByComparator.isAscending() ^ previous) {
2394                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2395                                            }
2396                                            else {
2397                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2398                                            }
2399                                    }
2400                                    else {
2401                                            if (orderByComparator.isAscending() ^ previous) {
2402                                                    query.append(ORDER_BY_ASC);
2403                                            }
2404                                            else {
2405                                                    query.append(ORDER_BY_DESC);
2406                                            }
2407                                    }
2408                            }
2409                    }
2410                    else {
2411                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2412                    }
2413    
2414                    String sql = query.toString();
2415    
2416                    Query q = session.createQuery(sql);
2417    
2418                    q.setFirstResult(0);
2419                    q.setMaxResults(2);
2420    
2421                    QueryPos qPos = QueryPos.getInstance(q);
2422    
2423                    qPos.add(toFileEntryId);
2424    
2425                    if (orderByComparator != null) {
2426                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2427    
2428                            for (Object value : values) {
2429                                    qPos.add(value);
2430                            }
2431                    }
2432    
2433                    List<DLFileShortcut> list = q.list();
2434    
2435                    if (list.size() == 2) {
2436                            return list.get(1);
2437                    }
2438                    else {
2439                            return null;
2440                    }
2441            }
2442    
2443            /**
2444             * Removes all the document library file shortcuts where toFileEntryId = &#63; from the database.
2445             *
2446             * @param toFileEntryId the to file entry ID
2447             */
2448            @Override
2449            public void removeByToFileEntryId(long toFileEntryId) {
2450                    for (DLFileShortcut dlFileShortcut : findByToFileEntryId(
2451                                    toFileEntryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2452                            remove(dlFileShortcut);
2453                    }
2454            }
2455    
2456            /**
2457             * Returns the number of document library file shortcuts where toFileEntryId = &#63;.
2458             *
2459             * @param toFileEntryId the to file entry ID
2460             * @return the number of matching document library file shortcuts
2461             */
2462            @Override
2463            public int countByToFileEntryId(long toFileEntryId) {
2464                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TOFILEENTRYID;
2465    
2466                    Object[] finderArgs = new Object[] { toFileEntryId };
2467    
2468                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2469    
2470                    if (count == null) {
2471                            StringBundler query = new StringBundler(2);
2472    
2473                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
2474    
2475                            query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
2476    
2477                            String sql = query.toString();
2478    
2479                            Session session = null;
2480    
2481                            try {
2482                                    session = openSession();
2483    
2484                                    Query q = session.createQuery(sql);
2485    
2486                                    QueryPos qPos = QueryPos.getInstance(q);
2487    
2488                                    qPos.add(toFileEntryId);
2489    
2490                                    count = (Long)q.uniqueResult();
2491    
2492                                    finderCache.putResult(finderPath, finderArgs, count);
2493                            }
2494                            catch (Exception e) {
2495                                    finderCache.removeResult(finderPath, finderArgs);
2496    
2497                                    throw processException(e);
2498                            }
2499                            finally {
2500                                    closeSession(session);
2501                            }
2502                    }
2503    
2504                    return count.intValue();
2505            }
2506    
2507            private static final String _FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2 = "dlFileShortcut.toFileEntryId = ?";
2508            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
2509                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
2510                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2511                            "findByG_F",
2512                            new String[] {
2513                                    Long.class.getName(), Long.class.getName(),
2514                                    
2515                            Integer.class.getName(), Integer.class.getName(),
2516                                    OrderByComparator.class.getName()
2517                            });
2518            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
2519                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
2520                            DLFileShortcutImpl.class,
2521                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
2522                            new String[] { Long.class.getName(), Long.class.getName() },
2523                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
2524                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK);
2525            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
2526                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
2527                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
2528                            new String[] { Long.class.getName(), Long.class.getName() });
2529    
2530            /**
2531             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
2532             *
2533             * @param groupId the group ID
2534             * @param folderId the folder ID
2535             * @return the matching document library file shortcuts
2536             */
2537            @Override
2538            public List<DLFileShortcut> findByG_F(long groupId, long folderId) {
2539                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
2540                            QueryUtil.ALL_POS, null);
2541            }
2542    
2543            /**
2544             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
2545             *
2546             * <p>
2547             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2548             * </p>
2549             *
2550             * @param groupId the group ID
2551             * @param folderId the folder ID
2552             * @param start the lower bound of the range of document library file shortcuts
2553             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2554             * @return the range of matching document library file shortcuts
2555             */
2556            @Override
2557            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
2558                    int start, int end) {
2559                    return findByG_F(groupId, folderId, start, end, null);
2560            }
2561    
2562            /**
2563             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
2564             *
2565             * <p>
2566             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2567             * </p>
2568             *
2569             * @param groupId the group ID
2570             * @param folderId the folder ID
2571             * @param start the lower bound of the range of document library file shortcuts
2572             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2573             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2574             * @return the ordered range of matching document library file shortcuts
2575             */
2576            @Override
2577            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
2578                    int start, int end, OrderByComparator<DLFileShortcut> orderByComparator) {
2579                    return findByG_F(groupId, folderId, start, end, orderByComparator, true);
2580            }
2581    
2582            /**
2583             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
2584             *
2585             * <p>
2586             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2587             * </p>
2588             *
2589             * @param groupId the group ID
2590             * @param folderId the folder ID
2591             * @param start the lower bound of the range of document library file shortcuts
2592             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2593             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2594             * @param retrieveFromCache whether to retrieve from the finder cache
2595             * @return the ordered range of matching document library file shortcuts
2596             */
2597            @Override
2598            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
2599                    int start, int end,
2600                    OrderByComparator<DLFileShortcut> orderByComparator,
2601                    boolean retrieveFromCache) {
2602                    boolean pagination = true;
2603                    FinderPath finderPath = null;
2604                    Object[] finderArgs = null;
2605    
2606                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2607                                    (orderByComparator == null)) {
2608                            pagination = false;
2609                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
2610                            finderArgs = new Object[] { groupId, folderId };
2611                    }
2612                    else {
2613                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
2614                            finderArgs = new Object[] {
2615                                            groupId, folderId,
2616                                            
2617                                            start, end, orderByComparator
2618                                    };
2619                    }
2620    
2621                    List<DLFileShortcut> list = null;
2622    
2623                    if (retrieveFromCache) {
2624                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
2625                                            finderArgs, this);
2626    
2627                            if ((list != null) && !list.isEmpty()) {
2628                                    for (DLFileShortcut dlFileShortcut : list) {
2629                                            if ((groupId != dlFileShortcut.getGroupId()) ||
2630                                                            (folderId != dlFileShortcut.getFolderId())) {
2631                                                    list = null;
2632    
2633                                                    break;
2634                                            }
2635                                    }
2636                            }
2637                    }
2638    
2639                    if (list == null) {
2640                            StringBundler query = null;
2641    
2642                            if (orderByComparator != null) {
2643                                    query = new StringBundler(4 +
2644                                                    (orderByComparator.getOrderByFields().length * 3));
2645                            }
2646                            else {
2647                                    query = new StringBundler(4);
2648                            }
2649    
2650                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2651    
2652                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2653    
2654                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2655    
2656                            if (orderByComparator != null) {
2657                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2658                                            orderByComparator);
2659                            }
2660                            else
2661                             if (pagination) {
2662                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2663                            }
2664    
2665                            String sql = query.toString();
2666    
2667                            Session session = null;
2668    
2669                            try {
2670                                    session = openSession();
2671    
2672                                    Query q = session.createQuery(sql);
2673    
2674                                    QueryPos qPos = QueryPos.getInstance(q);
2675    
2676                                    qPos.add(groupId);
2677    
2678                                    qPos.add(folderId);
2679    
2680                                    if (!pagination) {
2681                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2682                                                            getDialect(), start, end, false);
2683    
2684                                            Collections.sort(list);
2685    
2686                                            list = Collections.unmodifiableList(list);
2687                                    }
2688                                    else {
2689                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2690                                                            getDialect(), start, end);
2691                                    }
2692    
2693                                    cacheResult(list);
2694    
2695                                    finderCache.putResult(finderPath, finderArgs, list);
2696                            }
2697                            catch (Exception e) {
2698                                    finderCache.removeResult(finderPath, finderArgs);
2699    
2700                                    throw processException(e);
2701                            }
2702                            finally {
2703                                    closeSession(session);
2704                            }
2705                    }
2706    
2707                    return list;
2708            }
2709    
2710            /**
2711             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2712             *
2713             * @param groupId the group ID
2714             * @param folderId the folder ID
2715             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2716             * @return the first matching document library file shortcut
2717             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
2718             */
2719            @Override
2720            public DLFileShortcut findByG_F_First(long groupId, long folderId,
2721                    OrderByComparator<DLFileShortcut> orderByComparator)
2722                    throws NoSuchFileShortcutException {
2723                    DLFileShortcut dlFileShortcut = fetchByG_F_First(groupId, folderId,
2724                                    orderByComparator);
2725    
2726                    if (dlFileShortcut != null) {
2727                            return dlFileShortcut;
2728                    }
2729    
2730                    StringBundler msg = new StringBundler(6);
2731    
2732                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2733    
2734                    msg.append("groupId=");
2735                    msg.append(groupId);
2736    
2737                    msg.append(", folderId=");
2738                    msg.append(folderId);
2739    
2740                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2741    
2742                    throw new NoSuchFileShortcutException(msg.toString());
2743            }
2744    
2745            /**
2746             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2747             *
2748             * @param groupId the group ID
2749             * @param folderId the folder ID
2750             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2751             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
2752             */
2753            @Override
2754            public DLFileShortcut fetchByG_F_First(long groupId, long folderId,
2755                    OrderByComparator<DLFileShortcut> orderByComparator) {
2756                    List<DLFileShortcut> list = findByG_F(groupId, folderId, 0, 1,
2757                                    orderByComparator);
2758    
2759                    if (!list.isEmpty()) {
2760                            return list.get(0);
2761                    }
2762    
2763                    return null;
2764            }
2765    
2766            /**
2767             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2768             *
2769             * @param groupId the group ID
2770             * @param folderId the folder ID
2771             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2772             * @return the last matching document library file shortcut
2773             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
2774             */
2775            @Override
2776            public DLFileShortcut findByG_F_Last(long groupId, long folderId,
2777                    OrderByComparator<DLFileShortcut> orderByComparator)
2778                    throws NoSuchFileShortcutException {
2779                    DLFileShortcut dlFileShortcut = fetchByG_F_Last(groupId, folderId,
2780                                    orderByComparator);
2781    
2782                    if (dlFileShortcut != null) {
2783                            return dlFileShortcut;
2784                    }
2785    
2786                    StringBundler msg = new StringBundler(6);
2787    
2788                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2789    
2790                    msg.append("groupId=");
2791                    msg.append(groupId);
2792    
2793                    msg.append(", folderId=");
2794                    msg.append(folderId);
2795    
2796                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2797    
2798                    throw new NoSuchFileShortcutException(msg.toString());
2799            }
2800    
2801            /**
2802             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2803             *
2804             * @param groupId the group ID
2805             * @param folderId the folder ID
2806             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2807             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
2808             */
2809            @Override
2810            public DLFileShortcut fetchByG_F_Last(long groupId, long folderId,
2811                    OrderByComparator<DLFileShortcut> orderByComparator) {
2812                    int count = countByG_F(groupId, folderId);
2813    
2814                    if (count == 0) {
2815                            return null;
2816                    }
2817    
2818                    List<DLFileShortcut> list = findByG_F(groupId, folderId, count - 1,
2819                                    count, orderByComparator);
2820    
2821                    if (!list.isEmpty()) {
2822                            return list.get(0);
2823                    }
2824    
2825                    return null;
2826            }
2827    
2828            /**
2829             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2830             *
2831             * @param fileShortcutId the primary key of the current document library file shortcut
2832             * @param groupId the group ID
2833             * @param folderId the folder ID
2834             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2835             * @return the previous, current, and next document library file shortcut
2836             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2837             */
2838            @Override
2839            public DLFileShortcut[] findByG_F_PrevAndNext(long fileShortcutId,
2840                    long groupId, long folderId,
2841                    OrderByComparator<DLFileShortcut> orderByComparator)
2842                    throws NoSuchFileShortcutException {
2843                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2844    
2845                    Session session = null;
2846    
2847                    try {
2848                            session = openSession();
2849    
2850                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2851    
2852                            array[0] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
2853                                            folderId, orderByComparator, true);
2854    
2855                            array[1] = dlFileShortcut;
2856    
2857                            array[2] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
2858                                            folderId, orderByComparator, false);
2859    
2860                            return array;
2861                    }
2862                    catch (Exception e) {
2863                            throw processException(e);
2864                    }
2865                    finally {
2866                            closeSession(session);
2867                    }
2868            }
2869    
2870            protected DLFileShortcut getByG_F_PrevAndNext(Session session,
2871                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
2872                    OrderByComparator<DLFileShortcut> orderByComparator, boolean previous) {
2873                    StringBundler query = null;
2874    
2875                    if (orderByComparator != null) {
2876                            query = new StringBundler(6 +
2877                                            (orderByComparator.getOrderByFields().length * 6));
2878                    }
2879                    else {
2880                            query = new StringBundler(3);
2881                    }
2882    
2883                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2884    
2885                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2886    
2887                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2888    
2889                    if (orderByComparator != null) {
2890                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2891    
2892                            if (orderByConditionFields.length > 0) {
2893                                    query.append(WHERE_AND);
2894                            }
2895    
2896                            for (int i = 0; i < orderByConditionFields.length; i++) {
2897                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2898                                    query.append(orderByConditionFields[i]);
2899    
2900                                    if ((i + 1) < orderByConditionFields.length) {
2901                                            if (orderByComparator.isAscending() ^ previous) {
2902                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2903                                            }
2904                                            else {
2905                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2906                                            }
2907                                    }
2908                                    else {
2909                                            if (orderByComparator.isAscending() ^ previous) {
2910                                                    query.append(WHERE_GREATER_THAN);
2911                                            }
2912                                            else {
2913                                                    query.append(WHERE_LESSER_THAN);
2914                                            }
2915                                    }
2916                            }
2917    
2918                            query.append(ORDER_BY_CLAUSE);
2919    
2920                            String[] orderByFields = orderByComparator.getOrderByFields();
2921    
2922                            for (int i = 0; i < orderByFields.length; i++) {
2923                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2924                                    query.append(orderByFields[i]);
2925    
2926                                    if ((i + 1) < orderByFields.length) {
2927                                            if (orderByComparator.isAscending() ^ previous) {
2928                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2929                                            }
2930                                            else {
2931                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2932                                            }
2933                                    }
2934                                    else {
2935                                            if (orderByComparator.isAscending() ^ previous) {
2936                                                    query.append(ORDER_BY_ASC);
2937                                            }
2938                                            else {
2939                                                    query.append(ORDER_BY_DESC);
2940                                            }
2941                                    }
2942                            }
2943                    }
2944                    else {
2945                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2946                    }
2947    
2948                    String sql = query.toString();
2949    
2950                    Query q = session.createQuery(sql);
2951    
2952                    q.setFirstResult(0);
2953                    q.setMaxResults(2);
2954    
2955                    QueryPos qPos = QueryPos.getInstance(q);
2956    
2957                    qPos.add(groupId);
2958    
2959                    qPos.add(folderId);
2960    
2961                    if (orderByComparator != null) {
2962                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2963    
2964                            for (Object value : values) {
2965                                    qPos.add(value);
2966                            }
2967                    }
2968    
2969                    List<DLFileShortcut> list = q.list();
2970    
2971                    if (list.size() == 2) {
2972                            return list.get(1);
2973                    }
2974                    else {
2975                            return null;
2976                    }
2977            }
2978    
2979            /**
2980             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
2981             *
2982             * @param groupId the group ID
2983             * @param folderId the folder ID
2984             * @return the matching document library file shortcuts that the user has permission to view
2985             */
2986            @Override
2987            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId) {
2988                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
2989                            QueryUtil.ALL_POS, null);
2990            }
2991    
2992            /**
2993             * Returns a range of all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
2994             *
2995             * <p>
2996             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2997             * </p>
2998             *
2999             * @param groupId the group ID
3000             * @param folderId the folder ID
3001             * @param start the lower bound of the range of document library file shortcuts
3002             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3003             * @return the range of matching document library file shortcuts that the user has permission to view
3004             */
3005            @Override
3006            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
3007                    int start, int end) {
3008                    return filterFindByG_F(groupId, folderId, start, end, null);
3009            }
3010    
3011            /**
3012             * Returns an ordered range of all the document library file shortcuts that the user has permissions to view where groupId = &#63; and folderId = &#63;.
3013             *
3014             * <p>
3015             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3016             * </p>
3017             *
3018             * @param groupId the group ID
3019             * @param folderId the folder ID
3020             * @param start the lower bound of the range of document library file shortcuts
3021             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3022             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3023             * @return the ordered range of matching document library file shortcuts that the user has permission to view
3024             */
3025            @Override
3026            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
3027                    int start, int end, OrderByComparator<DLFileShortcut> orderByComparator) {
3028                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3029                            return findByG_F(groupId, folderId, start, end, orderByComparator);
3030                    }
3031    
3032                    StringBundler query = null;
3033    
3034                    if (orderByComparator != null) {
3035                            query = new StringBundler(4 +
3036                                            (orderByComparator.getOrderByFields().length * 3));
3037                    }
3038                    else {
3039                            query = new StringBundler(4);
3040                    }
3041    
3042                    if (getDB().isSupportsInlineDistinct()) {
3043                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
3044                    }
3045                    else {
3046                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
3047                    }
3048    
3049                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3050    
3051                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3052    
3053                    if (!getDB().isSupportsInlineDistinct()) {
3054                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
3055                    }
3056    
3057                    if (orderByComparator != null) {
3058                            if (getDB().isSupportsInlineDistinct()) {
3059                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3060                                            orderByComparator, true);
3061                            }
3062                            else {
3063                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3064                                            orderByComparator, true);
3065                            }
3066                    }
3067                    else {
3068                            if (getDB().isSupportsInlineDistinct()) {
3069                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
3070                            }
3071                            else {
3072                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
3073                            }
3074                    }
3075    
3076                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3077                                    DLFileShortcut.class.getName(),
3078                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3079    
3080                    Session session = null;
3081    
3082                    try {
3083                            session = openSession();
3084    
3085                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3086    
3087                            if (getDB().isSupportsInlineDistinct()) {
3088                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
3089                            }
3090                            else {
3091                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
3092                            }
3093    
3094                            QueryPos qPos = QueryPos.getInstance(q);
3095    
3096                            qPos.add(groupId);
3097    
3098                            qPos.add(folderId);
3099    
3100                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
3101                                    end);
3102                    }
3103                    catch (Exception e) {
3104                            throw processException(e);
3105                    }
3106                    finally {
3107                            closeSession(session);
3108                    }
3109            }
3110    
3111            /**
3112             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
3113             *
3114             * @param fileShortcutId the primary key of the current document library file shortcut
3115             * @param groupId the group ID
3116             * @param folderId the folder ID
3117             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3118             * @return the previous, current, and next document library file shortcut
3119             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
3120             */
3121            @Override
3122            public DLFileShortcut[] filterFindByG_F_PrevAndNext(long fileShortcutId,
3123                    long groupId, long folderId,
3124                    OrderByComparator<DLFileShortcut> orderByComparator)
3125                    throws NoSuchFileShortcutException {
3126                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3127                            return findByG_F_PrevAndNext(fileShortcutId, groupId, folderId,
3128                                    orderByComparator);
3129                    }
3130    
3131                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
3132    
3133                    Session session = null;
3134    
3135                    try {
3136                            session = openSession();
3137    
3138                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
3139    
3140                            array[0] = filterGetByG_F_PrevAndNext(session, dlFileShortcut,
3141                                            groupId, folderId, orderByComparator, true);
3142    
3143                            array[1] = dlFileShortcut;
3144    
3145                            array[2] = filterGetByG_F_PrevAndNext(session, dlFileShortcut,
3146                                            groupId, folderId, orderByComparator, false);
3147    
3148                            return array;
3149                    }
3150                    catch (Exception e) {
3151                            throw processException(e);
3152                    }
3153                    finally {
3154                            closeSession(session);
3155                    }
3156            }
3157    
3158            protected DLFileShortcut filterGetByG_F_PrevAndNext(Session session,
3159                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
3160                    OrderByComparator<DLFileShortcut> orderByComparator, boolean previous) {
3161                    StringBundler query = null;
3162    
3163                    if (orderByComparator != null) {
3164                            query = new StringBundler(6 +
3165                                            (orderByComparator.getOrderByFields().length * 6));
3166                    }
3167                    else {
3168                            query = new StringBundler(3);
3169                    }
3170    
3171                    if (getDB().isSupportsInlineDistinct()) {
3172                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
3173                    }
3174                    else {
3175                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
3176                    }
3177    
3178                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3179    
3180                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3181    
3182                    if (!getDB().isSupportsInlineDistinct()) {
3183                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
3184                    }
3185    
3186                    if (orderByComparator != null) {
3187                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3188    
3189                            if (orderByConditionFields.length > 0) {
3190                                    query.append(WHERE_AND);
3191                            }
3192    
3193                            for (int i = 0; i < orderByConditionFields.length; i++) {
3194                                    if (getDB().isSupportsInlineDistinct()) {
3195                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3196                                    }
3197                                    else {
3198                                            query.append(_ORDER_BY_ENTITY_TABLE);
3199                                    }
3200    
3201                                    query.append(orderByConditionFields[i]);
3202    
3203                                    if ((i + 1) < orderByConditionFields.length) {
3204                                            if (orderByComparator.isAscending() ^ previous) {
3205                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3206                                            }
3207                                            else {
3208                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3209                                            }
3210                                    }
3211                                    else {
3212                                            if (orderByComparator.isAscending() ^ previous) {
3213                                                    query.append(WHERE_GREATER_THAN);
3214                                            }
3215                                            else {
3216                                                    query.append(WHERE_LESSER_THAN);
3217                                            }
3218                                    }
3219                            }
3220    
3221                            query.append(ORDER_BY_CLAUSE);
3222    
3223                            String[] orderByFields = orderByComparator.getOrderByFields();
3224    
3225                            for (int i = 0; i < orderByFields.length; i++) {
3226                                    if (getDB().isSupportsInlineDistinct()) {
3227                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3228                                    }
3229                                    else {
3230                                            query.append(_ORDER_BY_ENTITY_TABLE);
3231                                    }
3232    
3233                                    query.append(orderByFields[i]);
3234    
3235                                    if ((i + 1) < orderByFields.length) {
3236                                            if (orderByComparator.isAscending() ^ previous) {
3237                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3238                                            }
3239                                            else {
3240                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3241                                            }
3242                                    }
3243                                    else {
3244                                            if (orderByComparator.isAscending() ^ previous) {
3245                                                    query.append(ORDER_BY_ASC);
3246                                            }
3247                                            else {
3248                                                    query.append(ORDER_BY_DESC);
3249                                            }
3250                                    }
3251                            }
3252                    }
3253                    else {
3254                            if (getDB().isSupportsInlineDistinct()) {
3255                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
3256                            }
3257                            else {
3258                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
3259                            }
3260                    }
3261    
3262                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3263                                    DLFileShortcut.class.getName(),
3264                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3265    
3266                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3267    
3268                    q.setFirstResult(0);
3269                    q.setMaxResults(2);
3270    
3271                    if (getDB().isSupportsInlineDistinct()) {
3272                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
3273                    }
3274                    else {
3275                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
3276                    }
3277    
3278                    QueryPos qPos = QueryPos.getInstance(q);
3279    
3280                    qPos.add(groupId);
3281    
3282                    qPos.add(folderId);
3283    
3284                    if (orderByComparator != null) {
3285                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
3286    
3287                            for (Object value : values) {
3288                                    qPos.add(value);
3289                            }
3290                    }
3291    
3292                    List<DLFileShortcut> list = q.list();
3293    
3294                    if (list.size() == 2) {
3295                            return list.get(1);
3296                    }
3297                    else {
3298                            return null;
3299                    }
3300            }
3301    
3302            /**
3303             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; from the database.
3304             *
3305             * @param groupId the group ID
3306             * @param folderId the folder ID
3307             */
3308            @Override
3309            public void removeByG_F(long groupId, long folderId) {
3310                    for (DLFileShortcut dlFileShortcut : findByG_F(groupId, folderId,
3311                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3312                            remove(dlFileShortcut);
3313                    }
3314            }
3315    
3316            /**
3317             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63;.
3318             *
3319             * @param groupId the group ID
3320             * @param folderId the folder ID
3321             * @return the number of matching document library file shortcuts
3322             */
3323            @Override
3324            public int countByG_F(long groupId, long folderId) {
3325                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
3326    
3327                    Object[] finderArgs = new Object[] { groupId, folderId };
3328    
3329                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3330    
3331                    if (count == null) {
3332                            StringBundler query = new StringBundler(3);
3333    
3334                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3335    
3336                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3337    
3338                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3339    
3340                            String sql = query.toString();
3341    
3342                            Session session = null;
3343    
3344                            try {
3345                                    session = openSession();
3346    
3347                                    Query q = session.createQuery(sql);
3348    
3349                                    QueryPos qPos = QueryPos.getInstance(q);
3350    
3351                                    qPos.add(groupId);
3352    
3353                                    qPos.add(folderId);
3354    
3355                                    count = (Long)q.uniqueResult();
3356    
3357                                    finderCache.putResult(finderPath, finderArgs, count);
3358                            }
3359                            catch (Exception e) {
3360                                    finderCache.removeResult(finderPath, finderArgs);
3361    
3362                                    throw processException(e);
3363                            }
3364                            finally {
3365                                    closeSession(session);
3366                            }
3367                    }
3368    
3369                    return count.intValue();
3370            }
3371    
3372            /**
3373             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
3374             *
3375             * @param groupId the group ID
3376             * @param folderId the folder ID
3377             * @return the number of matching document library file shortcuts that the user has permission to view
3378             */
3379            @Override
3380            public int filterCountByG_F(long groupId, long folderId) {
3381                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3382                            return countByG_F(groupId, folderId);
3383                    }
3384    
3385                    StringBundler query = new StringBundler(3);
3386    
3387                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3388    
3389                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3390    
3391                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3392    
3393                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3394                                    DLFileShortcut.class.getName(),
3395                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3396    
3397                    Session session = null;
3398    
3399                    try {
3400                            session = openSession();
3401    
3402                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3403    
3404                            q.addScalar(COUNT_COLUMN_NAME,
3405                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3406    
3407                            QueryPos qPos = QueryPos.getInstance(q);
3408    
3409                            qPos.add(groupId);
3410    
3411                            qPos.add(folderId);
3412    
3413                            Long count = (Long)q.uniqueResult();
3414    
3415                            return count.intValue();
3416                    }
3417                    catch (Exception e) {
3418                            throw processException(e);
3419                    }
3420                    finally {
3421                            closeSession(session);
3422                    }
3423            }
3424    
3425            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
3426            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileShortcut.folderId = ?";
3427            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
3428                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
3429                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3430                            "findByC_NotS",
3431                            new String[] {
3432                                    Long.class.getName(), Integer.class.getName(),
3433                                    
3434                            Integer.class.getName(), Integer.class.getName(),
3435                                    OrderByComparator.class.getName()
3436                            });
3437            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
3438                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
3439                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
3440                            new String[] { Long.class.getName(), Integer.class.getName() });
3441    
3442            /**
3443             * Returns all the document library file shortcuts where companyId = &#63; and status &ne; &#63;.
3444             *
3445             * @param companyId the company ID
3446             * @param status the status
3447             * @return the matching document library file shortcuts
3448             */
3449            @Override
3450            public List<DLFileShortcut> findByC_NotS(long companyId, int status) {
3451                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
3452                            QueryUtil.ALL_POS, null);
3453            }
3454    
3455            /**
3456             * Returns a range of all the document library file shortcuts where companyId = &#63; and status &ne; &#63;.
3457             *
3458             * <p>
3459             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3460             * </p>
3461             *
3462             * @param companyId the company ID
3463             * @param status the status
3464             * @param start the lower bound of the range of document library file shortcuts
3465             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3466             * @return the range of matching document library file shortcuts
3467             */
3468            @Override
3469            public List<DLFileShortcut> findByC_NotS(long companyId, int status,
3470                    int start, int end) {
3471                    return findByC_NotS(companyId, status, start, end, null);
3472            }
3473    
3474            /**
3475             * Returns an ordered range of all the document library file shortcuts where companyId = &#63; and status &ne; &#63;.
3476             *
3477             * <p>
3478             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3479             * </p>
3480             *
3481             * @param companyId the company ID
3482             * @param status the status
3483             * @param start the lower bound of the range of document library file shortcuts
3484             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3485             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3486             * @return the ordered range of matching document library file shortcuts
3487             */
3488            @Override
3489            public List<DLFileShortcut> findByC_NotS(long companyId, int status,
3490                    int start, int end, OrderByComparator<DLFileShortcut> orderByComparator) {
3491                    return findByC_NotS(companyId, status, start, end, orderByComparator,
3492                            true);
3493            }
3494    
3495            /**
3496             * Returns an ordered range of all the document library file shortcuts where companyId = &#63; and status &ne; &#63;.
3497             *
3498             * <p>
3499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3500             * </p>
3501             *
3502             * @param companyId the company ID
3503             * @param status the status
3504             * @param start the lower bound of the range of document library file shortcuts
3505             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3506             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3507             * @param retrieveFromCache whether to retrieve from the finder cache
3508             * @return the ordered range of matching document library file shortcuts
3509             */
3510            @Override
3511            public List<DLFileShortcut> findByC_NotS(long companyId, int status,
3512                    int start, int end,
3513                    OrderByComparator<DLFileShortcut> orderByComparator,
3514                    boolean retrieveFromCache) {
3515                    boolean pagination = true;
3516                    FinderPath finderPath = null;
3517                    Object[] finderArgs = null;
3518    
3519                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
3520                    finderArgs = new Object[] {
3521                                    companyId, status,
3522                                    
3523                                    start, end, orderByComparator
3524                            };
3525    
3526                    List<DLFileShortcut> list = null;
3527    
3528                    if (retrieveFromCache) {
3529                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
3530                                            finderArgs, this);
3531    
3532                            if ((list != null) && !list.isEmpty()) {
3533                                    for (DLFileShortcut dlFileShortcut : list) {
3534                                            if ((companyId != dlFileShortcut.getCompanyId()) ||
3535                                                            (status == dlFileShortcut.getStatus())) {
3536                                                    list = null;
3537    
3538                                                    break;
3539                                            }
3540                                    }
3541                            }
3542                    }
3543    
3544                    if (list == null) {
3545                            StringBundler query = null;
3546    
3547                            if (orderByComparator != null) {
3548                                    query = new StringBundler(4 +
3549                                                    (orderByComparator.getOrderByFields().length * 3));
3550                            }
3551                            else {
3552                                    query = new StringBundler(4);
3553                            }
3554    
3555                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
3556    
3557                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
3558    
3559                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
3560    
3561                            if (orderByComparator != null) {
3562                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3563                                            orderByComparator);
3564                            }
3565                            else
3566                             if (pagination) {
3567                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
3568                            }
3569    
3570                            String sql = query.toString();
3571    
3572                            Session session = null;
3573    
3574                            try {
3575                                    session = openSession();
3576    
3577                                    Query q = session.createQuery(sql);
3578    
3579                                    QueryPos qPos = QueryPos.getInstance(q);
3580    
3581                                    qPos.add(companyId);
3582    
3583                                    qPos.add(status);
3584    
3585                                    if (!pagination) {
3586                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
3587                                                            getDialect(), start, end, false);
3588    
3589                                            Collections.sort(list);
3590    
3591                                            list = Collections.unmodifiableList(list);
3592                                    }
3593                                    else {
3594                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
3595                                                            getDialect(), start, end);
3596                                    }
3597    
3598                                    cacheResult(list);
3599    
3600                                    finderCache.putResult(finderPath, finderArgs, list);
3601                            }
3602                            catch (Exception e) {
3603                                    finderCache.removeResult(finderPath, finderArgs);
3604    
3605                                    throw processException(e);
3606                            }
3607                            finally {
3608                                    closeSession(session);
3609                            }
3610                    }
3611    
3612                    return list;
3613            }
3614    
3615            /**
3616             * Returns the first document library file shortcut in the ordered set where companyId = &#63; and status &ne; &#63;.
3617             *
3618             * @param companyId the company ID
3619             * @param status the status
3620             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3621             * @return the first matching document library file shortcut
3622             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
3623             */
3624            @Override
3625            public DLFileShortcut findByC_NotS_First(long companyId, int status,
3626                    OrderByComparator<DLFileShortcut> orderByComparator)
3627                    throws NoSuchFileShortcutException {
3628                    DLFileShortcut dlFileShortcut = fetchByC_NotS_First(companyId, status,
3629                                    orderByComparator);
3630    
3631                    if (dlFileShortcut != null) {
3632                            return dlFileShortcut;
3633                    }
3634    
3635                    StringBundler msg = new StringBundler(6);
3636    
3637                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3638    
3639                    msg.append("companyId=");
3640                    msg.append(companyId);
3641    
3642                    msg.append(", status=");
3643                    msg.append(status);
3644    
3645                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3646    
3647                    throw new NoSuchFileShortcutException(msg.toString());
3648            }
3649    
3650            /**
3651             * Returns the first document library file shortcut in the ordered set where companyId = &#63; and status &ne; &#63;.
3652             *
3653             * @param companyId the company ID
3654             * @param status the status
3655             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3656             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
3657             */
3658            @Override
3659            public DLFileShortcut fetchByC_NotS_First(long companyId, int status,
3660                    OrderByComparator<DLFileShortcut> orderByComparator) {
3661                    List<DLFileShortcut> list = findByC_NotS(companyId, status, 0, 1,
3662                                    orderByComparator);
3663    
3664                    if (!list.isEmpty()) {
3665                            return list.get(0);
3666                    }
3667    
3668                    return null;
3669            }
3670    
3671            /**
3672             * Returns the last document library file shortcut in the ordered set where companyId = &#63; and status &ne; &#63;.
3673             *
3674             * @param companyId the company ID
3675             * @param status the status
3676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3677             * @return the last matching document library file shortcut
3678             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
3679             */
3680            @Override
3681            public DLFileShortcut findByC_NotS_Last(long companyId, int status,
3682                    OrderByComparator<DLFileShortcut> orderByComparator)
3683                    throws NoSuchFileShortcutException {
3684                    DLFileShortcut dlFileShortcut = fetchByC_NotS_Last(companyId, status,
3685                                    orderByComparator);
3686    
3687                    if (dlFileShortcut != null) {
3688                            return dlFileShortcut;
3689                    }
3690    
3691                    StringBundler msg = new StringBundler(6);
3692    
3693                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3694    
3695                    msg.append("companyId=");
3696                    msg.append(companyId);
3697    
3698                    msg.append(", status=");
3699                    msg.append(status);
3700    
3701                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3702    
3703                    throw new NoSuchFileShortcutException(msg.toString());
3704            }
3705    
3706            /**
3707             * Returns the last document library file shortcut in the ordered set where companyId = &#63; and status &ne; &#63;.
3708             *
3709             * @param companyId the company ID
3710             * @param status the status
3711             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3712             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
3713             */
3714            @Override
3715            public DLFileShortcut fetchByC_NotS_Last(long companyId, int status,
3716                    OrderByComparator<DLFileShortcut> orderByComparator) {
3717                    int count = countByC_NotS(companyId, status);
3718    
3719                    if (count == 0) {
3720                            return null;
3721                    }
3722    
3723                    List<DLFileShortcut> list = findByC_NotS(companyId, status, count - 1,
3724                                    count, orderByComparator);
3725    
3726                    if (!list.isEmpty()) {
3727                            return list.get(0);
3728                    }
3729    
3730                    return null;
3731            }
3732    
3733            /**
3734             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where companyId = &#63; and status &ne; &#63;.
3735             *
3736             * @param fileShortcutId the primary key of the current document library file shortcut
3737             * @param companyId the company ID
3738             * @param status the status
3739             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3740             * @return the previous, current, and next document library file shortcut
3741             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
3742             */
3743            @Override
3744            public DLFileShortcut[] findByC_NotS_PrevAndNext(long fileShortcutId,
3745                    long companyId, int status,
3746                    OrderByComparator<DLFileShortcut> orderByComparator)
3747                    throws NoSuchFileShortcutException {
3748                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
3749    
3750                    Session session = null;
3751    
3752                    try {
3753                            session = openSession();
3754    
3755                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
3756    
3757                            array[0] = getByC_NotS_PrevAndNext(session, dlFileShortcut,
3758                                            companyId, status, orderByComparator, true);
3759    
3760                            array[1] = dlFileShortcut;
3761    
3762                            array[2] = getByC_NotS_PrevAndNext(session, dlFileShortcut,
3763                                            companyId, status, orderByComparator, false);
3764    
3765                            return array;
3766                    }
3767                    catch (Exception e) {
3768                            throw processException(e);
3769                    }
3770                    finally {
3771                            closeSession(session);
3772                    }
3773            }
3774    
3775            protected DLFileShortcut getByC_NotS_PrevAndNext(Session session,
3776                    DLFileShortcut dlFileShortcut, long companyId, int status,
3777                    OrderByComparator<DLFileShortcut> orderByComparator, boolean previous) {
3778                    StringBundler query = null;
3779    
3780                    if (orderByComparator != null) {
3781                            query = new StringBundler(6 +
3782                                            (orderByComparator.getOrderByFields().length * 6));
3783                    }
3784                    else {
3785                            query = new StringBundler(3);
3786                    }
3787    
3788                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
3789    
3790                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
3791    
3792                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
3793    
3794                    if (orderByComparator != null) {
3795                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3796    
3797                            if (orderByConditionFields.length > 0) {
3798                                    query.append(WHERE_AND);
3799                            }
3800    
3801                            for (int i = 0; i < orderByConditionFields.length; i++) {
3802                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3803                                    query.append(orderByConditionFields[i]);
3804    
3805                                    if ((i + 1) < orderByConditionFields.length) {
3806                                            if (orderByComparator.isAscending() ^ previous) {
3807                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3808                                            }
3809                                            else {
3810                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3811                                            }
3812                                    }
3813                                    else {
3814                                            if (orderByComparator.isAscending() ^ previous) {
3815                                                    query.append(WHERE_GREATER_THAN);
3816                                            }
3817                                            else {
3818                                                    query.append(WHERE_LESSER_THAN);
3819                                            }
3820                                    }
3821                            }
3822    
3823                            query.append(ORDER_BY_CLAUSE);
3824    
3825                            String[] orderByFields = orderByComparator.getOrderByFields();
3826    
3827                            for (int i = 0; i < orderByFields.length; i++) {
3828                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3829                                    query.append(orderByFields[i]);
3830    
3831                                    if ((i + 1) < orderByFields.length) {
3832                                            if (orderByComparator.isAscending() ^ previous) {
3833                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3834                                            }
3835                                            else {
3836                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3837                                            }
3838                                    }
3839                                    else {
3840                                            if (orderByComparator.isAscending() ^ previous) {
3841                                                    query.append(ORDER_BY_ASC);
3842                                            }
3843                                            else {
3844                                                    query.append(ORDER_BY_DESC);
3845                                            }
3846                                    }
3847                            }
3848                    }
3849                    else {
3850                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
3851                    }
3852    
3853                    String sql = query.toString();
3854    
3855                    Query q = session.createQuery(sql);
3856    
3857                    q.setFirstResult(0);
3858                    q.setMaxResults(2);
3859    
3860                    QueryPos qPos = QueryPos.getInstance(q);
3861    
3862                    qPos.add(companyId);
3863    
3864                    qPos.add(status);
3865    
3866                    if (orderByComparator != null) {
3867                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
3868    
3869                            for (Object value : values) {
3870                                    qPos.add(value);
3871                            }
3872                    }
3873    
3874                    List<DLFileShortcut> list = q.list();
3875    
3876                    if (list.size() == 2) {
3877                            return list.get(1);
3878                    }
3879                    else {
3880                            return null;
3881                    }
3882            }
3883    
3884            /**
3885             * Removes all the document library file shortcuts where companyId = &#63; and status &ne; &#63; from the database.
3886             *
3887             * @param companyId the company ID
3888             * @param status the status
3889             */
3890            @Override
3891            public void removeByC_NotS(long companyId, int status) {
3892                    for (DLFileShortcut dlFileShortcut : findByC_NotS(companyId, status,
3893                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3894                            remove(dlFileShortcut);
3895                    }
3896            }
3897    
3898            /**
3899             * Returns the number of document library file shortcuts where companyId = &#63; and status &ne; &#63;.
3900             *
3901             * @param companyId the company ID
3902             * @param status the status
3903             * @return the number of matching document library file shortcuts
3904             */
3905            @Override
3906            public int countByC_NotS(long companyId, int status) {
3907                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
3908    
3909                    Object[] finderArgs = new Object[] { companyId, status };
3910    
3911                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3912    
3913                    if (count == null) {
3914                            StringBundler query = new StringBundler(3);
3915    
3916                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3917    
3918                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
3919    
3920                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
3921    
3922                            String sql = query.toString();
3923    
3924                            Session session = null;
3925    
3926                            try {
3927                                    session = openSession();
3928    
3929                                    Query q = session.createQuery(sql);
3930    
3931                                    QueryPos qPos = QueryPos.getInstance(q);
3932    
3933                                    qPos.add(companyId);
3934    
3935                                    qPos.add(status);
3936    
3937                                    count = (Long)q.uniqueResult();
3938    
3939                                    finderCache.putResult(finderPath, finderArgs, count);
3940                            }
3941                            catch (Exception e) {
3942                                    finderCache.removeResult(finderPath, finderArgs);
3943    
3944                                    throw processException(e);
3945                            }
3946                            finally {
3947                                    closeSession(session);
3948                            }
3949                    }
3950    
3951                    return count.intValue();
3952            }
3953    
3954            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "dlFileShortcut.companyId = ? AND ";
3955            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "dlFileShortcut.status != ?";
3956            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_A = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
3957                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
3958                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3959                            "findByG_F_A",
3960                            new String[] {
3961                                    Long.class.getName(), Long.class.getName(),
3962                                    Boolean.class.getName(),
3963                                    
3964                            Integer.class.getName(), Integer.class.getName(),
3965                                    OrderByComparator.class.getName()
3966                            });
3967            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
3968                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
3969                            DLFileShortcutImpl.class,
3970                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_A",
3971                            new String[] {
3972                                    Long.class.getName(), Long.class.getName(),
3973                                    Boolean.class.getName()
3974                            },
3975                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
3976                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK |
3977                            DLFileShortcutModelImpl.ACTIVE_COLUMN_BITMASK);
3978            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_A = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
3979                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
3980                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_A",
3981                            new String[] {
3982                                    Long.class.getName(), Long.class.getName(),
3983                                    Boolean.class.getName()
3984                            });
3985    
3986            /**
3987             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
3988             *
3989             * @param groupId the group ID
3990             * @param folderId the folder ID
3991             * @param active the active
3992             * @return the matching document library file shortcuts
3993             */
3994            @Override
3995            public List<DLFileShortcut> findByG_F_A(long groupId, long folderId,
3996                    boolean active) {
3997                    return findByG_F_A(groupId, folderId, active, QueryUtil.ALL_POS,
3998                            QueryUtil.ALL_POS, null);
3999            }
4000    
4001            /**
4002             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
4003             *
4004             * <p>
4005             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4006             * </p>
4007             *
4008             * @param groupId the group ID
4009             * @param folderId the folder ID
4010             * @param active the active
4011             * @param start the lower bound of the range of document library file shortcuts
4012             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
4013             * @return the range of matching document library file shortcuts
4014             */
4015            @Override
4016            public List<DLFileShortcut> findByG_F_A(long groupId, long folderId,
4017                    boolean active, int start, int end) {
4018                    return findByG_F_A(groupId, folderId, active, start, end, null);
4019            }
4020    
4021            /**
4022             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
4023             *
4024             * <p>
4025             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4026             * </p>
4027             *
4028             * @param groupId the group ID
4029             * @param folderId the folder ID
4030             * @param active the active
4031             * @param start the lower bound of the range of document library file shortcuts
4032             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
4033             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4034             * @return the ordered range of matching document library file shortcuts
4035             */
4036            @Override
4037            public List<DLFileShortcut> findByG_F_A(long groupId, long folderId,
4038                    boolean active, int start, int end,
4039                    OrderByComparator<DLFileShortcut> orderByComparator) {
4040                    return findByG_F_A(groupId, folderId, active, start, end,
4041                            orderByComparator, true);
4042            }
4043    
4044            /**
4045             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
4046             *
4047             * <p>
4048             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4049             * </p>
4050             *
4051             * @param groupId the group ID
4052             * @param folderId the folder ID
4053             * @param active the active
4054             * @param start the lower bound of the range of document library file shortcuts
4055             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
4056             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4057             * @param retrieveFromCache whether to retrieve from the finder cache
4058             * @return the ordered range of matching document library file shortcuts
4059             */
4060            @Override
4061            public List<DLFileShortcut> findByG_F_A(long groupId, long folderId,
4062                    boolean active, int start, int end,
4063                    OrderByComparator<DLFileShortcut> orderByComparator,
4064                    boolean retrieveFromCache) {
4065                    boolean pagination = true;
4066                    FinderPath finderPath = null;
4067                    Object[] finderArgs = null;
4068    
4069                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4070                                    (orderByComparator == null)) {
4071                            pagination = false;
4072                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A;
4073                            finderArgs = new Object[] { groupId, folderId, active };
4074                    }
4075                    else {
4076                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_A;
4077                            finderArgs = new Object[] {
4078                                            groupId, folderId, active,
4079                                            
4080                                            start, end, orderByComparator
4081                                    };
4082                    }
4083    
4084                    List<DLFileShortcut> list = null;
4085    
4086                    if (retrieveFromCache) {
4087                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
4088                                            finderArgs, this);
4089    
4090                            if ((list != null) && !list.isEmpty()) {
4091                                    for (DLFileShortcut dlFileShortcut : list) {
4092                                            if ((groupId != dlFileShortcut.getGroupId()) ||
4093                                                            (folderId != dlFileShortcut.getFolderId()) ||
4094                                                            (active != dlFileShortcut.getActive())) {
4095                                                    list = null;
4096    
4097                                                    break;
4098                                            }
4099                                    }
4100                            }
4101                    }
4102    
4103                    if (list == null) {
4104                            StringBundler query = null;
4105    
4106                            if (orderByComparator != null) {
4107                                    query = new StringBundler(5 +
4108                                                    (orderByComparator.getOrderByFields().length * 3));
4109                            }
4110                            else {
4111                                    query = new StringBundler(5);
4112                            }
4113    
4114                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
4115    
4116                            query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
4117    
4118                            query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
4119    
4120                            query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2);
4121    
4122                            if (orderByComparator != null) {
4123                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4124                                            orderByComparator);
4125                            }
4126                            else
4127                             if (pagination) {
4128                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
4129                            }
4130    
4131                            String sql = query.toString();
4132    
4133                            Session session = null;
4134    
4135                            try {
4136                                    session = openSession();
4137    
4138                                    Query q = session.createQuery(sql);
4139    
4140                                    QueryPos qPos = QueryPos.getInstance(q);
4141    
4142                                    qPos.add(groupId);
4143    
4144                                    qPos.add(folderId);
4145    
4146                                    qPos.add(active);
4147    
4148                                    if (!pagination) {
4149                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
4150                                                            getDialect(), start, end, false);
4151    
4152                                            Collections.sort(list);
4153    
4154                                            list = Collections.unmodifiableList(list);
4155                                    }
4156                                    else {
4157                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
4158                                                            getDialect(), start, end);
4159                                    }
4160    
4161                                    cacheResult(list);
4162    
4163                                    finderCache.putResult(finderPath, finderArgs, list);
4164                            }
4165                            catch (Exception e) {
4166                                    finderCache.removeResult(finderPath, finderArgs);
4167    
4168                                    throw processException(e);
4169                            }
4170                            finally {
4171                                    closeSession(session);
4172                            }
4173                    }
4174    
4175                    return list;
4176            }
4177    
4178            /**
4179             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
4180             *
4181             * @param groupId the group ID
4182             * @param folderId the folder ID
4183             * @param active the active
4184             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4185             * @return the first matching document library file shortcut
4186             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
4187             */
4188            @Override
4189            public DLFileShortcut findByG_F_A_First(long groupId, long folderId,
4190                    boolean active, OrderByComparator<DLFileShortcut> orderByComparator)
4191                    throws NoSuchFileShortcutException {
4192                    DLFileShortcut dlFileShortcut = fetchByG_F_A_First(groupId, folderId,
4193                                    active, orderByComparator);
4194    
4195                    if (dlFileShortcut != null) {
4196                            return dlFileShortcut;
4197                    }
4198    
4199                    StringBundler msg = new StringBundler(8);
4200    
4201                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4202    
4203                    msg.append("groupId=");
4204                    msg.append(groupId);
4205    
4206                    msg.append(", folderId=");
4207                    msg.append(folderId);
4208    
4209                    msg.append(", active=");
4210                    msg.append(active);
4211    
4212                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4213    
4214                    throw new NoSuchFileShortcutException(msg.toString());
4215            }
4216    
4217            /**
4218             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
4219             *
4220             * @param groupId the group ID
4221             * @param folderId the folder ID
4222             * @param active the active
4223             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4224             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
4225             */
4226            @Override
4227            public DLFileShortcut fetchByG_F_A_First(long groupId, long folderId,
4228                    boolean active, OrderByComparator<DLFileShortcut> orderByComparator) {
4229                    List<DLFileShortcut> list = findByG_F_A(groupId, folderId, active, 0,
4230                                    1, orderByComparator);
4231    
4232                    if (!list.isEmpty()) {
4233                            return list.get(0);
4234                    }
4235    
4236                    return null;
4237            }
4238    
4239            /**
4240             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
4241             *
4242             * @param groupId the group ID
4243             * @param folderId the folder ID
4244             * @param active the active
4245             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4246             * @return the last matching document library file shortcut
4247             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
4248             */
4249            @Override
4250            public DLFileShortcut findByG_F_A_Last(long groupId, long folderId,
4251                    boolean active, OrderByComparator<DLFileShortcut> orderByComparator)
4252                    throws NoSuchFileShortcutException {
4253                    DLFileShortcut dlFileShortcut = fetchByG_F_A_Last(groupId, folderId,
4254                                    active, orderByComparator);
4255    
4256                    if (dlFileShortcut != null) {
4257                            return dlFileShortcut;
4258                    }
4259    
4260                    StringBundler msg = new StringBundler(8);
4261    
4262                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4263    
4264                    msg.append("groupId=");
4265                    msg.append(groupId);
4266    
4267                    msg.append(", folderId=");
4268                    msg.append(folderId);
4269    
4270                    msg.append(", active=");
4271                    msg.append(active);
4272    
4273                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4274    
4275                    throw new NoSuchFileShortcutException(msg.toString());
4276            }
4277    
4278            /**
4279             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
4280             *
4281             * @param groupId the group ID
4282             * @param folderId the folder ID
4283             * @param active the active
4284             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4285             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
4286             */
4287            @Override
4288            public DLFileShortcut fetchByG_F_A_Last(long groupId, long folderId,
4289                    boolean active, OrderByComparator<DLFileShortcut> orderByComparator) {
4290                    int count = countByG_F_A(groupId, folderId, active);
4291    
4292                    if (count == 0) {
4293                            return null;
4294                    }
4295    
4296                    List<DLFileShortcut> list = findByG_F_A(groupId, folderId, active,
4297                                    count - 1, count, orderByComparator);
4298    
4299                    if (!list.isEmpty()) {
4300                            return list.get(0);
4301                    }
4302    
4303                    return null;
4304            }
4305    
4306            /**
4307             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
4308             *
4309             * @param fileShortcutId the primary key of the current document library file shortcut
4310             * @param groupId the group ID
4311             * @param folderId the folder ID
4312             * @param active the active
4313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4314             * @return the previous, current, and next document library file shortcut
4315             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
4316             */
4317            @Override
4318            public DLFileShortcut[] findByG_F_A_PrevAndNext(long fileShortcutId,
4319                    long groupId, long folderId, boolean active,
4320                    OrderByComparator<DLFileShortcut> orderByComparator)
4321                    throws NoSuchFileShortcutException {
4322                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
4323    
4324                    Session session = null;
4325    
4326                    try {
4327                            session = openSession();
4328    
4329                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
4330    
4331                            array[0] = getByG_F_A_PrevAndNext(session, dlFileShortcut, groupId,
4332                                            folderId, active, orderByComparator, true);
4333    
4334                            array[1] = dlFileShortcut;
4335    
4336                            array[2] = getByG_F_A_PrevAndNext(session, dlFileShortcut, groupId,
4337                                            folderId, active, orderByComparator, false);
4338    
4339                            return array;
4340                    }
4341                    catch (Exception e) {
4342                            throw processException(e);
4343                    }
4344                    finally {
4345                            closeSession(session);
4346                    }
4347            }
4348    
4349            protected DLFileShortcut getByG_F_A_PrevAndNext(Session session,
4350                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
4351                    boolean active, OrderByComparator<DLFileShortcut> orderByComparator,
4352                    boolean previous) {
4353                    StringBundler query = null;
4354    
4355                    if (orderByComparator != null) {
4356                            query = new StringBundler(6 +
4357                                            (orderByComparator.getOrderByFields().length * 6));
4358                    }
4359                    else {
4360                            query = new StringBundler(3);
4361                    }
4362    
4363                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
4364    
4365                    query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
4366    
4367                    query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
4368    
4369                    query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2);
4370    
4371                    if (orderByComparator != null) {
4372                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4373    
4374                            if (orderByConditionFields.length > 0) {
4375                                    query.append(WHERE_AND);
4376                            }
4377    
4378                            for (int i = 0; i < orderByConditionFields.length; i++) {
4379                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4380                                    query.append(orderByConditionFields[i]);
4381    
4382                                    if ((i + 1) < orderByConditionFields.length) {
4383                                            if (orderByComparator.isAscending() ^ previous) {
4384                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4385                                            }
4386                                            else {
4387                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4388                                            }
4389                                    }
4390                                    else {
4391                                            if (orderByComparator.isAscending() ^ previous) {
4392                                                    query.append(WHERE_GREATER_THAN);
4393                                            }
4394                                            else {
4395                                                    query.append(WHERE_LESSER_THAN);
4396                                            }
4397                                    }
4398                            }
4399    
4400                            query.append(ORDER_BY_CLAUSE);
4401    
4402                            String[] orderByFields = orderByComparator.getOrderByFields();
4403    
4404                            for (int i = 0; i < orderByFields.length; i++) {
4405                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4406                                    query.append(orderByFields[i]);
4407    
4408                                    if ((i + 1) < orderByFields.length) {
4409                                            if (orderByComparator.isAscending() ^ previous) {
4410                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4411                                            }
4412                                            else {
4413                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4414                                            }
4415                                    }
4416                                    else {
4417                                            if (orderByComparator.isAscending() ^ previous) {
4418                                                    query.append(ORDER_BY_ASC);
4419                                            }
4420                                            else {
4421                                                    query.append(ORDER_BY_DESC);
4422                                            }
4423                                    }
4424                            }
4425                    }
4426                    else {
4427                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
4428                    }
4429    
4430                    String sql = query.toString();
4431    
4432                    Query q = session.createQuery(sql);
4433    
4434                    q.setFirstResult(0);
4435                    q.setMaxResults(2);
4436    
4437                    QueryPos qPos = QueryPos.getInstance(q);
4438    
4439                    qPos.add(groupId);
4440    
4441                    qPos.add(folderId);
4442    
4443                    qPos.add(active);
4444    
4445                    if (orderByComparator != null) {
4446                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
4447    
4448                            for (Object value : values) {
4449                                    qPos.add(value);
4450                            }
4451                    }
4452    
4453                    List<DLFileShortcut> list = q.list();
4454    
4455                    if (list.size() == 2) {
4456                            return list.get(1);
4457                    }
4458                    else {
4459                            return null;
4460                    }
4461            }
4462    
4463            /**
4464             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63;.
4465             *
4466             * @param groupId the group ID
4467             * @param folderId the folder ID
4468             * @param active the active
4469             * @return the matching document library file shortcuts that the user has permission to view
4470             */
4471            @Override
4472            public List<DLFileShortcut> filterFindByG_F_A(long groupId, long folderId,
4473                    boolean active) {
4474                    return filterFindByG_F_A(groupId, folderId, active, QueryUtil.ALL_POS,
4475                            QueryUtil.ALL_POS, null);
4476            }
4477    
4478            /**
4479             * Returns a range of all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63;.
4480             *
4481             * <p>
4482             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4483             * </p>
4484             *
4485             * @param groupId the group ID
4486             * @param folderId the folder ID
4487             * @param active the active
4488             * @param start the lower bound of the range of document library file shortcuts
4489             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
4490             * @return the range of matching document library file shortcuts that the user has permission to view
4491             */
4492            @Override
4493            public List<DLFileShortcut> filterFindByG_F_A(long groupId, long folderId,
4494                    boolean active, int start, int end) {
4495                    return filterFindByG_F_A(groupId, folderId, active, start, end, null);
4496            }
4497    
4498            /**
4499             * Returns an ordered range of all the document library file shortcuts that the user has permissions to view where groupId = &#63; and folderId = &#63; and active = &#63;.
4500             *
4501             * <p>
4502             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4503             * </p>
4504             *
4505             * @param groupId the group ID
4506             * @param folderId the folder ID
4507             * @param active the active
4508             * @param start the lower bound of the range of document library file shortcuts
4509             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
4510             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4511             * @return the ordered range of matching document library file shortcuts that the user has permission to view
4512             */
4513            @Override
4514            public List<DLFileShortcut> filterFindByG_F_A(long groupId, long folderId,
4515                    boolean active, int start, int end,
4516                    OrderByComparator<DLFileShortcut> orderByComparator) {
4517                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4518                            return findByG_F_A(groupId, folderId, active, start, end,
4519                                    orderByComparator);
4520                    }
4521    
4522                    StringBundler query = null;
4523    
4524                    if (orderByComparator != null) {
4525                            query = new StringBundler(5 +
4526                                            (orderByComparator.getOrderByFields().length * 3));
4527                    }
4528                    else {
4529                            query = new StringBundler(5);
4530                    }
4531    
4532                    if (getDB().isSupportsInlineDistinct()) {
4533                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
4534                    }
4535                    else {
4536                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
4537                    }
4538    
4539                    query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
4540    
4541                    query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
4542    
4543                    query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2_SQL);
4544    
4545                    if (!getDB().isSupportsInlineDistinct()) {
4546                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
4547                    }
4548    
4549                    if (orderByComparator != null) {
4550                            if (getDB().isSupportsInlineDistinct()) {
4551                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4552                                            orderByComparator, true);
4553                            }
4554                            else {
4555                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4556                                            orderByComparator, true);
4557                            }
4558                    }
4559                    else {
4560                            if (getDB().isSupportsInlineDistinct()) {
4561                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
4562                            }
4563                            else {
4564                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
4565                            }
4566                    }
4567    
4568                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4569                                    DLFileShortcut.class.getName(),
4570                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4571    
4572                    Session session = null;
4573    
4574                    try {
4575                            session = openSession();
4576    
4577                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4578    
4579                            if (getDB().isSupportsInlineDistinct()) {
4580                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
4581                            }
4582                            else {
4583                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
4584                            }
4585    
4586                            QueryPos qPos = QueryPos.getInstance(q);
4587    
4588                            qPos.add(groupId);
4589    
4590                            qPos.add(folderId);
4591    
4592                            qPos.add(active);
4593    
4594                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
4595                                    end);
4596                    }
4597                    catch (Exception e) {
4598                            throw processException(e);
4599                    }
4600                    finally {
4601                            closeSession(session);
4602                    }
4603            }
4604    
4605            /**
4606             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63;.
4607             *
4608             * @param fileShortcutId the primary key of the current document library file shortcut
4609             * @param groupId the group ID
4610             * @param folderId the folder ID
4611             * @param active the active
4612             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4613             * @return the previous, current, and next document library file shortcut
4614             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
4615             */
4616            @Override
4617            public DLFileShortcut[] filterFindByG_F_A_PrevAndNext(long fileShortcutId,
4618                    long groupId, long folderId, boolean active,
4619                    OrderByComparator<DLFileShortcut> orderByComparator)
4620                    throws NoSuchFileShortcutException {
4621                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4622                            return findByG_F_A_PrevAndNext(fileShortcutId, groupId, folderId,
4623                                    active, orderByComparator);
4624                    }
4625    
4626                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
4627    
4628                    Session session = null;
4629    
4630                    try {
4631                            session = openSession();
4632    
4633                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
4634    
4635                            array[0] = filterGetByG_F_A_PrevAndNext(session, dlFileShortcut,
4636                                            groupId, folderId, active, orderByComparator, true);
4637    
4638                            array[1] = dlFileShortcut;
4639    
4640                            array[2] = filterGetByG_F_A_PrevAndNext(session, dlFileShortcut,
4641                                            groupId, folderId, active, orderByComparator, false);
4642    
4643                            return array;
4644                    }
4645                    catch (Exception e) {
4646                            throw processException(e);
4647                    }
4648                    finally {
4649                            closeSession(session);
4650                    }
4651            }
4652    
4653            protected DLFileShortcut filterGetByG_F_A_PrevAndNext(Session session,
4654                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
4655                    boolean active, OrderByComparator<DLFileShortcut> orderByComparator,
4656                    boolean previous) {
4657                    StringBundler query = null;
4658    
4659                    if (orderByComparator != null) {
4660                            query = new StringBundler(6 +
4661                                            (orderByComparator.getOrderByFields().length * 6));
4662                    }
4663                    else {
4664                            query = new StringBundler(3);
4665                    }
4666    
4667                    if (getDB().isSupportsInlineDistinct()) {
4668                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
4669                    }
4670                    else {
4671                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
4672                    }
4673    
4674                    query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
4675    
4676                    query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
4677    
4678                    query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2_SQL);
4679    
4680                    if (!getDB().isSupportsInlineDistinct()) {
4681                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
4682                    }
4683    
4684                    if (orderByComparator != null) {
4685                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4686    
4687                            if (orderByConditionFields.length > 0) {
4688                                    query.append(WHERE_AND);
4689                            }
4690    
4691                            for (int i = 0; i < orderByConditionFields.length; i++) {
4692                                    if (getDB().isSupportsInlineDistinct()) {
4693                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4694                                    }
4695                                    else {
4696                                            query.append(_ORDER_BY_ENTITY_TABLE);
4697                                    }
4698    
4699                                    query.append(orderByConditionFields[i]);
4700    
4701                                    if ((i + 1) < orderByConditionFields.length) {
4702                                            if (orderByComparator.isAscending() ^ previous) {
4703                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4704                                            }
4705                                            else {
4706                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4707                                            }
4708                                    }
4709                                    else {
4710                                            if (orderByComparator.isAscending() ^ previous) {
4711                                                    query.append(WHERE_GREATER_THAN);
4712                                            }
4713                                            else {
4714                                                    query.append(WHERE_LESSER_THAN);
4715                                            }
4716                                    }
4717                            }
4718    
4719                            query.append(ORDER_BY_CLAUSE);
4720    
4721                            String[] orderByFields = orderByComparator.getOrderByFields();
4722    
4723                            for (int i = 0; i < orderByFields.length; i++) {
4724                                    if (getDB().isSupportsInlineDistinct()) {
4725                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4726                                    }
4727                                    else {
4728                                            query.append(_ORDER_BY_ENTITY_TABLE);
4729                                    }
4730    
4731                                    query.append(orderByFields[i]);
4732    
4733                                    if ((i + 1) < orderByFields.length) {
4734                                            if (orderByComparator.isAscending() ^ previous) {
4735                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4736                                            }
4737                                            else {
4738                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4739                                            }
4740                                    }
4741                                    else {
4742                                            if (orderByComparator.isAscending() ^ previous) {
4743                                                    query.append(ORDER_BY_ASC);
4744                                            }
4745                                            else {
4746                                                    query.append(ORDER_BY_DESC);
4747                                            }
4748                                    }
4749                            }
4750                    }
4751                    else {
4752                            if (getDB().isSupportsInlineDistinct()) {
4753                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
4754                            }
4755                            else {
4756                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
4757                            }
4758                    }
4759    
4760                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4761                                    DLFileShortcut.class.getName(),
4762                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4763    
4764                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4765    
4766                    q.setFirstResult(0);
4767                    q.setMaxResults(2);
4768    
4769                    if (getDB().isSupportsInlineDistinct()) {
4770                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
4771                    }
4772                    else {
4773                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
4774                    }
4775    
4776                    QueryPos qPos = QueryPos.getInstance(q);
4777    
4778                    qPos.add(groupId);
4779    
4780                    qPos.add(folderId);
4781    
4782                    qPos.add(active);
4783    
4784                    if (orderByComparator != null) {
4785                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
4786    
4787                            for (Object value : values) {
4788                                    qPos.add(value);
4789                            }
4790                    }
4791    
4792                    List<DLFileShortcut> list = q.list();
4793    
4794                    if (list.size() == 2) {
4795                            return list.get(1);
4796                    }
4797                    else {
4798                            return null;
4799                    }
4800            }
4801    
4802            /**
4803             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; from the database.
4804             *
4805             * @param groupId the group ID
4806             * @param folderId the folder ID
4807             * @param active the active
4808             */
4809            @Override
4810            public void removeByG_F_A(long groupId, long folderId, boolean active) {
4811                    for (DLFileShortcut dlFileShortcut : findByG_F_A(groupId, folderId,
4812                                    active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4813                            remove(dlFileShortcut);
4814                    }
4815            }
4816    
4817            /**
4818             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
4819             *
4820             * @param groupId the group ID
4821             * @param folderId the folder ID
4822             * @param active the active
4823             * @return the number of matching document library file shortcuts
4824             */
4825            @Override
4826            public int countByG_F_A(long groupId, long folderId, boolean active) {
4827                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_A;
4828    
4829                    Object[] finderArgs = new Object[] { groupId, folderId, active };
4830    
4831                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4832    
4833                    if (count == null) {
4834                            StringBundler query = new StringBundler(4);
4835    
4836                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
4837    
4838                            query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
4839    
4840                            query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
4841    
4842                            query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2);
4843    
4844                            String sql = query.toString();
4845    
4846                            Session session = null;
4847    
4848                            try {
4849                                    session = openSession();
4850    
4851                                    Query q = session.createQuery(sql);
4852    
4853                                    QueryPos qPos = QueryPos.getInstance(q);
4854    
4855                                    qPos.add(groupId);
4856    
4857                                    qPos.add(folderId);
4858    
4859                                    qPos.add(active);
4860    
4861                                    count = (Long)q.uniqueResult();
4862    
4863                                    finderCache.putResult(finderPath, finderArgs, count);
4864                            }
4865                            catch (Exception e) {
4866                                    finderCache.removeResult(finderPath, finderArgs);
4867    
4868                                    throw processException(e);
4869                            }
4870                            finally {
4871                                    closeSession(session);
4872                            }
4873                    }
4874    
4875                    return count.intValue();
4876            }
4877    
4878            /**
4879             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63;.
4880             *
4881             * @param groupId the group ID
4882             * @param folderId the folder ID
4883             * @param active the active
4884             * @return the number of matching document library file shortcuts that the user has permission to view
4885             */
4886            @Override
4887            public int filterCountByG_F_A(long groupId, long folderId, boolean active) {
4888                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4889                            return countByG_F_A(groupId, folderId, active);
4890                    }
4891    
4892                    StringBundler query = new StringBundler(4);
4893    
4894                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
4895    
4896                    query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
4897    
4898                    query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
4899    
4900                    query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2_SQL);
4901    
4902                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4903                                    DLFileShortcut.class.getName(),
4904                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4905    
4906                    Session session = null;
4907    
4908                    try {
4909                            session = openSession();
4910    
4911                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4912    
4913                            q.addScalar(COUNT_COLUMN_NAME,
4914                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4915    
4916                            QueryPos qPos = QueryPos.getInstance(q);
4917    
4918                            qPos.add(groupId);
4919    
4920                            qPos.add(folderId);
4921    
4922                            qPos.add(active);
4923    
4924                            Long count = (Long)q.uniqueResult();
4925    
4926                            return count.intValue();
4927                    }
4928                    catch (Exception e) {
4929                            throw processException(e);
4930                    }
4931                    finally {
4932                            closeSession(session);
4933                    }
4934            }
4935    
4936            private static final String _FINDER_COLUMN_G_F_A_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
4937            private static final String _FINDER_COLUMN_G_F_A_FOLDERID_2 = "dlFileShortcut.folderId = ? AND ";
4938            private static final String _FINDER_COLUMN_G_F_A_ACTIVE_2 = "dlFileShortcut.active = ?";
4939            private static final String _FINDER_COLUMN_G_F_A_ACTIVE_2_SQL = "dlFileShortcut.active_ = ?";
4940            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_A_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
4941                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
4942                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4943                            "findByG_F_A_S",
4944                            new String[] {
4945                                    Long.class.getName(), Long.class.getName(),
4946                                    Boolean.class.getName(), Integer.class.getName(),
4947                                    
4948                            Integer.class.getName(), Integer.class.getName(),
4949                                    OrderByComparator.class.getName()
4950                            });
4951            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S =
4952                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
4953                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
4954                            DLFileShortcutImpl.class,
4955                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_A_S",
4956                            new String[] {
4957                                    Long.class.getName(), Long.class.getName(),
4958                                    Boolean.class.getName(), Integer.class.getName()
4959                            },
4960                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
4961                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK |
4962                            DLFileShortcutModelImpl.ACTIVE_COLUMN_BITMASK |
4963                            DLFileShortcutModelImpl.STATUS_COLUMN_BITMASK);
4964            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_A_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
4965                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
4966                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_A_S",
4967                            new String[] {
4968                                    Long.class.getName(), Long.class.getName(),
4969                                    Boolean.class.getName(), Integer.class.getName()
4970                            });
4971    
4972            /**
4973             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
4974             *
4975             * @param groupId the group ID
4976             * @param folderId the folder ID
4977             * @param active the active
4978             * @param status the status
4979             * @return the matching document library file shortcuts
4980             */
4981            @Override
4982            public List<DLFileShortcut> findByG_F_A_S(long groupId, long folderId,
4983                    boolean active, int status) {
4984                    return findByG_F_A_S(groupId, folderId, active, status,
4985                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4986            }
4987    
4988            /**
4989             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
4990             *
4991             * <p>
4992             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4993             * </p>
4994             *
4995             * @param groupId the group ID
4996             * @param folderId the folder ID
4997             * @param active the active
4998             * @param status the status
4999             * @param start the lower bound of the range of document library file shortcuts
5000             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
5001             * @return the range of matching document library file shortcuts
5002             */
5003            @Override
5004            public List<DLFileShortcut> findByG_F_A_S(long groupId, long folderId,
5005                    boolean active, int status, int start, int end) {
5006                    return findByG_F_A_S(groupId, folderId, active, status, start, end, null);
5007            }
5008    
5009            /**
5010             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5011             *
5012             * <p>
5013             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5014             * </p>
5015             *
5016             * @param groupId the group ID
5017             * @param folderId the folder ID
5018             * @param active the active
5019             * @param status the status
5020             * @param start the lower bound of the range of document library file shortcuts
5021             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
5022             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5023             * @return the ordered range of matching document library file shortcuts
5024             */
5025            @Override
5026            public List<DLFileShortcut> findByG_F_A_S(long groupId, long folderId,
5027                    boolean active, int status, int start, int end,
5028                    OrderByComparator<DLFileShortcut> orderByComparator) {
5029                    return findByG_F_A_S(groupId, folderId, active, status, start, end,
5030                            orderByComparator, true);
5031            }
5032    
5033            /**
5034             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5035             *
5036             * <p>
5037             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5038             * </p>
5039             *
5040             * @param groupId the group ID
5041             * @param folderId the folder ID
5042             * @param active the active
5043             * @param status the status
5044             * @param start the lower bound of the range of document library file shortcuts
5045             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
5046             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5047             * @param retrieveFromCache whether to retrieve from the finder cache
5048             * @return the ordered range of matching document library file shortcuts
5049             */
5050            @Override
5051            public List<DLFileShortcut> findByG_F_A_S(long groupId, long folderId,
5052                    boolean active, int status, int start, int end,
5053                    OrderByComparator<DLFileShortcut> orderByComparator,
5054                    boolean retrieveFromCache) {
5055                    boolean pagination = true;
5056                    FinderPath finderPath = null;
5057                    Object[] finderArgs = null;
5058    
5059                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5060                                    (orderByComparator == null)) {
5061                            pagination = false;
5062                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S;
5063                            finderArgs = new Object[] { groupId, folderId, active, status };
5064                    }
5065                    else {
5066                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_A_S;
5067                            finderArgs = new Object[] {
5068                                            groupId, folderId, active, status,
5069                                            
5070                                            start, end, orderByComparator
5071                                    };
5072                    }
5073    
5074                    List<DLFileShortcut> list = null;
5075    
5076                    if (retrieveFromCache) {
5077                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
5078                                            finderArgs, this);
5079    
5080                            if ((list != null) && !list.isEmpty()) {
5081                                    for (DLFileShortcut dlFileShortcut : list) {
5082                                            if ((groupId != dlFileShortcut.getGroupId()) ||
5083                                                            (folderId != dlFileShortcut.getFolderId()) ||
5084                                                            (active != dlFileShortcut.getActive()) ||
5085                                                            (status != dlFileShortcut.getStatus())) {
5086                                                    list = null;
5087    
5088                                                    break;
5089                                            }
5090                                    }
5091                            }
5092                    }
5093    
5094                    if (list == null) {
5095                            StringBundler query = null;
5096    
5097                            if (orderByComparator != null) {
5098                                    query = new StringBundler(6 +
5099                                                    (orderByComparator.getOrderByFields().length * 3));
5100                            }
5101                            else {
5102                                    query = new StringBundler(6);
5103                            }
5104    
5105                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
5106    
5107                            query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
5108    
5109                            query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
5110    
5111                            query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2);
5112    
5113                            query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
5114    
5115                            if (orderByComparator != null) {
5116                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5117                                            orderByComparator);
5118                            }
5119                            else
5120                             if (pagination) {
5121                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
5122                            }
5123    
5124                            String sql = query.toString();
5125    
5126                            Session session = null;
5127    
5128                            try {
5129                                    session = openSession();
5130    
5131                                    Query q = session.createQuery(sql);
5132    
5133                                    QueryPos qPos = QueryPos.getInstance(q);
5134    
5135                                    qPos.add(groupId);
5136    
5137                                    qPos.add(folderId);
5138    
5139                                    qPos.add(active);
5140    
5141                                    qPos.add(status);
5142    
5143                                    if (!pagination) {
5144                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
5145                                                            getDialect(), start, end, false);
5146    
5147                                            Collections.sort(list);
5148    
5149                                            list = Collections.unmodifiableList(list);
5150                                    }
5151                                    else {
5152                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
5153                                                            getDialect(), start, end);
5154                                    }
5155    
5156                                    cacheResult(list);
5157    
5158                                    finderCache.putResult(finderPath, finderArgs, list);
5159                            }
5160                            catch (Exception e) {
5161                                    finderCache.removeResult(finderPath, finderArgs);
5162    
5163                                    throw processException(e);
5164                            }
5165                            finally {
5166                                    closeSession(session);
5167                            }
5168                    }
5169    
5170                    return list;
5171            }
5172    
5173            /**
5174             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5175             *
5176             * @param groupId the group ID
5177             * @param folderId the folder ID
5178             * @param active the active
5179             * @param status the status
5180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5181             * @return the first matching document library file shortcut
5182             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
5183             */
5184            @Override
5185            public DLFileShortcut findByG_F_A_S_First(long groupId, long folderId,
5186                    boolean active, int status,
5187                    OrderByComparator<DLFileShortcut> orderByComparator)
5188                    throws NoSuchFileShortcutException {
5189                    DLFileShortcut dlFileShortcut = fetchByG_F_A_S_First(groupId, folderId,
5190                                    active, status, orderByComparator);
5191    
5192                    if (dlFileShortcut != null) {
5193                            return dlFileShortcut;
5194                    }
5195    
5196                    StringBundler msg = new StringBundler(10);
5197    
5198                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5199    
5200                    msg.append("groupId=");
5201                    msg.append(groupId);
5202    
5203                    msg.append(", folderId=");
5204                    msg.append(folderId);
5205    
5206                    msg.append(", active=");
5207                    msg.append(active);
5208    
5209                    msg.append(", status=");
5210                    msg.append(status);
5211    
5212                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5213    
5214                    throw new NoSuchFileShortcutException(msg.toString());
5215            }
5216    
5217            /**
5218             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5219             *
5220             * @param groupId the group ID
5221             * @param folderId the folder ID
5222             * @param active the active
5223             * @param status the status
5224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5225             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
5226             */
5227            @Override
5228            public DLFileShortcut fetchByG_F_A_S_First(long groupId, long folderId,
5229                    boolean active, int status,
5230                    OrderByComparator<DLFileShortcut> orderByComparator) {
5231                    List<DLFileShortcut> list = findByG_F_A_S(groupId, folderId, active,
5232                                    status, 0, 1, orderByComparator);
5233    
5234                    if (!list.isEmpty()) {
5235                            return list.get(0);
5236                    }
5237    
5238                    return null;
5239            }
5240    
5241            /**
5242             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5243             *
5244             * @param groupId the group ID
5245             * @param folderId the folder ID
5246             * @param active the active
5247             * @param status the status
5248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5249             * @return the last matching document library file shortcut
5250             * @throws NoSuchFileShortcutException if a matching document library file shortcut could not be found
5251             */
5252            @Override
5253            public DLFileShortcut findByG_F_A_S_Last(long groupId, long folderId,
5254                    boolean active, int status,
5255                    OrderByComparator<DLFileShortcut> orderByComparator)
5256                    throws NoSuchFileShortcutException {
5257                    DLFileShortcut dlFileShortcut = fetchByG_F_A_S_Last(groupId, folderId,
5258                                    active, status, orderByComparator);
5259    
5260                    if (dlFileShortcut != null) {
5261                            return dlFileShortcut;
5262                    }
5263    
5264                    StringBundler msg = new StringBundler(10);
5265    
5266                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5267    
5268                    msg.append("groupId=");
5269                    msg.append(groupId);
5270    
5271                    msg.append(", folderId=");
5272                    msg.append(folderId);
5273    
5274                    msg.append(", active=");
5275                    msg.append(active);
5276    
5277                    msg.append(", status=");
5278                    msg.append(status);
5279    
5280                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5281    
5282                    throw new NoSuchFileShortcutException(msg.toString());
5283            }
5284    
5285            /**
5286             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5287             *
5288             * @param groupId the group ID
5289             * @param folderId the folder ID
5290             * @param active the active
5291             * @param status the status
5292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5293             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
5294             */
5295            @Override
5296            public DLFileShortcut fetchByG_F_A_S_Last(long groupId, long folderId,
5297                    boolean active, int status,
5298                    OrderByComparator<DLFileShortcut> orderByComparator) {
5299                    int count = countByG_F_A_S(groupId, folderId, active, status);
5300    
5301                    if (count == 0) {
5302                            return null;
5303                    }
5304    
5305                    List<DLFileShortcut> list = findByG_F_A_S(groupId, folderId, active,
5306                                    status, count - 1, count, orderByComparator);
5307    
5308                    if (!list.isEmpty()) {
5309                            return list.get(0);
5310                    }
5311    
5312                    return null;
5313            }
5314    
5315            /**
5316             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5317             *
5318             * @param fileShortcutId the primary key of the current document library file shortcut
5319             * @param groupId the group ID
5320             * @param folderId the folder ID
5321             * @param active the active
5322             * @param status the status
5323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5324             * @return the previous, current, and next document library file shortcut
5325             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
5326             */
5327            @Override
5328            public DLFileShortcut[] findByG_F_A_S_PrevAndNext(long fileShortcutId,
5329                    long groupId, long folderId, boolean active, int status,
5330                    OrderByComparator<DLFileShortcut> orderByComparator)
5331                    throws NoSuchFileShortcutException {
5332                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
5333    
5334                    Session session = null;
5335    
5336                    try {
5337                            session = openSession();
5338    
5339                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
5340    
5341                            array[0] = getByG_F_A_S_PrevAndNext(session, dlFileShortcut,
5342                                            groupId, folderId, active, status, orderByComparator, true);
5343    
5344                            array[1] = dlFileShortcut;
5345    
5346                            array[2] = getByG_F_A_S_PrevAndNext(session, dlFileShortcut,
5347                                            groupId, folderId, active, status, orderByComparator, false);
5348    
5349                            return array;
5350                    }
5351                    catch (Exception e) {
5352                            throw processException(e);
5353                    }
5354                    finally {
5355                            closeSession(session);
5356                    }
5357            }
5358    
5359            protected DLFileShortcut getByG_F_A_S_PrevAndNext(Session session,
5360                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
5361                    boolean active, int status,
5362                    OrderByComparator<DLFileShortcut> orderByComparator, boolean previous) {
5363                    StringBundler query = null;
5364    
5365                    if (orderByComparator != null) {
5366                            query = new StringBundler(6 +
5367                                            (orderByComparator.getOrderByFields().length * 6));
5368                    }
5369                    else {
5370                            query = new StringBundler(3);
5371                    }
5372    
5373                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
5374    
5375                    query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
5376    
5377                    query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
5378    
5379                    query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2);
5380    
5381                    query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
5382    
5383                    if (orderByComparator != null) {
5384                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5385    
5386                            if (orderByConditionFields.length > 0) {
5387                                    query.append(WHERE_AND);
5388                            }
5389    
5390                            for (int i = 0; i < orderByConditionFields.length; i++) {
5391                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5392                                    query.append(orderByConditionFields[i]);
5393    
5394                                    if ((i + 1) < orderByConditionFields.length) {
5395                                            if (orderByComparator.isAscending() ^ previous) {
5396                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5397                                            }
5398                                            else {
5399                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5400                                            }
5401                                    }
5402                                    else {
5403                                            if (orderByComparator.isAscending() ^ previous) {
5404                                                    query.append(WHERE_GREATER_THAN);
5405                                            }
5406                                            else {
5407                                                    query.append(WHERE_LESSER_THAN);
5408                                            }
5409                                    }
5410                            }
5411    
5412                            query.append(ORDER_BY_CLAUSE);
5413    
5414                            String[] orderByFields = orderByComparator.getOrderByFields();
5415    
5416                            for (int i = 0; i < orderByFields.length; i++) {
5417                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5418                                    query.append(orderByFields[i]);
5419    
5420                                    if ((i + 1) < orderByFields.length) {
5421                                            if (orderByComparator.isAscending() ^ previous) {
5422                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5423                                            }
5424                                            else {
5425                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5426                                            }
5427                                    }
5428                                    else {
5429                                            if (orderByComparator.isAscending() ^ previous) {
5430                                                    query.append(ORDER_BY_ASC);
5431                                            }
5432                                            else {
5433                                                    query.append(ORDER_BY_DESC);
5434                                            }
5435                                    }
5436                            }
5437                    }
5438                    else {
5439                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
5440                    }
5441    
5442                    String sql = query.toString();
5443    
5444                    Query q = session.createQuery(sql);
5445    
5446                    q.setFirstResult(0);
5447                    q.setMaxResults(2);
5448    
5449                    QueryPos qPos = QueryPos.getInstance(q);
5450    
5451                    qPos.add(groupId);
5452    
5453                    qPos.add(folderId);
5454    
5455                    qPos.add(active);
5456    
5457                    qPos.add(status);
5458    
5459                    if (orderByComparator != null) {
5460                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
5461    
5462                            for (Object value : values) {
5463                                    qPos.add(value);
5464                            }
5465                    }
5466    
5467                    List<DLFileShortcut> list = q.list();
5468    
5469                    if (list.size() == 2) {
5470                            return list.get(1);
5471                    }
5472                    else {
5473                            return null;
5474                    }
5475            }
5476    
5477            /**
5478             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5479             *
5480             * @param groupId the group ID
5481             * @param folderId the folder ID
5482             * @param active the active
5483             * @param status the status
5484             * @return the matching document library file shortcuts that the user has permission to view
5485             */
5486            @Override
5487            public List<DLFileShortcut> filterFindByG_F_A_S(long groupId,
5488                    long folderId, boolean active, int status) {
5489                    return filterFindByG_F_A_S(groupId, folderId, active, status,
5490                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5491            }
5492    
5493            /**
5494             * Returns a range of all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5495             *
5496             * <p>
5497             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5498             * </p>
5499             *
5500             * @param groupId the group ID
5501             * @param folderId the folder ID
5502             * @param active the active
5503             * @param status the status
5504             * @param start the lower bound of the range of document library file shortcuts
5505             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
5506             * @return the range of matching document library file shortcuts that the user has permission to view
5507             */
5508            @Override
5509            public List<DLFileShortcut> filterFindByG_F_A_S(long groupId,
5510                    long folderId, boolean active, int status, int start, int end) {
5511                    return filterFindByG_F_A_S(groupId, folderId, active, status, start,
5512                            end, null);
5513            }
5514    
5515            /**
5516             * Returns an ordered range of all the document library file shortcuts that the user has permissions to view where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5517             *
5518             * <p>
5519             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5520             * </p>
5521             *
5522             * @param groupId the group ID
5523             * @param folderId the folder ID
5524             * @param active the active
5525             * @param status the status
5526             * @param start the lower bound of the range of document library file shortcuts
5527             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
5528             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5529             * @return the ordered range of matching document library file shortcuts that the user has permission to view
5530             */
5531            @Override
5532            public List<DLFileShortcut> filterFindByG_F_A_S(long groupId,
5533                    long folderId, boolean active, int status, int start, int end,
5534                    OrderByComparator<DLFileShortcut> orderByComparator) {
5535                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5536                            return findByG_F_A_S(groupId, folderId, active, status, start, end,
5537                                    orderByComparator);
5538                    }
5539    
5540                    StringBundler query = null;
5541    
5542                    if (orderByComparator != null) {
5543                            query = new StringBundler(6 +
5544                                            (orderByComparator.getOrderByFields().length * 3));
5545                    }
5546                    else {
5547                            query = new StringBundler(6);
5548                    }
5549    
5550                    if (getDB().isSupportsInlineDistinct()) {
5551                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
5552                    }
5553                    else {
5554                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
5555                    }
5556    
5557                    query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
5558    
5559                    query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
5560    
5561                    query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2_SQL);
5562    
5563                    query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
5564    
5565                    if (!getDB().isSupportsInlineDistinct()) {
5566                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
5567                    }
5568    
5569                    if (orderByComparator != null) {
5570                            if (getDB().isSupportsInlineDistinct()) {
5571                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5572                                            orderByComparator, true);
5573                            }
5574                            else {
5575                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5576                                            orderByComparator, true);
5577                            }
5578                    }
5579                    else {
5580                            if (getDB().isSupportsInlineDistinct()) {
5581                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
5582                            }
5583                            else {
5584                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
5585                            }
5586                    }
5587    
5588                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5589                                    DLFileShortcut.class.getName(),
5590                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5591    
5592                    Session session = null;
5593    
5594                    try {
5595                            session = openSession();
5596    
5597                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5598    
5599                            if (getDB().isSupportsInlineDistinct()) {
5600                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
5601                            }
5602                            else {
5603                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
5604                            }
5605    
5606                            QueryPos qPos = QueryPos.getInstance(q);
5607    
5608                            qPos.add(groupId);
5609    
5610                            qPos.add(folderId);
5611    
5612                            qPos.add(active);
5613    
5614                            qPos.add(status);
5615    
5616                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
5617                                    end);
5618                    }
5619                    catch (Exception e) {
5620                            throw processException(e);
5621                    }
5622                    finally {
5623                            closeSession(session);
5624                    }
5625            }
5626    
5627            /**
5628             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5629             *
5630             * @param fileShortcutId the primary key of the current document library file shortcut
5631             * @param groupId the group ID
5632             * @param folderId the folder ID
5633             * @param active the active
5634             * @param status the status
5635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5636             * @return the previous, current, and next document library file shortcut
5637             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
5638             */
5639            @Override
5640            public DLFileShortcut[] filterFindByG_F_A_S_PrevAndNext(
5641                    long fileShortcutId, long groupId, long folderId, boolean active,
5642                    int status, OrderByComparator<DLFileShortcut> orderByComparator)
5643                    throws NoSuchFileShortcutException {
5644                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5645                            return findByG_F_A_S_PrevAndNext(fileShortcutId, groupId, folderId,
5646                                    active, status, orderByComparator);
5647                    }
5648    
5649                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
5650    
5651                    Session session = null;
5652    
5653                    try {
5654                            session = openSession();
5655    
5656                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
5657    
5658                            array[0] = filterGetByG_F_A_S_PrevAndNext(session, dlFileShortcut,
5659                                            groupId, folderId, active, status, orderByComparator, true);
5660    
5661                            array[1] = dlFileShortcut;
5662    
5663                            array[2] = filterGetByG_F_A_S_PrevAndNext(session, dlFileShortcut,
5664                                            groupId, folderId, active, status, orderByComparator, false);
5665    
5666                            return array;
5667                    }
5668                    catch (Exception e) {
5669                            throw processException(e);
5670                    }
5671                    finally {
5672                            closeSession(session);
5673                    }
5674            }
5675    
5676            protected DLFileShortcut filterGetByG_F_A_S_PrevAndNext(Session session,
5677                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
5678                    boolean active, int status,
5679                    OrderByComparator<DLFileShortcut> orderByComparator, boolean previous) {
5680                    StringBundler query = null;
5681    
5682                    if (orderByComparator != null) {
5683                            query = new StringBundler(6 +
5684                                            (orderByComparator.getOrderByFields().length * 6));
5685                    }
5686                    else {
5687                            query = new StringBundler(3);
5688                    }
5689    
5690                    if (getDB().isSupportsInlineDistinct()) {
5691                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
5692                    }
5693                    else {
5694                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
5695                    }
5696    
5697                    query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
5698    
5699                    query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
5700    
5701                    query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2_SQL);
5702    
5703                    query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
5704    
5705                    if (!getDB().isSupportsInlineDistinct()) {
5706                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
5707                    }
5708    
5709                    if (orderByComparator != null) {
5710                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5711    
5712                            if (orderByConditionFields.length > 0) {
5713                                    query.append(WHERE_AND);
5714                            }
5715    
5716                            for (int i = 0; i < orderByConditionFields.length; i++) {
5717                                    if (getDB().isSupportsInlineDistinct()) {
5718                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5719                                    }
5720                                    else {
5721                                            query.append(_ORDER_BY_ENTITY_TABLE);
5722                                    }
5723    
5724                                    query.append(orderByConditionFields[i]);
5725    
5726                                    if ((i + 1) < orderByConditionFields.length) {
5727                                            if (orderByComparator.isAscending() ^ previous) {
5728                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5729                                            }
5730                                            else {
5731                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5732                                            }
5733                                    }
5734                                    else {
5735                                            if (orderByComparator.isAscending() ^ previous) {
5736                                                    query.append(WHERE_GREATER_THAN);
5737                                            }
5738                                            else {
5739                                                    query.append(WHERE_LESSER_THAN);
5740                                            }
5741                                    }
5742                            }
5743    
5744                            query.append(ORDER_BY_CLAUSE);
5745    
5746                            String[] orderByFields = orderByComparator.getOrderByFields();
5747    
5748                            for (int i = 0; i < orderByFields.length; i++) {
5749                                    if (getDB().isSupportsInlineDistinct()) {
5750                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5751                                    }
5752                                    else {
5753                                            query.append(_ORDER_BY_ENTITY_TABLE);
5754                                    }
5755    
5756                                    query.append(orderByFields[i]);
5757    
5758                                    if ((i + 1) < orderByFields.length) {
5759                                            if (orderByComparator.isAscending() ^ previous) {
5760                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5761                                            }
5762                                            else {
5763                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5764                                            }
5765                                    }
5766                                    else {
5767                                            if (orderByComparator.isAscending() ^ previous) {
5768                                                    query.append(ORDER_BY_ASC);
5769                                            }
5770                                            else {
5771                                                    query.append(ORDER_BY_DESC);
5772                                            }
5773                                    }
5774                            }
5775                    }
5776                    else {
5777                            if (getDB().isSupportsInlineDistinct()) {
5778                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
5779                            }
5780                            else {
5781                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
5782                            }
5783                    }
5784    
5785                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5786                                    DLFileShortcut.class.getName(),
5787                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5788    
5789                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5790    
5791                    q.setFirstResult(0);
5792                    q.setMaxResults(2);
5793    
5794                    if (getDB().isSupportsInlineDistinct()) {
5795                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
5796                    }
5797                    else {
5798                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
5799                    }
5800    
5801                    QueryPos qPos = QueryPos.getInstance(q);
5802    
5803                    qPos.add(groupId);
5804    
5805                    qPos.add(folderId);
5806    
5807                    qPos.add(active);
5808    
5809                    qPos.add(status);
5810    
5811                    if (orderByComparator != null) {
5812                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
5813    
5814                            for (Object value : values) {
5815                                    qPos.add(value);
5816                            }
5817                    }
5818    
5819                    List<DLFileShortcut> list = q.list();
5820    
5821                    if (list.size() == 2) {
5822                            return list.get(1);
5823                    }
5824                    else {
5825                            return null;
5826                    }
5827            }
5828    
5829            /**
5830             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63; from the database.
5831             *
5832             * @param groupId the group ID
5833             * @param folderId the folder ID
5834             * @param active the active
5835             * @param status the status
5836             */
5837            @Override
5838            public void removeByG_F_A_S(long groupId, long folderId, boolean active,
5839                    int status) {
5840                    for (DLFileShortcut dlFileShortcut : findByG_F_A_S(groupId, folderId,
5841                                    active, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5842                            remove(dlFileShortcut);
5843                    }
5844            }
5845    
5846            /**
5847             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5848             *
5849             * @param groupId the group ID
5850             * @param folderId the folder ID
5851             * @param active the active
5852             * @param status the status
5853             * @return the number of matching document library file shortcuts
5854             */
5855            @Override
5856            public int countByG_F_A_S(long groupId, long folderId, boolean active,
5857                    int status) {
5858                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_A_S;
5859    
5860                    Object[] finderArgs = new Object[] { groupId, folderId, active, status };
5861    
5862                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5863    
5864                    if (count == null) {
5865                            StringBundler query = new StringBundler(5);
5866    
5867                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
5868    
5869                            query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
5870    
5871                            query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
5872    
5873                            query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2);
5874    
5875                            query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
5876    
5877                            String sql = query.toString();
5878    
5879                            Session session = null;
5880    
5881                            try {
5882                                    session = openSession();
5883    
5884                                    Query q = session.createQuery(sql);
5885    
5886                                    QueryPos qPos = QueryPos.getInstance(q);
5887    
5888                                    qPos.add(groupId);
5889    
5890                                    qPos.add(folderId);
5891    
5892                                    qPos.add(active);
5893    
5894                                    qPos.add(status);
5895    
5896                                    count = (Long)q.uniqueResult();
5897    
5898                                    finderCache.putResult(finderPath, finderArgs, count);
5899                            }
5900                            catch (Exception e) {
5901                                    finderCache.removeResult(finderPath, finderArgs);
5902    
5903                                    throw processException(e);
5904                            }
5905                            finally {
5906                                    closeSession(session);
5907                            }
5908                    }
5909    
5910                    return count.intValue();
5911            }
5912    
5913            /**
5914             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
5915             *
5916             * @param groupId the group ID
5917             * @param folderId the folder ID
5918             * @param active the active
5919             * @param status the status
5920             * @return the number of matching document library file shortcuts that the user has permission to view
5921             */
5922            @Override
5923            public int filterCountByG_F_A_S(long groupId, long folderId,
5924                    boolean active, int status) {
5925                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5926                            return countByG_F_A_S(groupId, folderId, active, status);
5927                    }
5928    
5929                    StringBundler query = new StringBundler(5);
5930    
5931                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
5932    
5933                    query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
5934    
5935                    query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
5936    
5937                    query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2_SQL);
5938    
5939                    query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
5940    
5941                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5942                                    DLFileShortcut.class.getName(),
5943                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5944    
5945                    Session session = null;
5946    
5947                    try {
5948                            session = openSession();
5949    
5950                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5951    
5952                            q.addScalar(COUNT_COLUMN_NAME,
5953                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5954    
5955                            QueryPos qPos = QueryPos.getInstance(q);
5956    
5957                            qPos.add(groupId);
5958    
5959                            qPos.add(folderId);
5960    
5961                            qPos.add(active);
5962    
5963                            qPos.add(status);
5964    
5965                            Long count = (Long)q.uniqueResult();
5966    
5967                            return count.intValue();
5968                    }
5969                    catch (Exception e) {
5970                            throw processException(e);
5971                    }
5972                    finally {
5973                            closeSession(session);
5974                    }
5975            }
5976    
5977            private static final String _FINDER_COLUMN_G_F_A_S_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
5978            private static final String _FINDER_COLUMN_G_F_A_S_FOLDERID_2 = "dlFileShortcut.folderId = ? AND ";
5979            private static final String _FINDER_COLUMN_G_F_A_S_ACTIVE_2 = "dlFileShortcut.active = ? AND ";
5980            private static final String _FINDER_COLUMN_G_F_A_S_ACTIVE_2_SQL = "dlFileShortcut.active_ = ? AND ";
5981            private static final String _FINDER_COLUMN_G_F_A_S_STATUS_2 = "dlFileShortcut.status = ?";
5982    
5983            public DLFileShortcutPersistenceImpl() {
5984                    setModelClass(DLFileShortcut.class);
5985            }
5986    
5987            /**
5988             * Caches the document library file shortcut in the entity cache if it is enabled.
5989             *
5990             * @param dlFileShortcut the document library file shortcut
5991             */
5992            @Override
5993            public void cacheResult(DLFileShortcut dlFileShortcut) {
5994                    entityCache.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
5995                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
5996                            dlFileShortcut);
5997    
5998                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
5999                            new Object[] { dlFileShortcut.getUuid(), dlFileShortcut.getGroupId() },
6000                            dlFileShortcut);
6001    
6002                    dlFileShortcut.resetOriginalValues();
6003            }
6004    
6005            /**
6006             * Caches the document library file shortcuts in the entity cache if it is enabled.
6007             *
6008             * @param dlFileShortcuts the document library file shortcuts
6009             */
6010            @Override
6011            public void cacheResult(List<DLFileShortcut> dlFileShortcuts) {
6012                    for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
6013                            if (entityCache.getResult(
6014                                                    DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6015                                                    DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey()) == null) {
6016                                    cacheResult(dlFileShortcut);
6017                            }
6018                            else {
6019                                    dlFileShortcut.resetOriginalValues();
6020                            }
6021                    }
6022            }
6023    
6024            /**
6025             * Clears the cache for all document library file shortcuts.
6026             *
6027             * <p>
6028             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
6029             * </p>
6030             */
6031            @Override
6032            public void clearCache() {
6033                    entityCache.clearCache(DLFileShortcutImpl.class);
6034    
6035                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
6036                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6037                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6038            }
6039    
6040            /**
6041             * Clears the cache for the document library file shortcut.
6042             *
6043             * <p>
6044             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
6045             * </p>
6046             */
6047            @Override
6048            public void clearCache(DLFileShortcut dlFileShortcut) {
6049                    entityCache.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6050                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
6051    
6052                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6053                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6054    
6055                    clearUniqueFindersCache((DLFileShortcutModelImpl)dlFileShortcut);
6056            }
6057    
6058            @Override
6059            public void clearCache(List<DLFileShortcut> dlFileShortcuts) {
6060                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6061                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6062    
6063                    for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
6064                            entityCache.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6065                                    DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
6066    
6067                            clearUniqueFindersCache((DLFileShortcutModelImpl)dlFileShortcut);
6068                    }
6069            }
6070    
6071            protected void cacheUniqueFindersCache(
6072                    DLFileShortcutModelImpl dlFileShortcutModelImpl, boolean isNew) {
6073                    if (isNew) {
6074                            Object[] args = new Object[] {
6075                                            dlFileShortcutModelImpl.getUuid(),
6076                                            dlFileShortcutModelImpl.getGroupId()
6077                                    };
6078    
6079                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
6080                                    Long.valueOf(1));
6081                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
6082                                    dlFileShortcutModelImpl);
6083                    }
6084                    else {
6085                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
6086                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
6087                                    Object[] args = new Object[] {
6088                                                    dlFileShortcutModelImpl.getUuid(),
6089                                                    dlFileShortcutModelImpl.getGroupId()
6090                                            };
6091    
6092                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
6093                                            Long.valueOf(1));
6094                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
6095                                            dlFileShortcutModelImpl);
6096                            }
6097                    }
6098            }
6099    
6100            protected void clearUniqueFindersCache(
6101                    DLFileShortcutModelImpl dlFileShortcutModelImpl) {
6102                    Object[] args = new Object[] {
6103                                    dlFileShortcutModelImpl.getUuid(),
6104                                    dlFileShortcutModelImpl.getGroupId()
6105                            };
6106    
6107                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
6108                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
6109    
6110                    if ((dlFileShortcutModelImpl.getColumnBitmask() &
6111                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
6112                            args = new Object[] {
6113                                            dlFileShortcutModelImpl.getOriginalUuid(),
6114                                            dlFileShortcutModelImpl.getOriginalGroupId()
6115                                    };
6116    
6117                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
6118                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
6119                    }
6120            }
6121    
6122            /**
6123             * Creates a new document library file shortcut with the primary key. Does not add the document library file shortcut to the database.
6124             *
6125             * @param fileShortcutId the primary key for the new document library file shortcut
6126             * @return the new document library file shortcut
6127             */
6128            @Override
6129            public DLFileShortcut create(long fileShortcutId) {
6130                    DLFileShortcut dlFileShortcut = new DLFileShortcutImpl();
6131    
6132                    dlFileShortcut.setNew(true);
6133                    dlFileShortcut.setPrimaryKey(fileShortcutId);
6134    
6135                    String uuid = PortalUUIDUtil.generate();
6136    
6137                    dlFileShortcut.setUuid(uuid);
6138    
6139                    dlFileShortcut.setCompanyId(companyProvider.getCompanyId());
6140    
6141                    return dlFileShortcut;
6142            }
6143    
6144            /**
6145             * Removes the document library file shortcut with the primary key from the database. Also notifies the appropriate model listeners.
6146             *
6147             * @param fileShortcutId the primary key of the document library file shortcut
6148             * @return the document library file shortcut that was removed
6149             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
6150             */
6151            @Override
6152            public DLFileShortcut remove(long fileShortcutId)
6153                    throws NoSuchFileShortcutException {
6154                    return remove((Serializable)fileShortcutId);
6155            }
6156    
6157            /**
6158             * Removes the document library file shortcut with the primary key from the database. Also notifies the appropriate model listeners.
6159             *
6160             * @param primaryKey the primary key of the document library file shortcut
6161             * @return the document library file shortcut that was removed
6162             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
6163             */
6164            @Override
6165            public DLFileShortcut remove(Serializable primaryKey)
6166                    throws NoSuchFileShortcutException {
6167                    Session session = null;
6168    
6169                    try {
6170                            session = openSession();
6171    
6172                            DLFileShortcut dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
6173                                            primaryKey);
6174    
6175                            if (dlFileShortcut == null) {
6176                                    if (_log.isWarnEnabled()) {
6177                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
6178                                    }
6179    
6180                                    throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
6181                                            primaryKey);
6182                            }
6183    
6184                            return remove(dlFileShortcut);
6185                    }
6186                    catch (NoSuchFileShortcutException nsee) {
6187                            throw nsee;
6188                    }
6189                    catch (Exception e) {
6190                            throw processException(e);
6191                    }
6192                    finally {
6193                            closeSession(session);
6194                    }
6195            }
6196    
6197            @Override
6198            protected DLFileShortcut removeImpl(DLFileShortcut dlFileShortcut) {
6199                    dlFileShortcut = toUnwrappedModel(dlFileShortcut);
6200    
6201                    Session session = null;
6202    
6203                    try {
6204                            session = openSession();
6205    
6206                            if (!session.contains(dlFileShortcut)) {
6207                                    dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
6208                                                    dlFileShortcut.getPrimaryKeyObj());
6209                            }
6210    
6211                            if (dlFileShortcut != null) {
6212                                    session.delete(dlFileShortcut);
6213                            }
6214                    }
6215                    catch (Exception e) {
6216                            throw processException(e);
6217                    }
6218                    finally {
6219                            closeSession(session);
6220                    }
6221    
6222                    if (dlFileShortcut != null) {
6223                            clearCache(dlFileShortcut);
6224                    }
6225    
6226                    return dlFileShortcut;
6227            }
6228    
6229            @Override
6230            public DLFileShortcut updateImpl(DLFileShortcut dlFileShortcut) {
6231                    dlFileShortcut = toUnwrappedModel(dlFileShortcut);
6232    
6233                    boolean isNew = dlFileShortcut.isNew();
6234    
6235                    DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
6236    
6237                    if (Validator.isNull(dlFileShortcut.getUuid())) {
6238                            String uuid = PortalUUIDUtil.generate();
6239    
6240                            dlFileShortcut.setUuid(uuid);
6241                    }
6242    
6243                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
6244    
6245                    Date now = new Date();
6246    
6247                    if (isNew && (dlFileShortcut.getCreateDate() == null)) {
6248                            if (serviceContext == null) {
6249                                    dlFileShortcut.setCreateDate(now);
6250                            }
6251                            else {
6252                                    dlFileShortcut.setCreateDate(serviceContext.getCreateDate(now));
6253                            }
6254                    }
6255    
6256                    if (!dlFileShortcutModelImpl.hasSetModifiedDate()) {
6257                            if (serviceContext == null) {
6258                                    dlFileShortcut.setModifiedDate(now);
6259                            }
6260                            else {
6261                                    dlFileShortcut.setModifiedDate(serviceContext.getModifiedDate(
6262                                                    now));
6263                            }
6264                    }
6265    
6266                    Session session = null;
6267    
6268                    try {
6269                            session = openSession();
6270    
6271                            if (dlFileShortcut.isNew()) {
6272                                    session.save(dlFileShortcut);
6273    
6274                                    dlFileShortcut.setNew(false);
6275                            }
6276                            else {
6277                                    dlFileShortcut = (DLFileShortcut)session.merge(dlFileShortcut);
6278                            }
6279                    }
6280                    catch (Exception e) {
6281                            throw processException(e);
6282                    }
6283                    finally {
6284                            closeSession(session);
6285                    }
6286    
6287                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6288    
6289                    if (isNew || !DLFileShortcutModelImpl.COLUMN_BITMASK_ENABLED) {
6290                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6291                    }
6292    
6293                    else {
6294                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
6295                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
6296                                    Object[] args = new Object[] {
6297                                                    dlFileShortcutModelImpl.getOriginalUuid()
6298                                            };
6299    
6300                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
6301                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
6302                                            args);
6303    
6304                                    args = new Object[] { dlFileShortcutModelImpl.getUuid() };
6305    
6306                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
6307                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
6308                                            args);
6309                            }
6310    
6311                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
6312                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
6313                                    Object[] args = new Object[] {
6314                                                    dlFileShortcutModelImpl.getOriginalUuid(),
6315                                                    dlFileShortcutModelImpl.getOriginalCompanyId()
6316                                            };
6317    
6318                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
6319                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
6320                                            args);
6321    
6322                                    args = new Object[] {
6323                                                    dlFileShortcutModelImpl.getUuid(),
6324                                                    dlFileShortcutModelImpl.getCompanyId()
6325                                            };
6326    
6327                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
6328                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
6329                                            args);
6330                            }
6331    
6332                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
6333                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
6334                                    Object[] args = new Object[] {
6335                                                    dlFileShortcutModelImpl.getOriginalCompanyId()
6336                                            };
6337    
6338                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
6339                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
6340                                            args);
6341    
6342                                    args = new Object[] { dlFileShortcutModelImpl.getCompanyId() };
6343    
6344                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
6345                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
6346                                            args);
6347                            }
6348    
6349                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
6350                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID.getColumnBitmask()) != 0) {
6351                                    Object[] args = new Object[] {
6352                                                    dlFileShortcutModelImpl.getOriginalToFileEntryId()
6353                                            };
6354    
6355                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
6356                                            args);
6357                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID,
6358                                            args);
6359    
6360                                    args = new Object[] { dlFileShortcutModelImpl.getToFileEntryId() };
6361    
6362                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
6363                                            args);
6364                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID,
6365                                            args);
6366                            }
6367    
6368                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
6369                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
6370                                    Object[] args = new Object[] {
6371                                                    dlFileShortcutModelImpl.getOriginalGroupId(),
6372                                                    dlFileShortcutModelImpl.getOriginalFolderId()
6373                                            };
6374    
6375                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
6376                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
6377                                            args);
6378    
6379                                    args = new Object[] {
6380                                                    dlFileShortcutModelImpl.getGroupId(),
6381                                                    dlFileShortcutModelImpl.getFolderId()
6382                                            };
6383    
6384                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
6385                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
6386                                            args);
6387                            }
6388    
6389                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
6390                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A.getColumnBitmask()) != 0) {
6391                                    Object[] args = new Object[] {
6392                                                    dlFileShortcutModelImpl.getOriginalGroupId(),
6393                                                    dlFileShortcutModelImpl.getOriginalFolderId(),
6394                                                    dlFileShortcutModelImpl.getOriginalActive()
6395                                            };
6396    
6397                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_A, args);
6398                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A,
6399                                            args);
6400    
6401                                    args = new Object[] {
6402                                                    dlFileShortcutModelImpl.getGroupId(),
6403                                                    dlFileShortcutModelImpl.getFolderId(),
6404                                                    dlFileShortcutModelImpl.getActive()
6405                                            };
6406    
6407                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_A, args);
6408                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A,
6409                                            args);
6410                            }
6411    
6412                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
6413                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S.getColumnBitmask()) != 0) {
6414                                    Object[] args = new Object[] {
6415                                                    dlFileShortcutModelImpl.getOriginalGroupId(),
6416                                                    dlFileShortcutModelImpl.getOriginalFolderId(),
6417                                                    dlFileShortcutModelImpl.getOriginalActive(),
6418                                                    dlFileShortcutModelImpl.getOriginalStatus()
6419                                            };
6420    
6421                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_A_S, args);
6422                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S,
6423                                            args);
6424    
6425                                    args = new Object[] {
6426                                                    dlFileShortcutModelImpl.getGroupId(),
6427                                                    dlFileShortcutModelImpl.getFolderId(),
6428                                                    dlFileShortcutModelImpl.getActive(),
6429                                                    dlFileShortcutModelImpl.getStatus()
6430                                            };
6431    
6432                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F_A_S, args);
6433                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S,
6434                                            args);
6435                            }
6436                    }
6437    
6438                    entityCache.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6439                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
6440                            dlFileShortcut, false);
6441    
6442                    clearUniqueFindersCache(dlFileShortcutModelImpl);
6443                    cacheUniqueFindersCache(dlFileShortcutModelImpl, isNew);
6444    
6445                    dlFileShortcut.resetOriginalValues();
6446    
6447                    return dlFileShortcut;
6448            }
6449    
6450            protected DLFileShortcut toUnwrappedModel(DLFileShortcut dlFileShortcut) {
6451                    if (dlFileShortcut instanceof DLFileShortcutImpl) {
6452                            return dlFileShortcut;
6453                    }
6454    
6455                    DLFileShortcutImpl dlFileShortcutImpl = new DLFileShortcutImpl();
6456    
6457                    dlFileShortcutImpl.setNew(dlFileShortcut.isNew());
6458                    dlFileShortcutImpl.setPrimaryKey(dlFileShortcut.getPrimaryKey());
6459    
6460                    dlFileShortcutImpl.setUuid(dlFileShortcut.getUuid());
6461                    dlFileShortcutImpl.setFileShortcutId(dlFileShortcut.getFileShortcutId());
6462                    dlFileShortcutImpl.setGroupId(dlFileShortcut.getGroupId());
6463                    dlFileShortcutImpl.setCompanyId(dlFileShortcut.getCompanyId());
6464                    dlFileShortcutImpl.setUserId(dlFileShortcut.getUserId());
6465                    dlFileShortcutImpl.setUserName(dlFileShortcut.getUserName());
6466                    dlFileShortcutImpl.setCreateDate(dlFileShortcut.getCreateDate());
6467                    dlFileShortcutImpl.setModifiedDate(dlFileShortcut.getModifiedDate());
6468                    dlFileShortcutImpl.setRepositoryId(dlFileShortcut.getRepositoryId());
6469                    dlFileShortcutImpl.setFolderId(dlFileShortcut.getFolderId());
6470                    dlFileShortcutImpl.setToFileEntryId(dlFileShortcut.getToFileEntryId());
6471                    dlFileShortcutImpl.setTreePath(dlFileShortcut.getTreePath());
6472                    dlFileShortcutImpl.setActive(dlFileShortcut.isActive());
6473                    dlFileShortcutImpl.setLastPublishDate(dlFileShortcut.getLastPublishDate());
6474                    dlFileShortcutImpl.setStatus(dlFileShortcut.getStatus());
6475                    dlFileShortcutImpl.setStatusByUserId(dlFileShortcut.getStatusByUserId());
6476                    dlFileShortcutImpl.setStatusByUserName(dlFileShortcut.getStatusByUserName());
6477                    dlFileShortcutImpl.setStatusDate(dlFileShortcut.getStatusDate());
6478    
6479                    return dlFileShortcutImpl;
6480            }
6481    
6482            /**
6483             * Returns the document library file shortcut with the primary key or throws a {@link com.liferay.portal.exception.NoSuchModelException} if it could not be found.
6484             *
6485             * @param primaryKey the primary key of the document library file shortcut
6486             * @return the document library file shortcut
6487             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
6488             */
6489            @Override
6490            public DLFileShortcut findByPrimaryKey(Serializable primaryKey)
6491                    throws NoSuchFileShortcutException {
6492                    DLFileShortcut dlFileShortcut = fetchByPrimaryKey(primaryKey);
6493    
6494                    if (dlFileShortcut == null) {
6495                            if (_log.isWarnEnabled()) {
6496                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
6497                            }
6498    
6499                            throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
6500                                    primaryKey);
6501                    }
6502    
6503                    return dlFileShortcut;
6504            }
6505    
6506            /**
6507             * Returns the document library file shortcut with the primary key or throws a {@link NoSuchFileShortcutException} if it could not be found.
6508             *
6509             * @param fileShortcutId the primary key of the document library file shortcut
6510             * @return the document library file shortcut
6511             * @throws NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
6512             */
6513            @Override
6514            public DLFileShortcut findByPrimaryKey(long fileShortcutId)
6515                    throws NoSuchFileShortcutException {
6516                    return findByPrimaryKey((Serializable)fileShortcutId);
6517            }
6518    
6519            /**
6520             * Returns the document library file shortcut with the primary key or returns <code>null</code> if it could not be found.
6521             *
6522             * @param primaryKey the primary key of the document library file shortcut
6523             * @return the document library file shortcut, or <code>null</code> if a document library file shortcut with the primary key could not be found
6524             */
6525            @Override
6526            public DLFileShortcut fetchByPrimaryKey(Serializable primaryKey) {
6527                    DLFileShortcut dlFileShortcut = (DLFileShortcut)entityCache.getResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6528                                    DLFileShortcutImpl.class, primaryKey);
6529    
6530                    if (dlFileShortcut == _nullDLFileShortcut) {
6531                            return null;
6532                    }
6533    
6534                    if (dlFileShortcut == null) {
6535                            Session session = null;
6536    
6537                            try {
6538                                    session = openSession();
6539    
6540                                    dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
6541                                                    primaryKey);
6542    
6543                                    if (dlFileShortcut != null) {
6544                                            cacheResult(dlFileShortcut);
6545                                    }
6546                                    else {
6547                                            entityCache.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6548                                                    DLFileShortcutImpl.class, primaryKey,
6549                                                    _nullDLFileShortcut);
6550                                    }
6551                            }
6552                            catch (Exception e) {
6553                                    entityCache.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6554                                            DLFileShortcutImpl.class, primaryKey);
6555    
6556                                    throw processException(e);
6557                            }
6558                            finally {
6559                                    closeSession(session);
6560                            }
6561                    }
6562    
6563                    return dlFileShortcut;
6564            }
6565    
6566            /**
6567             * Returns the document library file shortcut with the primary key or returns <code>null</code> if it could not be found.
6568             *
6569             * @param fileShortcutId the primary key of the document library file shortcut
6570             * @return the document library file shortcut, or <code>null</code> if a document library file shortcut with the primary key could not be found
6571             */
6572            @Override
6573            public DLFileShortcut fetchByPrimaryKey(long fileShortcutId) {
6574                    return fetchByPrimaryKey((Serializable)fileShortcutId);
6575            }
6576    
6577            @Override
6578            public Map<Serializable, DLFileShortcut> fetchByPrimaryKeys(
6579                    Set<Serializable> primaryKeys) {
6580                    if (primaryKeys.isEmpty()) {
6581                            return Collections.emptyMap();
6582                    }
6583    
6584                    Map<Serializable, DLFileShortcut> map = new HashMap<Serializable, DLFileShortcut>();
6585    
6586                    if (primaryKeys.size() == 1) {
6587                            Iterator<Serializable> iterator = primaryKeys.iterator();
6588    
6589                            Serializable primaryKey = iterator.next();
6590    
6591                            DLFileShortcut dlFileShortcut = fetchByPrimaryKey(primaryKey);
6592    
6593                            if (dlFileShortcut != null) {
6594                                    map.put(primaryKey, dlFileShortcut);
6595                            }
6596    
6597                            return map;
6598                    }
6599    
6600                    Set<Serializable> uncachedPrimaryKeys = null;
6601    
6602                    for (Serializable primaryKey : primaryKeys) {
6603                            DLFileShortcut dlFileShortcut = (DLFileShortcut)entityCache.getResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6604                                            DLFileShortcutImpl.class, primaryKey);
6605    
6606                            if (dlFileShortcut == null) {
6607                                    if (uncachedPrimaryKeys == null) {
6608                                            uncachedPrimaryKeys = new HashSet<Serializable>();
6609                                    }
6610    
6611                                    uncachedPrimaryKeys.add(primaryKey);
6612                            }
6613                            else {
6614                                    map.put(primaryKey, dlFileShortcut);
6615                            }
6616                    }
6617    
6618                    if (uncachedPrimaryKeys == null) {
6619                            return map;
6620                    }
6621    
6622                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
6623                                    1);
6624    
6625                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE_PKS_IN);
6626    
6627                    for (Serializable primaryKey : uncachedPrimaryKeys) {
6628                            query.append(String.valueOf(primaryKey));
6629    
6630                            query.append(StringPool.COMMA);
6631                    }
6632    
6633                    query.setIndex(query.index() - 1);
6634    
6635                    query.append(StringPool.CLOSE_PARENTHESIS);
6636    
6637                    String sql = query.toString();
6638    
6639                    Session session = null;
6640    
6641                    try {
6642                            session = openSession();
6643    
6644                            Query q = session.createQuery(sql);
6645    
6646                            for (DLFileShortcut dlFileShortcut : (List<DLFileShortcut>)q.list()) {
6647                                    map.put(dlFileShortcut.getPrimaryKeyObj(), dlFileShortcut);
6648    
6649                                    cacheResult(dlFileShortcut);
6650    
6651                                    uncachedPrimaryKeys.remove(dlFileShortcut.getPrimaryKeyObj());
6652                            }
6653    
6654                            for (Serializable primaryKey : uncachedPrimaryKeys) {
6655                                    entityCache.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
6656                                            DLFileShortcutImpl.class, primaryKey, _nullDLFileShortcut);
6657                            }
6658                    }
6659                    catch (Exception e) {
6660                            throw processException(e);
6661                    }
6662                    finally {
6663                            closeSession(session);
6664                    }
6665    
6666                    return map;
6667            }
6668    
6669            /**
6670             * Returns all the document library file shortcuts.
6671             *
6672             * @return the document library file shortcuts
6673             */
6674            @Override
6675            public List<DLFileShortcut> findAll() {
6676                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6677            }
6678    
6679            /**
6680             * Returns a range of all the document library file shortcuts.
6681             *
6682             * <p>
6683             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6684             * </p>
6685             *
6686             * @param start the lower bound of the range of document library file shortcuts
6687             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
6688             * @return the range of document library file shortcuts
6689             */
6690            @Override
6691            public List<DLFileShortcut> findAll(int start, int end) {
6692                    return findAll(start, end, null);
6693            }
6694    
6695            /**
6696             * Returns an ordered range of all the document library file shortcuts.
6697             *
6698             * <p>
6699             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6700             * </p>
6701             *
6702             * @param start the lower bound of the range of document library file shortcuts
6703             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
6704             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6705             * @return the ordered range of document library file shortcuts
6706             */
6707            @Override
6708            public List<DLFileShortcut> findAll(int start, int end,
6709                    OrderByComparator<DLFileShortcut> orderByComparator) {
6710                    return findAll(start, end, orderByComparator, true);
6711            }
6712    
6713            /**
6714             * Returns an ordered range of all the document library file shortcuts.
6715             *
6716             * <p>
6717             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileShortcutModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6718             * </p>
6719             *
6720             * @param start the lower bound of the range of document library file shortcuts
6721             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
6722             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6723             * @param retrieveFromCache whether to retrieve from the finder cache
6724             * @return the ordered range of document library file shortcuts
6725             */
6726            @Override
6727            public List<DLFileShortcut> findAll(int start, int end,
6728                    OrderByComparator<DLFileShortcut> orderByComparator,
6729                    boolean retrieveFromCache) {
6730                    boolean pagination = true;
6731                    FinderPath finderPath = null;
6732                    Object[] finderArgs = null;
6733    
6734                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6735                                    (orderByComparator == null)) {
6736                            pagination = false;
6737                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
6738                            finderArgs = FINDER_ARGS_EMPTY;
6739                    }
6740                    else {
6741                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
6742                            finderArgs = new Object[] { start, end, orderByComparator };
6743                    }
6744    
6745                    List<DLFileShortcut> list = null;
6746    
6747                    if (retrieveFromCache) {
6748                            list = (List<DLFileShortcut>)finderCache.getResult(finderPath,
6749                                            finderArgs, this);
6750                    }
6751    
6752                    if (list == null) {
6753                            StringBundler query = null;
6754                            String sql = null;
6755    
6756                            if (orderByComparator != null) {
6757                                    query = new StringBundler(2 +
6758                                                    (orderByComparator.getOrderByFields().length * 3));
6759    
6760                                    query.append(_SQL_SELECT_DLFILESHORTCUT);
6761    
6762                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6763                                            orderByComparator);
6764    
6765                                    sql = query.toString();
6766                            }
6767                            else {
6768                                    sql = _SQL_SELECT_DLFILESHORTCUT;
6769    
6770                                    if (pagination) {
6771                                            sql = sql.concat(DLFileShortcutModelImpl.ORDER_BY_JPQL);
6772                                    }
6773                            }
6774    
6775                            Session session = null;
6776    
6777                            try {
6778                                    session = openSession();
6779    
6780                                    Query q = session.createQuery(sql);
6781    
6782                                    if (!pagination) {
6783                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
6784                                                            getDialect(), start, end, false);
6785    
6786                                            Collections.sort(list);
6787    
6788                                            list = Collections.unmodifiableList(list);
6789                                    }
6790                                    else {
6791                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
6792                                                            getDialect(), start, end);
6793                                    }
6794    
6795                                    cacheResult(list);
6796    
6797                                    finderCache.putResult(finderPath, finderArgs, list);
6798                            }
6799                            catch (Exception e) {
6800                                    finderCache.removeResult(finderPath, finderArgs);
6801    
6802                                    throw processException(e);
6803                            }
6804                            finally {
6805                                    closeSession(session);
6806                            }
6807                    }
6808    
6809                    return list;
6810            }
6811    
6812            /**
6813             * Removes all the document library file shortcuts from the database.
6814             *
6815             */
6816            @Override
6817            public void removeAll() {
6818                    for (DLFileShortcut dlFileShortcut : findAll()) {
6819                            remove(dlFileShortcut);
6820                    }
6821            }
6822    
6823            /**
6824             * Returns the number of document library file shortcuts.
6825             *
6826             * @return the number of document library file shortcuts
6827             */
6828            @Override
6829            public int countAll() {
6830                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
6831                                    FINDER_ARGS_EMPTY, this);
6832    
6833                    if (count == null) {
6834                            Session session = null;
6835    
6836                            try {
6837                                    session = openSession();
6838    
6839                                    Query q = session.createQuery(_SQL_COUNT_DLFILESHORTCUT);
6840    
6841                                    count = (Long)q.uniqueResult();
6842    
6843                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
6844                                            count);
6845                            }
6846                            catch (Exception e) {
6847                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
6848                                            FINDER_ARGS_EMPTY);
6849    
6850                                    throw processException(e);
6851                            }
6852                            finally {
6853                                    closeSession(session);
6854                            }
6855                    }
6856    
6857                    return count.intValue();
6858            }
6859    
6860            @Override
6861            public Set<String> getBadColumnNames() {
6862                    return _badColumnNames;
6863            }
6864    
6865            @Override
6866            protected Map<String, Integer> getTableColumnsMap() {
6867                    return DLFileShortcutModelImpl.TABLE_COLUMNS_MAP;
6868            }
6869    
6870            /**
6871             * Initializes the document library file shortcut persistence.
6872             */
6873            public void afterPropertiesSet() {
6874            }
6875    
6876            public void destroy() {
6877                    entityCache.removeCache(DLFileShortcutImpl.class.getName());
6878                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
6879                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6880                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6881            }
6882    
6883            @BeanReference(type = CompanyProviderWrapper.class)
6884            protected CompanyProvider companyProvider;
6885            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
6886            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
6887            private static final String _SQL_SELECT_DLFILESHORTCUT = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut";
6888            private static final String _SQL_SELECT_DLFILESHORTCUT_WHERE_PKS_IN = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE fileShortcutId IN (";
6889            private static final String _SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ";
6890            private static final String _SQL_COUNT_DLFILESHORTCUT = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut";
6891            private static final String _SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut WHERE ";
6892            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileShortcut.fileShortcutId";
6893            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT DISTINCT {dlFileShortcut.*} FROM DLFileShortcut dlFileShortcut WHERE ";
6894            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1 =
6895                    "SELECT {DLFileShortcut.*} FROM (SELECT DISTINCT dlFileShortcut.fileShortcutId FROM DLFileShortcut dlFileShortcut WHERE ";
6896            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2 =
6897                    ") TEMP_TABLE INNER JOIN DLFileShortcut ON TEMP_TABLE.fileShortcutId = DLFileShortcut.fileShortcutId";
6898            private static final String _FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(DISTINCT dlFileShortcut.fileShortcutId) AS COUNT_VALUE FROM DLFileShortcut dlFileShortcut WHERE ";
6899            private static final String _FILTER_ENTITY_ALIAS = "dlFileShortcut";
6900            private static final String _FILTER_ENTITY_TABLE = "DLFileShortcut";
6901            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileShortcut.";
6902            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileShortcut.";
6903            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileShortcut exists with the primary key ";
6904            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileShortcut exists with the key {";
6905            private static final Log _log = LogFactoryUtil.getLog(DLFileShortcutPersistenceImpl.class);
6906            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
6907                                    "uuid", "active"
6908                            });
6909            private static final DLFileShortcut _nullDLFileShortcut = new DLFileShortcutImpl() {
6910                            @Override
6911                            public Object clone() {
6912                                    return this;
6913                            }
6914    
6915                            @Override
6916                            public CacheModel<DLFileShortcut> toCacheModel() {
6917                                    return _nullDLFileShortcutCacheModel;
6918                            }
6919                    };
6920    
6921            private static final CacheModel<DLFileShortcut> _nullDLFileShortcutCacheModel =
6922                    new CacheModel<DLFileShortcut>() {
6923                            @Override
6924                            public DLFileShortcut toEntityModel() {
6925                                    return _nullDLFileShortcut;
6926                            }
6927                    };
6928    }