001    /**
002     * Copyright (c) 2000-2013 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;
016    
017    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.SQLQuery;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.GetterUtil;
030    import com.liferay.portal.kernel.util.InstanceFactory;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.SetUtil;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.UnmodifiableList;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.documentlibrary.NoSuchFileShortcutException;
045    import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
046    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutImpl;
047    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutModelImpl;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    import java.util.Set;
055    
056    /**
057     * The persistence implementation for the document library file shortcut service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see DLFileShortcutPersistence
065     * @see DLFileShortcutUtil
066     * @generated
067     */
068    public class DLFileShortcutPersistenceImpl extends BasePersistenceImpl<DLFileShortcut>
069            implements DLFileShortcutPersistence {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * 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.
074             */
075            public static final String FINDER_CLASS_NAME_ENTITY = DLFileShortcutImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List1";
078            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List2";
080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
081                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
082                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
083                            "findAll", new String[0]);
084            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
085                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
086                            DLFileShortcutImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
089                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
091            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
092                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
093                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
094                            "findByUuid",
095                            new String[] {
096                                    String.class.getName(),
097                                    
098                            Integer.class.getName(), Integer.class.getName(),
099                                    OrderByComparator.class.getName()
100                            });
101            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
102                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
103                            DLFileShortcutImpl.class,
104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
105                            new String[] { String.class.getName() },
106                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK);
107            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
108                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
110                            new String[] { String.class.getName() });
111    
112            /**
113             * Returns all the document library file shortcuts where uuid = &#63;.
114             *
115             * @param uuid the uuid
116             * @return the matching document library file shortcuts
117             * @throws SystemException if a system exception occurred
118             */
119            public List<DLFileShortcut> findByUuid(String uuid)
120                    throws SystemException {
121                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
122            }
123    
124            /**
125             * Returns a range of all the document library file shortcuts where uuid = &#63;.
126             *
127             * <p>
128             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
129             * </p>
130             *
131             * @param uuid the uuid
132             * @param start the lower bound of the range of document library file shortcuts
133             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
134             * @return the range of matching document library file shortcuts
135             * @throws SystemException if a system exception occurred
136             */
137            public List<DLFileShortcut> findByUuid(String uuid, int start, int end)
138                    throws SystemException {
139                    return findByUuid(uuid, start, end, null);
140            }
141    
142            /**
143             * Returns an ordered range of all the document library file shortcuts where uuid = &#63;.
144             *
145             * <p>
146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
147             * </p>
148             *
149             * @param uuid the uuid
150             * @param start the lower bound of the range of document library file shortcuts
151             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
152             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
153             * @return the ordered range of matching document library file shortcuts
154             * @throws SystemException if a system exception occurred
155             */
156            public List<DLFileShortcut> findByUuid(String uuid, int start, int end,
157                    OrderByComparator orderByComparator) throws SystemException {
158                    boolean pagination = true;
159                    FinderPath finderPath = null;
160                    Object[] finderArgs = null;
161    
162                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163                                    (orderByComparator == null)) {
164                            pagination = false;
165                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
166                            finderArgs = new Object[] { uuid };
167                    }
168                    else {
169                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
170                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
171                    }
172    
173                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
174                                    finderArgs, this);
175    
176                    if ((list != null) && !list.isEmpty()) {
177                            for (DLFileShortcut dlFileShortcut : list) {
178                                    if (!Validator.equals(uuid, dlFileShortcut.getUuid())) {
179                                            list = null;
180    
181                                            break;
182                                    }
183                            }
184                    }
185    
186                    if (list == null) {
187                            StringBundler query = null;
188    
189                            if (orderByComparator != null) {
190                                    query = new StringBundler(3 +
191                                                    (orderByComparator.getOrderByFields().length * 3));
192                            }
193                            else {
194                                    query = new StringBundler(3);
195                            }
196    
197                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
198    
199                            boolean bindUuid = false;
200    
201                            if (uuid == null) {
202                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
203                            }
204                            else if (uuid.equals(StringPool.BLANK)) {
205                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
206                            }
207                            else {
208                                    bindUuid = true;
209    
210                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
211                            }
212    
213                            if (orderByComparator != null) {
214                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
215                                            orderByComparator);
216                            }
217                            else
218                             if (pagination) {
219                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
220                            }
221    
222                            String sql = query.toString();
223    
224                            Session session = null;
225    
226                            try {
227                                    session = openSession();
228    
229                                    Query q = session.createQuery(sql);
230    
231                                    QueryPos qPos = QueryPos.getInstance(q);
232    
233                                    if (bindUuid) {
234                                            qPos.add(uuid);
235                                    }
236    
237                                    if (!pagination) {
238                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
239                                                            getDialect(), start, end, false);
240    
241                                            Collections.sort(list);
242    
243                                            list = new UnmodifiableList<DLFileShortcut>(list);
244                                    }
245                                    else {
246                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
247                                                            getDialect(), start, end);
248                                    }
249    
250                                    cacheResult(list);
251    
252                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
253                            }
254                            catch (Exception e) {
255                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
256    
257                                    throw processException(e);
258                            }
259                            finally {
260                                    closeSession(session);
261                            }
262                    }
263    
264                    return list;
265            }
266    
267            /**
268             * Returns the first document library file shortcut in the ordered set where uuid = &#63;.
269             *
270             * @param uuid the uuid
271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
272             * @return the first matching document library file shortcut
273             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
274             * @throws SystemException if a system exception occurred
275             */
276            public DLFileShortcut findByUuid_First(String uuid,
277                    OrderByComparator orderByComparator)
278                    throws NoSuchFileShortcutException, SystemException {
279                    DLFileShortcut dlFileShortcut = fetchByUuid_First(uuid,
280                                    orderByComparator);
281    
282                    if (dlFileShortcut != null) {
283                            return dlFileShortcut;
284                    }
285    
286                    StringBundler msg = new StringBundler(4);
287    
288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289    
290                    msg.append("uuid=");
291                    msg.append(uuid);
292    
293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
294    
295                    throw new NoSuchFileShortcutException(msg.toString());
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, or <code>null</code> if a matching document library file shortcut could not be found
304             * @throws SystemException if a system exception occurred
305             */
306            public DLFileShortcut fetchByUuid_First(String uuid,
307                    OrderByComparator orderByComparator) throws SystemException {
308                    List<DLFileShortcut> list = findByUuid(uuid, 0, 1, orderByComparator);
309    
310                    if (!list.isEmpty()) {
311                            return list.get(0);
312                    }
313    
314                    return null;
315            }
316    
317            /**
318             * Returns the last document library file shortcut in the ordered set where uuid = &#63;.
319             *
320             * @param uuid the uuid
321             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
322             * @return the last matching document library file shortcut
323             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
324             * @throws SystemException if a system exception occurred
325             */
326            public DLFileShortcut findByUuid_Last(String uuid,
327                    OrderByComparator orderByComparator)
328                    throws NoSuchFileShortcutException, SystemException {
329                    DLFileShortcut dlFileShortcut = fetchByUuid_Last(uuid, orderByComparator);
330    
331                    if (dlFileShortcut != null) {
332                            return dlFileShortcut;
333                    }
334    
335                    StringBundler msg = new StringBundler(4);
336    
337                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
338    
339                    msg.append("uuid=");
340                    msg.append(uuid);
341    
342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
343    
344                    throw new NoSuchFileShortcutException(msg.toString());
345            }
346    
347            /**
348             * Returns the last document library file shortcut in the ordered set where uuid = &#63;.
349             *
350             * @param uuid the uuid
351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
352             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
353             * @throws SystemException if a system exception occurred
354             */
355            public DLFileShortcut fetchByUuid_Last(String uuid,
356                    OrderByComparator orderByComparator) throws SystemException {
357                    int count = countByUuid(uuid);
358    
359                    List<DLFileShortcut> list = findByUuid(uuid, count - 1, count,
360                                    orderByComparator);
361    
362                    if (!list.isEmpty()) {
363                            return list.get(0);
364                    }
365    
366                    return null;
367            }
368    
369            /**
370             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where uuid = &#63;.
371             *
372             * @param fileShortcutId the primary key of the current document library file shortcut
373             * @param uuid the uuid
374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
375             * @return the previous, current, and next document library file shortcut
376             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
377             * @throws SystemException if a system exception occurred
378             */
379            public DLFileShortcut[] findByUuid_PrevAndNext(long fileShortcutId,
380                    String uuid, OrderByComparator orderByComparator)
381                    throws NoSuchFileShortcutException, SystemException {
382                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
383    
384                    Session session = null;
385    
386                    try {
387                            session = openSession();
388    
389                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
390    
391                            array[0] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
392                                            orderByComparator, true);
393    
394                            array[1] = dlFileShortcut;
395    
396                            array[2] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
397                                            orderByComparator, false);
398    
399                            return array;
400                    }
401                    catch (Exception e) {
402                            throw processException(e);
403                    }
404                    finally {
405                            closeSession(session);
406                    }
407            }
408    
409            protected DLFileShortcut getByUuid_PrevAndNext(Session session,
410                    DLFileShortcut dlFileShortcut, String uuid,
411                    OrderByComparator orderByComparator, boolean previous) {
412                    StringBundler query = null;
413    
414                    if (orderByComparator != null) {
415                            query = new StringBundler(6 +
416                                            (orderByComparator.getOrderByFields().length * 6));
417                    }
418                    else {
419                            query = new StringBundler(3);
420                    }
421    
422                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
423    
424                    boolean bindUuid = false;
425    
426                    if (uuid == null) {
427                            query.append(_FINDER_COLUMN_UUID_UUID_1);
428                    }
429                    else if (uuid.equals(StringPool.BLANK)) {
430                            query.append(_FINDER_COLUMN_UUID_UUID_3);
431                    }
432                    else {
433                            bindUuid = true;
434    
435                            query.append(_FINDER_COLUMN_UUID_UUID_2);
436                    }
437    
438                    if (orderByComparator != null) {
439                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
440    
441                            if (orderByConditionFields.length > 0) {
442                                    query.append(WHERE_AND);
443                            }
444    
445                            for (int i = 0; i < orderByConditionFields.length; i++) {
446                                    query.append(_ORDER_BY_ENTITY_ALIAS);
447                                    query.append(orderByConditionFields[i]);
448    
449                                    if ((i + 1) < orderByConditionFields.length) {
450                                            if (orderByComparator.isAscending() ^ previous) {
451                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
452                                            }
453                                            else {
454                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
455                                            }
456                                    }
457                                    else {
458                                            if (orderByComparator.isAscending() ^ previous) {
459                                                    query.append(WHERE_GREATER_THAN);
460                                            }
461                                            else {
462                                                    query.append(WHERE_LESSER_THAN);
463                                            }
464                                    }
465                            }
466    
467                            query.append(ORDER_BY_CLAUSE);
468    
469                            String[] orderByFields = orderByComparator.getOrderByFields();
470    
471                            for (int i = 0; i < orderByFields.length; i++) {
472                                    query.append(_ORDER_BY_ENTITY_ALIAS);
473                                    query.append(orderByFields[i]);
474    
475                                    if ((i + 1) < orderByFields.length) {
476                                            if (orderByComparator.isAscending() ^ previous) {
477                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
478                                            }
479                                            else {
480                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
481                                            }
482                                    }
483                                    else {
484                                            if (orderByComparator.isAscending() ^ previous) {
485                                                    query.append(ORDER_BY_ASC);
486                                            }
487                                            else {
488                                                    query.append(ORDER_BY_DESC);
489                                            }
490                                    }
491                            }
492                    }
493                    else {
494                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
495                    }
496    
497                    String sql = query.toString();
498    
499                    Query q = session.createQuery(sql);
500    
501                    q.setFirstResult(0);
502                    q.setMaxResults(2);
503    
504                    QueryPos qPos = QueryPos.getInstance(q);
505    
506                    if (bindUuid) {
507                            qPos.add(uuid);
508                    }
509    
510                    if (orderByComparator != null) {
511                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
512    
513                            for (Object value : values) {
514                                    qPos.add(value);
515                            }
516                    }
517    
518                    List<DLFileShortcut> list = q.list();
519    
520                    if (list.size() == 2) {
521                            return list.get(1);
522                    }
523                    else {
524                            return null;
525                    }
526            }
527    
528            /**
529             * Removes all the document library file shortcuts where uuid = &#63; from the database.
530             *
531             * @param uuid the uuid
532             * @throws SystemException if a system exception occurred
533             */
534            public void removeByUuid(String uuid) throws SystemException {
535                    for (DLFileShortcut dlFileShortcut : findByUuid(uuid,
536                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
537                            remove(dlFileShortcut);
538                    }
539            }
540    
541            /**
542             * Returns the number of document library file shortcuts where uuid = &#63;.
543             *
544             * @param uuid the uuid
545             * @return the number of matching document library file shortcuts
546             * @throws SystemException if a system exception occurred
547             */
548            public int countByUuid(String uuid) throws SystemException {
549                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
550    
551                    Object[] finderArgs = new Object[] { uuid };
552    
553                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
554                                    this);
555    
556                    if (count == null) {
557                            StringBundler query = new StringBundler(2);
558    
559                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
560    
561                            boolean bindUuid = false;
562    
563                            if (uuid == null) {
564                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
565                            }
566                            else if (uuid.equals(StringPool.BLANK)) {
567                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
568                            }
569                            else {
570                                    bindUuid = true;
571    
572                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
573                            }
574    
575                            String sql = query.toString();
576    
577                            Session session = null;
578    
579                            try {
580                                    session = openSession();
581    
582                                    Query q = session.createQuery(sql);
583    
584                                    QueryPos qPos = QueryPos.getInstance(q);
585    
586                                    if (bindUuid) {
587                                            qPos.add(uuid);
588                                    }
589    
590                                    count = (Long)q.uniqueResult();
591    
592                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
593                            }
594                            catch (Exception e) {
595                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
596    
597                                    throw processException(e);
598                            }
599                            finally {
600                                    closeSession(session);
601                            }
602                    }
603    
604                    return count.intValue();
605            }
606    
607            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileShortcut.uuid IS NULL";
608            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileShortcut.uuid = ?";
609            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = '')";
610            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
611                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
612                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_ENTITY,
613                            "fetchByUUID_G",
614                            new String[] { String.class.getName(), Long.class.getName() },
615                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK |
616                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK);
617            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
618                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
619                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
620                            new String[] { String.class.getName(), Long.class.getName() });
621    
622            /**
623             * Returns the document library file shortcut where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileShortcutException} if it could not be found.
624             *
625             * @param uuid the uuid
626             * @param groupId the group ID
627             * @return the matching document library file shortcut
628             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
629             * @throws SystemException if a system exception occurred
630             */
631            public DLFileShortcut findByUUID_G(String uuid, long groupId)
632                    throws NoSuchFileShortcutException, SystemException {
633                    DLFileShortcut dlFileShortcut = fetchByUUID_G(uuid, groupId);
634    
635                    if (dlFileShortcut == null) {
636                            StringBundler msg = new StringBundler(6);
637    
638                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
639    
640                            msg.append("uuid=");
641                            msg.append(uuid);
642    
643                            msg.append(", groupId=");
644                            msg.append(groupId);
645    
646                            msg.append(StringPool.CLOSE_CURLY_BRACE);
647    
648                            if (_log.isWarnEnabled()) {
649                                    _log.warn(msg.toString());
650                            }
651    
652                            throw new NoSuchFileShortcutException(msg.toString());
653                    }
654    
655                    return dlFileShortcut;
656            }
657    
658            /**
659             * 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.
660             *
661             * @param uuid the uuid
662             * @param groupId the group ID
663             * @return the matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
664             * @throws SystemException if a system exception occurred
665             */
666            public DLFileShortcut fetchByUUID_G(String uuid, long groupId)
667                    throws SystemException {
668                    return fetchByUUID_G(uuid, groupId, true);
669            }
670    
671            /**
672             * 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.
673             *
674             * @param uuid the uuid
675             * @param groupId the group ID
676             * @param retrieveFromCache whether to use the finder cache
677             * @return the matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
678             * @throws SystemException if a system exception occurred
679             */
680            public DLFileShortcut fetchByUUID_G(String uuid, long groupId,
681                    boolean retrieveFromCache) throws SystemException {
682                    Object[] finderArgs = new Object[] { uuid, groupId };
683    
684                    Object result = null;
685    
686                    if (retrieveFromCache) {
687                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
688                                            finderArgs, this);
689                    }
690    
691                    if (result instanceof DLFileShortcut) {
692                            DLFileShortcut dlFileShortcut = (DLFileShortcut)result;
693    
694                            if (!Validator.equals(uuid, dlFileShortcut.getUuid()) ||
695                                            (groupId != dlFileShortcut.getGroupId())) {
696                                    result = null;
697                            }
698                    }
699    
700                    if (result == null) {
701                            StringBundler query = new StringBundler(4);
702    
703                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
704    
705                            boolean bindUuid = false;
706    
707                            if (uuid == null) {
708                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
709                            }
710                            else if (uuid.equals(StringPool.BLANK)) {
711                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
712                            }
713                            else {
714                                    bindUuid = true;
715    
716                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
717                            }
718    
719                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
720    
721                            String sql = query.toString();
722    
723                            Session session = null;
724    
725                            try {
726                                    session = openSession();
727    
728                                    Query q = session.createQuery(sql);
729    
730                                    QueryPos qPos = QueryPos.getInstance(q);
731    
732                                    if (bindUuid) {
733                                            qPos.add(uuid);
734                                    }
735    
736                                    qPos.add(groupId);
737    
738                                    List<DLFileShortcut> list = q.list();
739    
740                                    if (list.isEmpty()) {
741                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
742                                                    finderArgs, list);
743                                    }
744                                    else {
745                                            DLFileShortcut dlFileShortcut = list.get(0);
746    
747                                            result = dlFileShortcut;
748    
749                                            cacheResult(dlFileShortcut);
750    
751                                            if ((dlFileShortcut.getUuid() == null) ||
752                                                            !dlFileShortcut.getUuid().equals(uuid) ||
753                                                            (dlFileShortcut.getGroupId() != groupId)) {
754                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
755                                                            finderArgs, dlFileShortcut);
756                                            }
757                                    }
758                            }
759                            catch (Exception e) {
760                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
761                                            finderArgs);
762    
763                                    throw processException(e);
764                            }
765                            finally {
766                                    closeSession(session);
767                            }
768                    }
769    
770                    if (result instanceof List<?>) {
771                            return null;
772                    }
773                    else {
774                            return (DLFileShortcut)result;
775                    }
776            }
777    
778            /**
779             * Removes the document library file shortcut where uuid = &#63; and groupId = &#63; from the database.
780             *
781             * @param uuid the uuid
782             * @param groupId the group ID
783             * @return the document library file shortcut that was removed
784             * @throws SystemException if a system exception occurred
785             */
786            public DLFileShortcut removeByUUID_G(String uuid, long groupId)
787                    throws NoSuchFileShortcutException, SystemException {
788                    DLFileShortcut dlFileShortcut = findByUUID_G(uuid, groupId);
789    
790                    return remove(dlFileShortcut);
791            }
792    
793            /**
794             * Returns the number of document library file shortcuts where uuid = &#63; and groupId = &#63;.
795             *
796             * @param uuid the uuid
797             * @param groupId the group ID
798             * @return the number of matching document library file shortcuts
799             * @throws SystemException if a system exception occurred
800             */
801            public int countByUUID_G(String uuid, long groupId)
802                    throws SystemException {
803                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
804    
805                    Object[] finderArgs = new Object[] { uuid, groupId };
806    
807                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
808                                    this);
809    
810                    if (count == null) {
811                            StringBundler query = new StringBundler(3);
812    
813                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
814    
815                            boolean bindUuid = false;
816    
817                            if (uuid == null) {
818                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
819                            }
820                            else if (uuid.equals(StringPool.BLANK)) {
821                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
822                            }
823                            else {
824                                    bindUuid = true;
825    
826                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
827                            }
828    
829                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
830    
831                            String sql = query.toString();
832    
833                            Session session = null;
834    
835                            try {
836                                    session = openSession();
837    
838                                    Query q = session.createQuery(sql);
839    
840                                    QueryPos qPos = QueryPos.getInstance(q);
841    
842                                    if (bindUuid) {
843                                            qPos.add(uuid);
844                                    }
845    
846                                    qPos.add(groupId);
847    
848                                    count = (Long)q.uniqueResult();
849    
850                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
851                            }
852                            catch (Exception e) {
853                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
854    
855                                    throw processException(e);
856                            }
857                            finally {
858                                    closeSession(session);
859                            }
860                    }
861    
862                    return count.intValue();
863            }
864    
865            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileShortcut.uuid IS NULL AND ";
866            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileShortcut.uuid = ? AND ";
867            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = '') AND ";
868            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileShortcut.groupId = ?";
869            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
870                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
871                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
872                            "findByUuid_C",
873                            new String[] {
874                                    String.class.getName(), Long.class.getName(),
875                                    
876                            Integer.class.getName(), Integer.class.getName(),
877                                    OrderByComparator.class.getName()
878                            });
879            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
880                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
881                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
882                            DLFileShortcutImpl.class,
883                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
884                            new String[] { String.class.getName(), Long.class.getName() },
885                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK |
886                            DLFileShortcutModelImpl.COMPANYID_COLUMN_BITMASK);
887            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
888                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
889                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
890                            new String[] { String.class.getName(), Long.class.getName() });
891    
892            /**
893             * Returns all the document library file shortcuts where uuid = &#63; and companyId = &#63;.
894             *
895             * @param uuid the uuid
896             * @param companyId the company ID
897             * @return the matching document library file shortcuts
898             * @throws SystemException if a system exception occurred
899             */
900            public List<DLFileShortcut> findByUuid_C(String uuid, long companyId)
901                    throws SystemException {
902                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
903                            QueryUtil.ALL_POS, null);
904            }
905    
906            /**
907             * Returns a range of all the document library file shortcuts where uuid = &#63; and companyId = &#63;.
908             *
909             * <p>
910             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
911             * </p>
912             *
913             * @param uuid the uuid
914             * @param companyId the company ID
915             * @param start the lower bound of the range of document library file shortcuts
916             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
917             * @return the range of matching document library file shortcuts
918             * @throws SystemException if a system exception occurred
919             */
920            public List<DLFileShortcut> findByUuid_C(String uuid, long companyId,
921                    int start, int end) throws SystemException {
922                    return findByUuid_C(uuid, companyId, start, end, null);
923            }
924    
925            /**
926             * Returns an ordered range of all the document library file shortcuts where uuid = &#63; and companyId = &#63;.
927             *
928             * <p>
929             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
930             * </p>
931             *
932             * @param uuid the uuid
933             * @param companyId the company ID
934             * @param start the lower bound of the range of document library file shortcuts
935             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
936             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
937             * @return the ordered range of matching document library file shortcuts
938             * @throws SystemException if a system exception occurred
939             */
940            public List<DLFileShortcut> findByUuid_C(String uuid, long companyId,
941                    int start, int end, OrderByComparator orderByComparator)
942                    throws SystemException {
943                    boolean pagination = true;
944                    FinderPath finderPath = null;
945                    Object[] finderArgs = null;
946    
947                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
948                                    (orderByComparator == null)) {
949                            pagination = false;
950                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
951                            finderArgs = new Object[] { uuid, companyId };
952                    }
953                    else {
954                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
955                            finderArgs = new Object[] {
956                                            uuid, companyId,
957                                            
958                                            start, end, orderByComparator
959                                    };
960                    }
961    
962                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
963                                    finderArgs, this);
964    
965                    if ((list != null) && !list.isEmpty()) {
966                            for (DLFileShortcut dlFileShortcut : list) {
967                                    if (!Validator.equals(uuid, dlFileShortcut.getUuid()) ||
968                                                    (companyId != dlFileShortcut.getCompanyId())) {
969                                            list = null;
970    
971                                            break;
972                                    }
973                            }
974                    }
975    
976                    if (list == null) {
977                            StringBundler query = null;
978    
979                            if (orderByComparator != null) {
980                                    query = new StringBundler(4 +
981                                                    (orderByComparator.getOrderByFields().length * 3));
982                            }
983                            else {
984                                    query = new StringBundler(4);
985                            }
986    
987                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
988    
989                            boolean bindUuid = false;
990    
991                            if (uuid == null) {
992                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
993                            }
994                            else if (uuid.equals(StringPool.BLANK)) {
995                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
996                            }
997                            else {
998                                    bindUuid = true;
999    
1000                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1001                            }
1002    
1003                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1004    
1005                            if (orderByComparator != null) {
1006                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1007                                            orderByComparator);
1008                            }
1009                            else
1010                             if (pagination) {
1011                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
1012                            }
1013    
1014                            String sql = query.toString();
1015    
1016                            Session session = null;
1017    
1018                            try {
1019                                    session = openSession();
1020    
1021                                    Query q = session.createQuery(sql);
1022    
1023                                    QueryPos qPos = QueryPos.getInstance(q);
1024    
1025                                    if (bindUuid) {
1026                                            qPos.add(uuid);
1027                                    }
1028    
1029                                    qPos.add(companyId);
1030    
1031                                    if (!pagination) {
1032                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
1033                                                            getDialect(), start, end, false);
1034    
1035                                            Collections.sort(list);
1036    
1037                                            list = new UnmodifiableList<DLFileShortcut>(list);
1038                                    }
1039                                    else {
1040                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
1041                                                            getDialect(), start, end);
1042                                    }
1043    
1044                                    cacheResult(list);
1045    
1046                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1047                            }
1048                            catch (Exception e) {
1049                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1050    
1051                                    throw processException(e);
1052                            }
1053                            finally {
1054                                    closeSession(session);
1055                            }
1056                    }
1057    
1058                    return list;
1059            }
1060    
1061            /**
1062             * Returns the first document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1063             *
1064             * @param uuid the uuid
1065             * @param companyId the company ID
1066             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1067             * @return the first matching document library file shortcut
1068             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1069             * @throws SystemException if a system exception occurred
1070             */
1071            public DLFileShortcut findByUuid_C_First(String uuid, long companyId,
1072                    OrderByComparator orderByComparator)
1073                    throws NoSuchFileShortcutException, SystemException {
1074                    DLFileShortcut dlFileShortcut = fetchByUuid_C_First(uuid, companyId,
1075                                    orderByComparator);
1076    
1077                    if (dlFileShortcut != null) {
1078                            return dlFileShortcut;
1079                    }
1080    
1081                    StringBundler msg = new StringBundler(6);
1082    
1083                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1084    
1085                    msg.append("uuid=");
1086                    msg.append(uuid);
1087    
1088                    msg.append(", companyId=");
1089                    msg.append(companyId);
1090    
1091                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1092    
1093                    throw new NoSuchFileShortcutException(msg.toString());
1094            }
1095    
1096            /**
1097             * Returns the first document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1098             *
1099             * @param uuid the uuid
1100             * @param companyId the company ID
1101             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1102             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1103             * @throws SystemException if a system exception occurred
1104             */
1105            public DLFileShortcut fetchByUuid_C_First(String uuid, long companyId,
1106                    OrderByComparator orderByComparator) throws SystemException {
1107                    List<DLFileShortcut> list = findByUuid_C(uuid, companyId, 0, 1,
1108                                    orderByComparator);
1109    
1110                    if (!list.isEmpty()) {
1111                            return list.get(0);
1112                    }
1113    
1114                    return null;
1115            }
1116    
1117            /**
1118             * Returns the last document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1119             *
1120             * @param uuid the uuid
1121             * @param companyId the company ID
1122             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1123             * @return the last matching document library file shortcut
1124             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1125             * @throws SystemException if a system exception occurred
1126             */
1127            public DLFileShortcut findByUuid_C_Last(String uuid, long companyId,
1128                    OrderByComparator orderByComparator)
1129                    throws NoSuchFileShortcutException, SystemException {
1130                    DLFileShortcut dlFileShortcut = fetchByUuid_C_Last(uuid, companyId,
1131                                    orderByComparator);
1132    
1133                    if (dlFileShortcut != null) {
1134                            return dlFileShortcut;
1135                    }
1136    
1137                    StringBundler msg = new StringBundler(6);
1138    
1139                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1140    
1141                    msg.append("uuid=");
1142                    msg.append(uuid);
1143    
1144                    msg.append(", companyId=");
1145                    msg.append(companyId);
1146    
1147                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1148    
1149                    throw new NoSuchFileShortcutException(msg.toString());
1150            }
1151    
1152            /**
1153             * Returns the last document library file shortcut in the ordered set where uuid = &#63; and companyId = &#63;.
1154             *
1155             * @param uuid the uuid
1156             * @param companyId the company ID
1157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1158             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1159             * @throws SystemException if a system exception occurred
1160             */
1161            public DLFileShortcut fetchByUuid_C_Last(String uuid, long companyId,
1162                    OrderByComparator orderByComparator) throws SystemException {
1163                    int count = countByUuid_C(uuid, companyId);
1164    
1165                    List<DLFileShortcut> list = findByUuid_C(uuid, companyId, count - 1,
1166                                    count, orderByComparator);
1167    
1168                    if (!list.isEmpty()) {
1169                            return list.get(0);
1170                    }
1171    
1172                    return null;
1173            }
1174    
1175            /**
1176             * 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;.
1177             *
1178             * @param fileShortcutId the primary key of the current document library file shortcut
1179             * @param uuid the uuid
1180             * @param companyId the company ID
1181             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1182             * @return the previous, current, and next document library file shortcut
1183             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
1184             * @throws SystemException if a system exception occurred
1185             */
1186            public DLFileShortcut[] findByUuid_C_PrevAndNext(long fileShortcutId,
1187                    String uuid, long companyId, OrderByComparator orderByComparator)
1188                    throws NoSuchFileShortcutException, SystemException {
1189                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1190    
1191                    Session session = null;
1192    
1193                    try {
1194                            session = openSession();
1195    
1196                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1197    
1198                            array[0] = getByUuid_C_PrevAndNext(session, dlFileShortcut, uuid,
1199                                            companyId, orderByComparator, true);
1200    
1201                            array[1] = dlFileShortcut;
1202    
1203                            array[2] = getByUuid_C_PrevAndNext(session, dlFileShortcut, uuid,
1204                                            companyId, orderByComparator, false);
1205    
1206                            return array;
1207                    }
1208                    catch (Exception e) {
1209                            throw processException(e);
1210                    }
1211                    finally {
1212                            closeSession(session);
1213                    }
1214            }
1215    
1216            protected DLFileShortcut getByUuid_C_PrevAndNext(Session session,
1217                    DLFileShortcut dlFileShortcut, String uuid, long companyId,
1218                    OrderByComparator orderByComparator, boolean previous) {
1219                    StringBundler query = null;
1220    
1221                    if (orderByComparator != null) {
1222                            query = new StringBundler(6 +
1223                                            (orderByComparator.getOrderByFields().length * 6));
1224                    }
1225                    else {
1226                            query = new StringBundler(3);
1227                    }
1228    
1229                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1230    
1231                    boolean bindUuid = false;
1232    
1233                    if (uuid == null) {
1234                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1235                    }
1236                    else if (uuid.equals(StringPool.BLANK)) {
1237                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1238                    }
1239                    else {
1240                            bindUuid = true;
1241    
1242                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1243                    }
1244    
1245                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1246    
1247                    if (orderByComparator != null) {
1248                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1249    
1250                            if (orderByConditionFields.length > 0) {
1251                                    query.append(WHERE_AND);
1252                            }
1253    
1254                            for (int i = 0; i < orderByConditionFields.length; i++) {
1255                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1256                                    query.append(orderByConditionFields[i]);
1257    
1258                                    if ((i + 1) < orderByConditionFields.length) {
1259                                            if (orderByComparator.isAscending() ^ previous) {
1260                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1261                                            }
1262                                            else {
1263                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1264                                            }
1265                                    }
1266                                    else {
1267                                            if (orderByComparator.isAscending() ^ previous) {
1268                                                    query.append(WHERE_GREATER_THAN);
1269                                            }
1270                                            else {
1271                                                    query.append(WHERE_LESSER_THAN);
1272                                            }
1273                                    }
1274                            }
1275    
1276                            query.append(ORDER_BY_CLAUSE);
1277    
1278                            String[] orderByFields = orderByComparator.getOrderByFields();
1279    
1280                            for (int i = 0; i < orderByFields.length; i++) {
1281                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1282                                    query.append(orderByFields[i]);
1283    
1284                                    if ((i + 1) < orderByFields.length) {
1285                                            if (orderByComparator.isAscending() ^ previous) {
1286                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1287                                            }
1288                                            else {
1289                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1290                                            }
1291                                    }
1292                                    else {
1293                                            if (orderByComparator.isAscending() ^ previous) {
1294                                                    query.append(ORDER_BY_ASC);
1295                                            }
1296                                            else {
1297                                                    query.append(ORDER_BY_DESC);
1298                                            }
1299                                    }
1300                            }
1301                    }
1302                    else {
1303                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
1304                    }
1305    
1306                    String sql = query.toString();
1307    
1308                    Query q = session.createQuery(sql);
1309    
1310                    q.setFirstResult(0);
1311                    q.setMaxResults(2);
1312    
1313                    QueryPos qPos = QueryPos.getInstance(q);
1314    
1315                    if (bindUuid) {
1316                            qPos.add(uuid);
1317                    }
1318    
1319                    qPos.add(companyId);
1320    
1321                    if (orderByComparator != null) {
1322                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1323    
1324                            for (Object value : values) {
1325                                    qPos.add(value);
1326                            }
1327                    }
1328    
1329                    List<DLFileShortcut> list = q.list();
1330    
1331                    if (list.size() == 2) {
1332                            return list.get(1);
1333                    }
1334                    else {
1335                            return null;
1336                    }
1337            }
1338    
1339            /**
1340             * Removes all the document library file shortcuts where uuid = &#63; and companyId = &#63; from the database.
1341             *
1342             * @param uuid the uuid
1343             * @param companyId the company ID
1344             * @throws SystemException if a system exception occurred
1345             */
1346            public void removeByUuid_C(String uuid, long companyId)
1347                    throws SystemException {
1348                    for (DLFileShortcut dlFileShortcut : findByUuid_C(uuid, companyId,
1349                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1350                            remove(dlFileShortcut);
1351                    }
1352            }
1353    
1354            /**
1355             * Returns the number of document library file shortcuts where uuid = &#63; and companyId = &#63;.
1356             *
1357             * @param uuid the uuid
1358             * @param companyId the company ID
1359             * @return the number of matching document library file shortcuts
1360             * @throws SystemException if a system exception occurred
1361             */
1362            public int countByUuid_C(String uuid, long companyId)
1363                    throws SystemException {
1364                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1365    
1366                    Object[] finderArgs = new Object[] { uuid, companyId };
1367    
1368                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1369                                    this);
1370    
1371                    if (count == null) {
1372                            StringBundler query = new StringBundler(3);
1373    
1374                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
1375    
1376                            boolean bindUuid = false;
1377    
1378                            if (uuid == null) {
1379                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1380                            }
1381                            else if (uuid.equals(StringPool.BLANK)) {
1382                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1383                            }
1384                            else {
1385                                    bindUuid = true;
1386    
1387                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1388                            }
1389    
1390                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1391    
1392                            String sql = query.toString();
1393    
1394                            Session session = null;
1395    
1396                            try {
1397                                    session = openSession();
1398    
1399                                    Query q = session.createQuery(sql);
1400    
1401                                    QueryPos qPos = QueryPos.getInstance(q);
1402    
1403                                    if (bindUuid) {
1404                                            qPos.add(uuid);
1405                                    }
1406    
1407                                    qPos.add(companyId);
1408    
1409                                    count = (Long)q.uniqueResult();
1410    
1411                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1412                            }
1413                            catch (Exception e) {
1414                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1415    
1416                                    throw processException(e);
1417                            }
1418                            finally {
1419                                    closeSession(session);
1420                            }
1421                    }
1422    
1423                    return count.intValue();
1424            }
1425    
1426            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "dlFileShortcut.uuid IS NULL AND ";
1427            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dlFileShortcut.uuid = ? AND ";
1428            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = '') AND ";
1429            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dlFileShortcut.companyId = ?";
1430            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TOFILEENTRYID =
1431                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1432                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
1433                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1434                            "findByToFileEntryId",
1435                            new String[] {
1436                                    Long.class.getName(),
1437                                    
1438                            Integer.class.getName(), Integer.class.getName(),
1439                                    OrderByComparator.class.getName()
1440                            });
1441            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID =
1442                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1443                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
1444                            DLFileShortcutImpl.class,
1445                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByToFileEntryId",
1446                            new String[] { Long.class.getName() },
1447                            DLFileShortcutModelImpl.TOFILEENTRYID_COLUMN_BITMASK);
1448            public static final FinderPath FINDER_PATH_COUNT_BY_TOFILEENTRYID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1449                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
1450                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByToFileEntryId",
1451                            new String[] { Long.class.getName() });
1452    
1453            /**
1454             * Returns all the document library file shortcuts where toFileEntryId = &#63;.
1455             *
1456             * @param toFileEntryId the to file entry ID
1457             * @return the matching document library file shortcuts
1458             * @throws SystemException if a system exception occurred
1459             */
1460            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId)
1461                    throws SystemException {
1462                    return findByToFileEntryId(toFileEntryId, QueryUtil.ALL_POS,
1463                            QueryUtil.ALL_POS, null);
1464            }
1465    
1466            /**
1467             * Returns a range of all the document library file shortcuts where toFileEntryId = &#63;.
1468             *
1469             * <p>
1470             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
1471             * </p>
1472             *
1473             * @param toFileEntryId the to file entry ID
1474             * @param start the lower bound of the range of document library file shortcuts
1475             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1476             * @return the range of matching document library file shortcuts
1477             * @throws SystemException if a system exception occurred
1478             */
1479            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
1480                    int start, int end) throws SystemException {
1481                    return findByToFileEntryId(toFileEntryId, start, end, null);
1482            }
1483    
1484            /**
1485             * Returns an ordered range of all the document library file shortcuts where toFileEntryId = &#63;.
1486             *
1487             * <p>
1488             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
1489             * </p>
1490             *
1491             * @param toFileEntryId the to file entry ID
1492             * @param start the lower bound of the range of document library file shortcuts
1493             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1494             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1495             * @return the ordered range of matching document library file shortcuts
1496             * @throws SystemException if a system exception occurred
1497             */
1498            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
1499                    int start, int end, OrderByComparator orderByComparator)
1500                    throws SystemException {
1501                    boolean pagination = true;
1502                    FinderPath finderPath = null;
1503                    Object[] finderArgs = null;
1504    
1505                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1506                                    (orderByComparator == null)) {
1507                            pagination = false;
1508                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID;
1509                            finderArgs = new Object[] { toFileEntryId };
1510                    }
1511                    else {
1512                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TOFILEENTRYID;
1513                            finderArgs = new Object[] {
1514                                            toFileEntryId,
1515                                            
1516                                            start, end, orderByComparator
1517                                    };
1518                    }
1519    
1520                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
1521                                    finderArgs, this);
1522    
1523                    if ((list != null) && !list.isEmpty()) {
1524                            for (DLFileShortcut dlFileShortcut : list) {
1525                                    if ((toFileEntryId != dlFileShortcut.getToFileEntryId())) {
1526                                            list = null;
1527    
1528                                            break;
1529                                    }
1530                            }
1531                    }
1532    
1533                    if (list == null) {
1534                            StringBundler query = null;
1535    
1536                            if (orderByComparator != null) {
1537                                    query = new StringBundler(3 +
1538                                                    (orderByComparator.getOrderByFields().length * 3));
1539                            }
1540                            else {
1541                                    query = new StringBundler(3);
1542                            }
1543    
1544                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1545    
1546                            query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
1547    
1548                            if (orderByComparator != null) {
1549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1550                                            orderByComparator);
1551                            }
1552                            else
1553                             if (pagination) {
1554                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
1555                            }
1556    
1557                            String sql = query.toString();
1558    
1559                            Session session = null;
1560    
1561                            try {
1562                                    session = openSession();
1563    
1564                                    Query q = session.createQuery(sql);
1565    
1566                                    QueryPos qPos = QueryPos.getInstance(q);
1567    
1568                                    qPos.add(toFileEntryId);
1569    
1570                                    if (!pagination) {
1571                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
1572                                                            getDialect(), start, end, false);
1573    
1574                                            Collections.sort(list);
1575    
1576                                            list = new UnmodifiableList<DLFileShortcut>(list);
1577                                    }
1578                                    else {
1579                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
1580                                                            getDialect(), start, end);
1581                                    }
1582    
1583                                    cacheResult(list);
1584    
1585                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1586                            }
1587                            catch (Exception e) {
1588                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1589    
1590                                    throw processException(e);
1591                            }
1592                            finally {
1593                                    closeSession(session);
1594                            }
1595                    }
1596    
1597                    return list;
1598            }
1599    
1600            /**
1601             * Returns the first document library file shortcut in the ordered set where toFileEntryId = &#63;.
1602             *
1603             * @param toFileEntryId the to file entry ID
1604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1605             * @return the first matching document library file shortcut
1606             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1607             * @throws SystemException if a system exception occurred
1608             */
1609            public DLFileShortcut findByToFileEntryId_First(long toFileEntryId,
1610                    OrderByComparator orderByComparator)
1611                    throws NoSuchFileShortcutException, SystemException {
1612                    DLFileShortcut dlFileShortcut = fetchByToFileEntryId_First(toFileEntryId,
1613                                    orderByComparator);
1614    
1615                    if (dlFileShortcut != null) {
1616                            return dlFileShortcut;
1617                    }
1618    
1619                    StringBundler msg = new StringBundler(4);
1620    
1621                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1622    
1623                    msg.append("toFileEntryId=");
1624                    msg.append(toFileEntryId);
1625    
1626                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1627    
1628                    throw new NoSuchFileShortcutException(msg.toString());
1629            }
1630    
1631            /**
1632             * Returns the first document library file shortcut in the ordered set where toFileEntryId = &#63;.
1633             *
1634             * @param toFileEntryId the to file entry ID
1635             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1636             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1637             * @throws SystemException if a system exception occurred
1638             */
1639            public DLFileShortcut fetchByToFileEntryId_First(long toFileEntryId,
1640                    OrderByComparator orderByComparator) throws SystemException {
1641                    List<DLFileShortcut> list = findByToFileEntryId(toFileEntryId, 0, 1,
1642                                    orderByComparator);
1643    
1644                    if (!list.isEmpty()) {
1645                            return list.get(0);
1646                    }
1647    
1648                    return null;
1649            }
1650    
1651            /**
1652             * Returns the last document library file shortcut in the ordered set where toFileEntryId = &#63;.
1653             *
1654             * @param toFileEntryId the to file entry ID
1655             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1656             * @return the last matching document library file shortcut
1657             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1658             * @throws SystemException if a system exception occurred
1659             */
1660            public DLFileShortcut findByToFileEntryId_Last(long toFileEntryId,
1661                    OrderByComparator orderByComparator)
1662                    throws NoSuchFileShortcutException, SystemException {
1663                    DLFileShortcut dlFileShortcut = fetchByToFileEntryId_Last(toFileEntryId,
1664                                    orderByComparator);
1665    
1666                    if (dlFileShortcut != null) {
1667                            return dlFileShortcut;
1668                    }
1669    
1670                    StringBundler msg = new StringBundler(4);
1671    
1672                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1673    
1674                    msg.append("toFileEntryId=");
1675                    msg.append(toFileEntryId);
1676    
1677                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1678    
1679                    throw new NoSuchFileShortcutException(msg.toString());
1680            }
1681    
1682            /**
1683             * Returns the last document library file shortcut in the ordered set where toFileEntryId = &#63;.
1684             *
1685             * @param toFileEntryId the to file entry ID
1686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1687             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1688             * @throws SystemException if a system exception occurred
1689             */
1690            public DLFileShortcut fetchByToFileEntryId_Last(long toFileEntryId,
1691                    OrderByComparator orderByComparator) throws SystemException {
1692                    int count = countByToFileEntryId(toFileEntryId);
1693    
1694                    List<DLFileShortcut> list = findByToFileEntryId(toFileEntryId,
1695                                    count - 1, count, orderByComparator);
1696    
1697                    if (!list.isEmpty()) {
1698                            return list.get(0);
1699                    }
1700    
1701                    return null;
1702            }
1703    
1704            /**
1705             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where toFileEntryId = &#63;.
1706             *
1707             * @param fileShortcutId the primary key of the current document library file shortcut
1708             * @param toFileEntryId the to file entry ID
1709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1710             * @return the previous, current, and next document library file shortcut
1711             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
1712             * @throws SystemException if a system exception occurred
1713             */
1714            public DLFileShortcut[] findByToFileEntryId_PrevAndNext(
1715                    long fileShortcutId, long toFileEntryId,
1716                    OrderByComparator orderByComparator)
1717                    throws NoSuchFileShortcutException, SystemException {
1718                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1719    
1720                    Session session = null;
1721    
1722                    try {
1723                            session = openSession();
1724    
1725                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1726    
1727                            array[0] = getByToFileEntryId_PrevAndNext(session, dlFileShortcut,
1728                                            toFileEntryId, orderByComparator, true);
1729    
1730                            array[1] = dlFileShortcut;
1731    
1732                            array[2] = getByToFileEntryId_PrevAndNext(session, dlFileShortcut,
1733                                            toFileEntryId, orderByComparator, false);
1734    
1735                            return array;
1736                    }
1737                    catch (Exception e) {
1738                            throw processException(e);
1739                    }
1740                    finally {
1741                            closeSession(session);
1742                    }
1743            }
1744    
1745            protected DLFileShortcut getByToFileEntryId_PrevAndNext(Session session,
1746                    DLFileShortcut dlFileShortcut, long toFileEntryId,
1747                    OrderByComparator orderByComparator, boolean previous) {
1748                    StringBundler query = null;
1749    
1750                    if (orderByComparator != null) {
1751                            query = new StringBundler(6 +
1752                                            (orderByComparator.getOrderByFields().length * 6));
1753                    }
1754                    else {
1755                            query = new StringBundler(3);
1756                    }
1757    
1758                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1759    
1760                    query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
1761    
1762                    if (orderByComparator != null) {
1763                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1764    
1765                            if (orderByConditionFields.length > 0) {
1766                                    query.append(WHERE_AND);
1767                            }
1768    
1769                            for (int i = 0; i < orderByConditionFields.length; i++) {
1770                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1771                                    query.append(orderByConditionFields[i]);
1772    
1773                                    if ((i + 1) < orderByConditionFields.length) {
1774                                            if (orderByComparator.isAscending() ^ previous) {
1775                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1776                                            }
1777                                            else {
1778                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1779                                            }
1780                                    }
1781                                    else {
1782                                            if (orderByComparator.isAscending() ^ previous) {
1783                                                    query.append(WHERE_GREATER_THAN);
1784                                            }
1785                                            else {
1786                                                    query.append(WHERE_LESSER_THAN);
1787                                            }
1788                                    }
1789                            }
1790    
1791                            query.append(ORDER_BY_CLAUSE);
1792    
1793                            String[] orderByFields = orderByComparator.getOrderByFields();
1794    
1795                            for (int i = 0; i < orderByFields.length; i++) {
1796                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1797                                    query.append(orderByFields[i]);
1798    
1799                                    if ((i + 1) < orderByFields.length) {
1800                                            if (orderByComparator.isAscending() ^ previous) {
1801                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1802                                            }
1803                                            else {
1804                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1805                                            }
1806                                    }
1807                                    else {
1808                                            if (orderByComparator.isAscending() ^ previous) {
1809                                                    query.append(ORDER_BY_ASC);
1810                                            }
1811                                            else {
1812                                                    query.append(ORDER_BY_DESC);
1813                                            }
1814                                    }
1815                            }
1816                    }
1817                    else {
1818                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
1819                    }
1820    
1821                    String sql = query.toString();
1822    
1823                    Query q = session.createQuery(sql);
1824    
1825                    q.setFirstResult(0);
1826                    q.setMaxResults(2);
1827    
1828                    QueryPos qPos = QueryPos.getInstance(q);
1829    
1830                    qPos.add(toFileEntryId);
1831    
1832                    if (orderByComparator != null) {
1833                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1834    
1835                            for (Object value : values) {
1836                                    qPos.add(value);
1837                            }
1838                    }
1839    
1840                    List<DLFileShortcut> list = q.list();
1841    
1842                    if (list.size() == 2) {
1843                            return list.get(1);
1844                    }
1845                    else {
1846                            return null;
1847                    }
1848            }
1849    
1850            /**
1851             * Removes all the document library file shortcuts where toFileEntryId = &#63; from the database.
1852             *
1853             * @param toFileEntryId the to file entry ID
1854             * @throws SystemException if a system exception occurred
1855             */
1856            public void removeByToFileEntryId(long toFileEntryId)
1857                    throws SystemException {
1858                    for (DLFileShortcut dlFileShortcut : findByToFileEntryId(
1859                                    toFileEntryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1860                            remove(dlFileShortcut);
1861                    }
1862            }
1863    
1864            /**
1865             * Returns the number of document library file shortcuts where toFileEntryId = &#63;.
1866             *
1867             * @param toFileEntryId the to file entry ID
1868             * @return the number of matching document library file shortcuts
1869             * @throws SystemException if a system exception occurred
1870             */
1871            public int countByToFileEntryId(long toFileEntryId)
1872                    throws SystemException {
1873                    FinderPath finderPath = FINDER_PATH_COUNT_BY_TOFILEENTRYID;
1874    
1875                    Object[] finderArgs = new Object[] { toFileEntryId };
1876    
1877                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1878                                    this);
1879    
1880                    if (count == null) {
1881                            StringBundler query = new StringBundler(2);
1882    
1883                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
1884    
1885                            query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
1886    
1887                            String sql = query.toString();
1888    
1889                            Session session = null;
1890    
1891                            try {
1892                                    session = openSession();
1893    
1894                                    Query q = session.createQuery(sql);
1895    
1896                                    QueryPos qPos = QueryPos.getInstance(q);
1897    
1898                                    qPos.add(toFileEntryId);
1899    
1900                                    count = (Long)q.uniqueResult();
1901    
1902                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1903                            }
1904                            catch (Exception e) {
1905                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1906    
1907                                    throw processException(e);
1908                            }
1909                            finally {
1910                                    closeSession(session);
1911                            }
1912                    }
1913    
1914                    return count.intValue();
1915            }
1916    
1917            private static final String _FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2 = "dlFileShortcut.toFileEntryId = ?";
1918            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1919                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
1920                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1921                            "findByG_F",
1922                            new String[] {
1923                                    Long.class.getName(), Long.class.getName(),
1924                                    
1925                            Integer.class.getName(), Integer.class.getName(),
1926                                    OrderByComparator.class.getName()
1927                            });
1928            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1929                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
1930                            DLFileShortcutImpl.class,
1931                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
1932                            new String[] { Long.class.getName(), Long.class.getName() },
1933                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
1934                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK);
1935            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
1936                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
1937                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
1938                            new String[] { Long.class.getName(), Long.class.getName() });
1939    
1940            /**
1941             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1942             *
1943             * @param groupId the group ID
1944             * @param folderId the folder ID
1945             * @return the matching document library file shortcuts
1946             * @throws SystemException if a system exception occurred
1947             */
1948            public List<DLFileShortcut> findByG_F(long groupId, long folderId)
1949                    throws SystemException {
1950                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
1951                            QueryUtil.ALL_POS, null);
1952            }
1953    
1954            /**
1955             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1956             *
1957             * <p>
1958             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
1959             * </p>
1960             *
1961             * @param groupId the group ID
1962             * @param folderId the folder ID
1963             * @param start the lower bound of the range of document library file shortcuts
1964             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1965             * @return the range of matching document library file shortcuts
1966             * @throws SystemException if a system exception occurred
1967             */
1968            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
1969                    int start, int end) throws SystemException {
1970                    return findByG_F(groupId, folderId, start, end, null);
1971            }
1972    
1973            /**
1974             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1975             *
1976             * <p>
1977             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
1978             * </p>
1979             *
1980             * @param groupId the group ID
1981             * @param folderId the folder ID
1982             * @param start the lower bound of the range of document library file shortcuts
1983             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1984             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1985             * @return the ordered range of matching document library file shortcuts
1986             * @throws SystemException if a system exception occurred
1987             */
1988            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
1989                    int start, int end, OrderByComparator orderByComparator)
1990                    throws SystemException {
1991                    boolean pagination = true;
1992                    FinderPath finderPath = null;
1993                    Object[] finderArgs = null;
1994    
1995                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1996                                    (orderByComparator == null)) {
1997                            pagination = false;
1998                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
1999                            finderArgs = new Object[] { groupId, folderId };
2000                    }
2001                    else {
2002                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
2003                            finderArgs = new Object[] {
2004                                            groupId, folderId,
2005                                            
2006                                            start, end, orderByComparator
2007                                    };
2008                    }
2009    
2010                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
2011                                    finderArgs, this);
2012    
2013                    if ((list != null) && !list.isEmpty()) {
2014                            for (DLFileShortcut dlFileShortcut : list) {
2015                                    if ((groupId != dlFileShortcut.getGroupId()) ||
2016                                                    (folderId != dlFileShortcut.getFolderId())) {
2017                                            list = null;
2018    
2019                                            break;
2020                                    }
2021                            }
2022                    }
2023    
2024                    if (list == null) {
2025                            StringBundler query = null;
2026    
2027                            if (orderByComparator != null) {
2028                                    query = new StringBundler(4 +
2029                                                    (orderByComparator.getOrderByFields().length * 3));
2030                            }
2031                            else {
2032                                    query = new StringBundler(4);
2033                            }
2034    
2035                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2036    
2037                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2038    
2039                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2040    
2041                            if (orderByComparator != null) {
2042                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2043                                            orderByComparator);
2044                            }
2045                            else
2046                             if (pagination) {
2047                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2048                            }
2049    
2050                            String sql = query.toString();
2051    
2052                            Session session = null;
2053    
2054                            try {
2055                                    session = openSession();
2056    
2057                                    Query q = session.createQuery(sql);
2058    
2059                                    QueryPos qPos = QueryPos.getInstance(q);
2060    
2061                                    qPos.add(groupId);
2062    
2063                                    qPos.add(folderId);
2064    
2065                                    if (!pagination) {
2066                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2067                                                            getDialect(), start, end, false);
2068    
2069                                            Collections.sort(list);
2070    
2071                                            list = new UnmodifiableList<DLFileShortcut>(list);
2072                                    }
2073                                    else {
2074                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2075                                                            getDialect(), start, end);
2076                                    }
2077    
2078                                    cacheResult(list);
2079    
2080                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2081                            }
2082                            catch (Exception e) {
2083                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2084    
2085                                    throw processException(e);
2086                            }
2087                            finally {
2088                                    closeSession(session);
2089                            }
2090                    }
2091    
2092                    return list;
2093            }
2094    
2095            /**
2096             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2097             *
2098             * @param groupId the group ID
2099             * @param folderId the folder ID
2100             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2101             * @return the first matching document library file shortcut
2102             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
2103             * @throws SystemException if a system exception occurred
2104             */
2105            public DLFileShortcut findByG_F_First(long groupId, long folderId,
2106                    OrderByComparator orderByComparator)
2107                    throws NoSuchFileShortcutException, SystemException {
2108                    DLFileShortcut dlFileShortcut = fetchByG_F_First(groupId, folderId,
2109                                    orderByComparator);
2110    
2111                    if (dlFileShortcut != null) {
2112                            return dlFileShortcut;
2113                    }
2114    
2115                    StringBundler msg = new StringBundler(6);
2116    
2117                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2118    
2119                    msg.append("groupId=");
2120                    msg.append(groupId);
2121    
2122                    msg.append(", folderId=");
2123                    msg.append(folderId);
2124    
2125                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2126    
2127                    throw new NoSuchFileShortcutException(msg.toString());
2128            }
2129    
2130            /**
2131             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2132             *
2133             * @param groupId the group ID
2134             * @param folderId the folder ID
2135             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2136             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
2137             * @throws SystemException if a system exception occurred
2138             */
2139            public DLFileShortcut fetchByG_F_First(long groupId, long folderId,
2140                    OrderByComparator orderByComparator) throws SystemException {
2141                    List<DLFileShortcut> list = findByG_F(groupId, folderId, 0, 1,
2142                                    orderByComparator);
2143    
2144                    if (!list.isEmpty()) {
2145                            return list.get(0);
2146                    }
2147    
2148                    return null;
2149            }
2150    
2151            /**
2152             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2153             *
2154             * @param groupId the group ID
2155             * @param folderId the folder ID
2156             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2157             * @return the last matching document library file shortcut
2158             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
2159             * @throws SystemException if a system exception occurred
2160             */
2161            public DLFileShortcut findByG_F_Last(long groupId, long folderId,
2162                    OrderByComparator orderByComparator)
2163                    throws NoSuchFileShortcutException, SystemException {
2164                    DLFileShortcut dlFileShortcut = fetchByG_F_Last(groupId, folderId,
2165                                    orderByComparator);
2166    
2167                    if (dlFileShortcut != null) {
2168                            return dlFileShortcut;
2169                    }
2170    
2171                    StringBundler msg = new StringBundler(6);
2172    
2173                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2174    
2175                    msg.append("groupId=");
2176                    msg.append(groupId);
2177    
2178                    msg.append(", folderId=");
2179                    msg.append(folderId);
2180    
2181                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2182    
2183                    throw new NoSuchFileShortcutException(msg.toString());
2184            }
2185    
2186            /**
2187             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
2188             *
2189             * @param groupId the group ID
2190             * @param folderId the folder ID
2191             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2192             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
2193             * @throws SystemException if a system exception occurred
2194             */
2195            public DLFileShortcut fetchByG_F_Last(long groupId, long folderId,
2196                    OrderByComparator orderByComparator) throws SystemException {
2197                    int count = countByG_F(groupId, folderId);
2198    
2199                    List<DLFileShortcut> list = findByG_F(groupId, folderId, count - 1,
2200                                    count, orderByComparator);
2201    
2202                    if (!list.isEmpty()) {
2203                            return list.get(0);
2204                    }
2205    
2206                    return null;
2207            }
2208    
2209            /**
2210             * 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;.
2211             *
2212             * @param fileShortcutId the primary key of the current document library file shortcut
2213             * @param groupId the group ID
2214             * @param folderId the folder ID
2215             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2216             * @return the previous, current, and next document library file shortcut
2217             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2218             * @throws SystemException if a system exception occurred
2219             */
2220            public DLFileShortcut[] findByG_F_PrevAndNext(long fileShortcutId,
2221                    long groupId, long folderId, OrderByComparator orderByComparator)
2222                    throws NoSuchFileShortcutException, SystemException {
2223                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2224    
2225                    Session session = null;
2226    
2227                    try {
2228                            session = openSession();
2229    
2230                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2231    
2232                            array[0] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
2233                                            folderId, orderByComparator, true);
2234    
2235                            array[1] = dlFileShortcut;
2236    
2237                            array[2] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
2238                                            folderId, orderByComparator, false);
2239    
2240                            return array;
2241                    }
2242                    catch (Exception e) {
2243                            throw processException(e);
2244                    }
2245                    finally {
2246                            closeSession(session);
2247                    }
2248            }
2249    
2250            protected DLFileShortcut getByG_F_PrevAndNext(Session session,
2251                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
2252                    OrderByComparator orderByComparator, boolean previous) {
2253                    StringBundler query = null;
2254    
2255                    if (orderByComparator != null) {
2256                            query = new StringBundler(6 +
2257                                            (orderByComparator.getOrderByFields().length * 6));
2258                    }
2259                    else {
2260                            query = new StringBundler(3);
2261                    }
2262    
2263                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2264    
2265                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2266    
2267                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2268    
2269                    if (orderByComparator != null) {
2270                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2271    
2272                            if (orderByConditionFields.length > 0) {
2273                                    query.append(WHERE_AND);
2274                            }
2275    
2276                            for (int i = 0; i < orderByConditionFields.length; i++) {
2277                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2278                                    query.append(orderByConditionFields[i]);
2279    
2280                                    if ((i + 1) < orderByConditionFields.length) {
2281                                            if (orderByComparator.isAscending() ^ previous) {
2282                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2283                                            }
2284                                            else {
2285                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2286                                            }
2287                                    }
2288                                    else {
2289                                            if (orderByComparator.isAscending() ^ previous) {
2290                                                    query.append(WHERE_GREATER_THAN);
2291                                            }
2292                                            else {
2293                                                    query.append(WHERE_LESSER_THAN);
2294                                            }
2295                                    }
2296                            }
2297    
2298                            query.append(ORDER_BY_CLAUSE);
2299    
2300                            String[] orderByFields = orderByComparator.getOrderByFields();
2301    
2302                            for (int i = 0; i < orderByFields.length; i++) {
2303                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2304                                    query.append(orderByFields[i]);
2305    
2306                                    if ((i + 1) < orderByFields.length) {
2307                                            if (orderByComparator.isAscending() ^ previous) {
2308                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2309                                            }
2310                                            else {
2311                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2312                                            }
2313                                    }
2314                                    else {
2315                                            if (orderByComparator.isAscending() ^ previous) {
2316                                                    query.append(ORDER_BY_ASC);
2317                                            }
2318                                            else {
2319                                                    query.append(ORDER_BY_DESC);
2320                                            }
2321                                    }
2322                            }
2323                    }
2324                    else {
2325                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2326                    }
2327    
2328                    String sql = query.toString();
2329    
2330                    Query q = session.createQuery(sql);
2331    
2332                    q.setFirstResult(0);
2333                    q.setMaxResults(2);
2334    
2335                    QueryPos qPos = QueryPos.getInstance(q);
2336    
2337                    qPos.add(groupId);
2338    
2339                    qPos.add(folderId);
2340    
2341                    if (orderByComparator != null) {
2342                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2343    
2344                            for (Object value : values) {
2345                                    qPos.add(value);
2346                            }
2347                    }
2348    
2349                    List<DLFileShortcut> list = q.list();
2350    
2351                    if (list.size() == 2) {
2352                            return list.get(1);
2353                    }
2354                    else {
2355                            return null;
2356                    }
2357            }
2358    
2359            /**
2360             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
2361             *
2362             * @param groupId the group ID
2363             * @param folderId the folder ID
2364             * @return the matching document library file shortcuts that the user has permission to view
2365             * @throws SystemException if a system exception occurred
2366             */
2367            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId)
2368                    throws SystemException {
2369                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
2370                            QueryUtil.ALL_POS, null);
2371            }
2372    
2373            /**
2374             * Returns a range of all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
2375             *
2376             * <p>
2377             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
2378             * </p>
2379             *
2380             * @param groupId the group ID
2381             * @param folderId the folder ID
2382             * @param start the lower bound of the range of document library file shortcuts
2383             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2384             * @return the range of matching document library file shortcuts that the user has permission to view
2385             * @throws SystemException if a system exception occurred
2386             */
2387            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
2388                    int start, int end) throws SystemException {
2389                    return filterFindByG_F(groupId, folderId, start, end, null);
2390            }
2391    
2392            /**
2393             * Returns an ordered range of all the document library file shortcuts that the user has permissions to view where groupId = &#63; and folderId = &#63;.
2394             *
2395             * <p>
2396             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
2397             * </p>
2398             *
2399             * @param groupId the group ID
2400             * @param folderId the folder ID
2401             * @param start the lower bound of the range of document library file shortcuts
2402             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2403             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2404             * @return the ordered range of matching document library file shortcuts that the user has permission to view
2405             * @throws SystemException if a system exception occurred
2406             */
2407            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
2408                    int start, int end, OrderByComparator orderByComparator)
2409                    throws SystemException {
2410                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2411                            return findByG_F(groupId, folderId, start, end, orderByComparator);
2412                    }
2413    
2414                    StringBundler query = null;
2415    
2416                    if (orderByComparator != null) {
2417                            query = new StringBundler(4 +
2418                                            (orderByComparator.getOrderByFields().length * 3));
2419                    }
2420                    else {
2421                            query = new StringBundler(4);
2422                    }
2423    
2424                    if (getDB().isSupportsInlineDistinct()) {
2425                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2426                    }
2427                    else {
2428                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
2429                    }
2430    
2431                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2432    
2433                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2434    
2435                    if (!getDB().isSupportsInlineDistinct()) {
2436                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
2437                    }
2438    
2439                    if (orderByComparator != null) {
2440                            if (getDB().isSupportsInlineDistinct()) {
2441                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2442                                            orderByComparator, true);
2443                            }
2444                            else {
2445                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2446                                            orderByComparator, true);
2447                            }
2448                    }
2449                    else {
2450                            if (getDB().isSupportsInlineDistinct()) {
2451                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2452                            }
2453                            else {
2454                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
2455                            }
2456                    }
2457    
2458                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2459                                    DLFileShortcut.class.getName(),
2460                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2461    
2462                    Session session = null;
2463    
2464                    try {
2465                            session = openSession();
2466    
2467                            SQLQuery q = session.createSQLQuery(sql);
2468    
2469                            if (getDB().isSupportsInlineDistinct()) {
2470                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2471                            }
2472                            else {
2473                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2474                            }
2475    
2476                            QueryPos qPos = QueryPos.getInstance(q);
2477    
2478                            qPos.add(groupId);
2479    
2480                            qPos.add(folderId);
2481    
2482                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
2483                                    end);
2484                    }
2485                    catch (Exception e) {
2486                            throw processException(e);
2487                    }
2488                    finally {
2489                            closeSession(session);
2490                    }
2491            }
2492    
2493            /**
2494             * 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;.
2495             *
2496             * @param fileShortcutId the primary key of the current document library file shortcut
2497             * @param groupId the group ID
2498             * @param folderId the folder ID
2499             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2500             * @return the previous, current, and next document library file shortcut
2501             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2502             * @throws SystemException if a system exception occurred
2503             */
2504            public DLFileShortcut[] filterFindByG_F_PrevAndNext(long fileShortcutId,
2505                    long groupId, long folderId, OrderByComparator orderByComparator)
2506                    throws NoSuchFileShortcutException, SystemException {
2507                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2508                            return findByG_F_PrevAndNext(fileShortcutId, groupId, folderId,
2509                                    orderByComparator);
2510                    }
2511    
2512                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2513    
2514                    Session session = null;
2515    
2516                    try {
2517                            session = openSession();
2518    
2519                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2520    
2521                            array[0] = filterGetByG_F_PrevAndNext(session, dlFileShortcut,
2522                                            groupId, folderId, orderByComparator, true);
2523    
2524                            array[1] = dlFileShortcut;
2525    
2526                            array[2] = filterGetByG_F_PrevAndNext(session, dlFileShortcut,
2527                                            groupId, folderId, orderByComparator, false);
2528    
2529                            return array;
2530                    }
2531                    catch (Exception e) {
2532                            throw processException(e);
2533                    }
2534                    finally {
2535                            closeSession(session);
2536                    }
2537            }
2538    
2539            protected DLFileShortcut filterGetByG_F_PrevAndNext(Session session,
2540                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
2541                    OrderByComparator orderByComparator, boolean previous) {
2542                    StringBundler query = null;
2543    
2544                    if (orderByComparator != null) {
2545                            query = new StringBundler(6 +
2546                                            (orderByComparator.getOrderByFields().length * 6));
2547                    }
2548                    else {
2549                            query = new StringBundler(3);
2550                    }
2551    
2552                    if (getDB().isSupportsInlineDistinct()) {
2553                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2554                    }
2555                    else {
2556                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
2557                    }
2558    
2559                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2560    
2561                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2562    
2563                    if (!getDB().isSupportsInlineDistinct()) {
2564                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
2565                    }
2566    
2567                    if (orderByComparator != null) {
2568                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2569    
2570                            if (orderByConditionFields.length > 0) {
2571                                    query.append(WHERE_AND);
2572                            }
2573    
2574                            for (int i = 0; i < orderByConditionFields.length; i++) {
2575                                    if (getDB().isSupportsInlineDistinct()) {
2576                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2577                                    }
2578                                    else {
2579                                            query.append(_ORDER_BY_ENTITY_TABLE);
2580                                    }
2581    
2582                                    query.append(orderByConditionFields[i]);
2583    
2584                                    if ((i + 1) < orderByConditionFields.length) {
2585                                            if (orderByComparator.isAscending() ^ previous) {
2586                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2587                                            }
2588                                            else {
2589                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2590                                            }
2591                                    }
2592                                    else {
2593                                            if (orderByComparator.isAscending() ^ previous) {
2594                                                    query.append(WHERE_GREATER_THAN);
2595                                            }
2596                                            else {
2597                                                    query.append(WHERE_LESSER_THAN);
2598                                            }
2599                                    }
2600                            }
2601    
2602                            query.append(ORDER_BY_CLAUSE);
2603    
2604                            String[] orderByFields = orderByComparator.getOrderByFields();
2605    
2606                            for (int i = 0; i < orderByFields.length; i++) {
2607                                    if (getDB().isSupportsInlineDistinct()) {
2608                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2609                                    }
2610                                    else {
2611                                            query.append(_ORDER_BY_ENTITY_TABLE);
2612                                    }
2613    
2614                                    query.append(orderByFields[i]);
2615    
2616                                    if ((i + 1) < orderByFields.length) {
2617                                            if (orderByComparator.isAscending() ^ previous) {
2618                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2619                                            }
2620                                            else {
2621                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2622                                            }
2623                                    }
2624                                    else {
2625                                            if (orderByComparator.isAscending() ^ previous) {
2626                                                    query.append(ORDER_BY_ASC);
2627                                            }
2628                                            else {
2629                                                    query.append(ORDER_BY_DESC);
2630                                            }
2631                                    }
2632                            }
2633                    }
2634                    else {
2635                            if (getDB().isSupportsInlineDistinct()) {
2636                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2637                            }
2638                            else {
2639                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
2640                            }
2641                    }
2642    
2643                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2644                                    DLFileShortcut.class.getName(),
2645                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2646    
2647                    SQLQuery q = session.createSQLQuery(sql);
2648    
2649                    q.setFirstResult(0);
2650                    q.setMaxResults(2);
2651    
2652                    if (getDB().isSupportsInlineDistinct()) {
2653                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2654                    }
2655                    else {
2656                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2657                    }
2658    
2659                    QueryPos qPos = QueryPos.getInstance(q);
2660    
2661                    qPos.add(groupId);
2662    
2663                    qPos.add(folderId);
2664    
2665                    if (orderByComparator != null) {
2666                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2667    
2668                            for (Object value : values) {
2669                                    qPos.add(value);
2670                            }
2671                    }
2672    
2673                    List<DLFileShortcut> list = q.list();
2674    
2675                    if (list.size() == 2) {
2676                            return list.get(1);
2677                    }
2678                    else {
2679                            return null;
2680                    }
2681            }
2682    
2683            /**
2684             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; from the database.
2685             *
2686             * @param groupId the group ID
2687             * @param folderId the folder ID
2688             * @throws SystemException if a system exception occurred
2689             */
2690            public void removeByG_F(long groupId, long folderId)
2691                    throws SystemException {
2692                    for (DLFileShortcut dlFileShortcut : findByG_F(groupId, folderId,
2693                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2694                            remove(dlFileShortcut);
2695                    }
2696            }
2697    
2698            /**
2699             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63;.
2700             *
2701             * @param groupId the group ID
2702             * @param folderId the folder ID
2703             * @return the number of matching document library file shortcuts
2704             * @throws SystemException if a system exception occurred
2705             */
2706            public int countByG_F(long groupId, long folderId)
2707                    throws SystemException {
2708                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
2709    
2710                    Object[] finderArgs = new Object[] { groupId, folderId };
2711    
2712                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2713                                    this);
2714    
2715                    if (count == null) {
2716                            StringBundler query = new StringBundler(3);
2717    
2718                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
2719    
2720                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2721    
2722                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2723    
2724                            String sql = query.toString();
2725    
2726                            Session session = null;
2727    
2728                            try {
2729                                    session = openSession();
2730    
2731                                    Query q = session.createQuery(sql);
2732    
2733                                    QueryPos qPos = QueryPos.getInstance(q);
2734    
2735                                    qPos.add(groupId);
2736    
2737                                    qPos.add(folderId);
2738    
2739                                    count = (Long)q.uniqueResult();
2740    
2741                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2742                            }
2743                            catch (Exception e) {
2744                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2745    
2746                                    throw processException(e);
2747                            }
2748                            finally {
2749                                    closeSession(session);
2750                            }
2751                    }
2752    
2753                    return count.intValue();
2754            }
2755    
2756            /**
2757             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
2758             *
2759             * @param groupId the group ID
2760             * @param folderId the folder ID
2761             * @return the number of matching document library file shortcuts that the user has permission to view
2762             * @throws SystemException if a system exception occurred
2763             */
2764            public int filterCountByG_F(long groupId, long folderId)
2765                    throws SystemException {
2766                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2767                            return countByG_F(groupId, folderId);
2768                    }
2769    
2770                    StringBundler query = new StringBundler(3);
2771    
2772                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
2773    
2774                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2775    
2776                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2777    
2778                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2779                                    DLFileShortcut.class.getName(),
2780                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2781    
2782                    Session session = null;
2783    
2784                    try {
2785                            session = openSession();
2786    
2787                            SQLQuery q = session.createSQLQuery(sql);
2788    
2789                            q.addScalar(COUNT_COLUMN_NAME,
2790                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2791    
2792                            QueryPos qPos = QueryPos.getInstance(q);
2793    
2794                            qPos.add(groupId);
2795    
2796                            qPos.add(folderId);
2797    
2798                            Long count = (Long)q.uniqueResult();
2799    
2800                            return count.intValue();
2801                    }
2802                    catch (Exception e) {
2803                            throw processException(e);
2804                    }
2805                    finally {
2806                            closeSession(session);
2807                    }
2808            }
2809    
2810            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
2811            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileShortcut.folderId = ?";
2812            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_A = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
2813                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
2814                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2815                            "findByG_F_A",
2816                            new String[] {
2817                                    Long.class.getName(), Long.class.getName(),
2818                                    Boolean.class.getName(),
2819                                    
2820                            Integer.class.getName(), Integer.class.getName(),
2821                                    OrderByComparator.class.getName()
2822                            });
2823            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
2824                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
2825                            DLFileShortcutImpl.class,
2826                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_A",
2827                            new String[] {
2828                                    Long.class.getName(), Long.class.getName(),
2829                                    Boolean.class.getName()
2830                            },
2831                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
2832                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK |
2833                            DLFileShortcutModelImpl.ACTIVE_COLUMN_BITMASK);
2834            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_A = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
2835                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
2836                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_A",
2837                            new String[] {
2838                                    Long.class.getName(), Long.class.getName(),
2839                                    Boolean.class.getName()
2840                            });
2841    
2842            /**
2843             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
2844             *
2845             * @param groupId the group ID
2846             * @param folderId the folder ID
2847             * @param active the active
2848             * @return the matching document library file shortcuts
2849             * @throws SystemException if a system exception occurred
2850             */
2851            public List<DLFileShortcut> findByG_F_A(long groupId, long folderId,
2852                    boolean active) throws SystemException {
2853                    return findByG_F_A(groupId, folderId, active, QueryUtil.ALL_POS,
2854                            QueryUtil.ALL_POS, null);
2855            }
2856    
2857            /**
2858             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
2859             *
2860             * <p>
2861             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
2862             * </p>
2863             *
2864             * @param groupId the group ID
2865             * @param folderId the folder ID
2866             * @param active the active
2867             * @param start the lower bound of the range of document library file shortcuts
2868             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2869             * @return the range of matching document library file shortcuts
2870             * @throws SystemException if a system exception occurred
2871             */
2872            public List<DLFileShortcut> findByG_F_A(long groupId, long folderId,
2873                    boolean active, int start, int end) throws SystemException {
2874                    return findByG_F_A(groupId, folderId, active, start, end, null);
2875            }
2876    
2877            /**
2878             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
2879             *
2880             * <p>
2881             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
2882             * </p>
2883             *
2884             * @param groupId the group ID
2885             * @param folderId the folder ID
2886             * @param active the active
2887             * @param start the lower bound of the range of document library file shortcuts
2888             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2889             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2890             * @return the ordered range of matching document library file shortcuts
2891             * @throws SystemException if a system exception occurred
2892             */
2893            public List<DLFileShortcut> findByG_F_A(long groupId, long folderId,
2894                    boolean active, int start, int end, OrderByComparator orderByComparator)
2895                    throws SystemException {
2896                    boolean pagination = true;
2897                    FinderPath finderPath = null;
2898                    Object[] finderArgs = null;
2899    
2900                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2901                                    (orderByComparator == null)) {
2902                            pagination = false;
2903                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A;
2904                            finderArgs = new Object[] { groupId, folderId, active };
2905                    }
2906                    else {
2907                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_A;
2908                            finderArgs = new Object[] {
2909                                            groupId, folderId, active,
2910                                            
2911                                            start, end, orderByComparator
2912                                    };
2913                    }
2914    
2915                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
2916                                    finderArgs, this);
2917    
2918                    if ((list != null) && !list.isEmpty()) {
2919                            for (DLFileShortcut dlFileShortcut : list) {
2920                                    if ((groupId != dlFileShortcut.getGroupId()) ||
2921                                                    (folderId != dlFileShortcut.getFolderId()) ||
2922                                                    (active != dlFileShortcut.getActive())) {
2923                                            list = null;
2924    
2925                                            break;
2926                                    }
2927                            }
2928                    }
2929    
2930                    if (list == null) {
2931                            StringBundler query = null;
2932    
2933                            if (orderByComparator != null) {
2934                                    query = new StringBundler(5 +
2935                                                    (orderByComparator.getOrderByFields().length * 3));
2936                            }
2937                            else {
2938                                    query = new StringBundler(5);
2939                            }
2940    
2941                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2942    
2943                            query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
2944    
2945                            query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
2946    
2947                            query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2);
2948    
2949                            if (orderByComparator != null) {
2950                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2951                                            orderByComparator);
2952                            }
2953                            else
2954                             if (pagination) {
2955                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
2956                            }
2957    
2958                            String sql = query.toString();
2959    
2960                            Session session = null;
2961    
2962                            try {
2963                                    session = openSession();
2964    
2965                                    Query q = session.createQuery(sql);
2966    
2967                                    QueryPos qPos = QueryPos.getInstance(q);
2968    
2969                                    qPos.add(groupId);
2970    
2971                                    qPos.add(folderId);
2972    
2973                                    qPos.add(active);
2974    
2975                                    if (!pagination) {
2976                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2977                                                            getDialect(), start, end, false);
2978    
2979                                            Collections.sort(list);
2980    
2981                                            list = new UnmodifiableList<DLFileShortcut>(list);
2982                                    }
2983                                    else {
2984                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2985                                                            getDialect(), start, end);
2986                                    }
2987    
2988                                    cacheResult(list);
2989    
2990                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2991                            }
2992                            catch (Exception e) {
2993                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2994    
2995                                    throw processException(e);
2996                            }
2997                            finally {
2998                                    closeSession(session);
2999                            }
3000                    }
3001    
3002                    return list;
3003            }
3004    
3005            /**
3006             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
3007             *
3008             * @param groupId the group ID
3009             * @param folderId the folder ID
3010             * @param active the active
3011             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3012             * @return the first matching document library file shortcut
3013             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
3014             * @throws SystemException if a system exception occurred
3015             */
3016            public DLFileShortcut findByG_F_A_First(long groupId, long folderId,
3017                    boolean active, OrderByComparator orderByComparator)
3018                    throws NoSuchFileShortcutException, SystemException {
3019                    DLFileShortcut dlFileShortcut = fetchByG_F_A_First(groupId, folderId,
3020                                    active, orderByComparator);
3021    
3022                    if (dlFileShortcut != null) {
3023                            return dlFileShortcut;
3024                    }
3025    
3026                    StringBundler msg = new StringBundler(8);
3027    
3028                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3029    
3030                    msg.append("groupId=");
3031                    msg.append(groupId);
3032    
3033                    msg.append(", folderId=");
3034                    msg.append(folderId);
3035    
3036                    msg.append(", active=");
3037                    msg.append(active);
3038    
3039                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3040    
3041                    throw new NoSuchFileShortcutException(msg.toString());
3042            }
3043    
3044            /**
3045             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
3046             *
3047             * @param groupId the group ID
3048             * @param folderId the folder ID
3049             * @param active the active
3050             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3051             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
3052             * @throws SystemException if a system exception occurred
3053             */
3054            public DLFileShortcut fetchByG_F_A_First(long groupId, long folderId,
3055                    boolean active, OrderByComparator orderByComparator)
3056                    throws SystemException {
3057                    List<DLFileShortcut> list = findByG_F_A(groupId, folderId, active, 0,
3058                                    1, orderByComparator);
3059    
3060                    if (!list.isEmpty()) {
3061                            return list.get(0);
3062                    }
3063    
3064                    return null;
3065            }
3066    
3067            /**
3068             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
3069             *
3070             * @param groupId the group ID
3071             * @param folderId the folder ID
3072             * @param active the active
3073             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3074             * @return the last matching document library file shortcut
3075             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
3076             * @throws SystemException if a system exception occurred
3077             */
3078            public DLFileShortcut findByG_F_A_Last(long groupId, long folderId,
3079                    boolean active, OrderByComparator orderByComparator)
3080                    throws NoSuchFileShortcutException, SystemException {
3081                    DLFileShortcut dlFileShortcut = fetchByG_F_A_Last(groupId, folderId,
3082                                    active, orderByComparator);
3083    
3084                    if (dlFileShortcut != null) {
3085                            return dlFileShortcut;
3086                    }
3087    
3088                    StringBundler msg = new StringBundler(8);
3089    
3090                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3091    
3092                    msg.append("groupId=");
3093                    msg.append(groupId);
3094    
3095                    msg.append(", folderId=");
3096                    msg.append(folderId);
3097    
3098                    msg.append(", active=");
3099                    msg.append(active);
3100    
3101                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3102    
3103                    throw new NoSuchFileShortcutException(msg.toString());
3104            }
3105    
3106            /**
3107             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63;.
3108             *
3109             * @param groupId the group ID
3110             * @param folderId the folder ID
3111             * @param active the active
3112             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3113             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
3114             * @throws SystemException if a system exception occurred
3115             */
3116            public DLFileShortcut fetchByG_F_A_Last(long groupId, long folderId,
3117                    boolean active, OrderByComparator orderByComparator)
3118                    throws SystemException {
3119                    int count = countByG_F_A(groupId, folderId, active);
3120    
3121                    List<DLFileShortcut> list = findByG_F_A(groupId, folderId, active,
3122                                    count - 1, count, orderByComparator);
3123    
3124                    if (!list.isEmpty()) {
3125                            return list.get(0);
3126                    }
3127    
3128                    return null;
3129            }
3130    
3131            /**
3132             * 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;.
3133             *
3134             * @param fileShortcutId the primary key of the current document library file shortcut
3135             * @param groupId the group ID
3136             * @param folderId the folder ID
3137             * @param active the active
3138             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3139             * @return the previous, current, and next document library file shortcut
3140             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
3141             * @throws SystemException if a system exception occurred
3142             */
3143            public DLFileShortcut[] findByG_F_A_PrevAndNext(long fileShortcutId,
3144                    long groupId, long folderId, boolean active,
3145                    OrderByComparator orderByComparator)
3146                    throws NoSuchFileShortcutException, SystemException {
3147                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
3148    
3149                    Session session = null;
3150    
3151                    try {
3152                            session = openSession();
3153    
3154                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
3155    
3156                            array[0] = getByG_F_A_PrevAndNext(session, dlFileShortcut, groupId,
3157                                            folderId, active, orderByComparator, true);
3158    
3159                            array[1] = dlFileShortcut;
3160    
3161                            array[2] = getByG_F_A_PrevAndNext(session, dlFileShortcut, groupId,
3162                                            folderId, active, orderByComparator, false);
3163    
3164                            return array;
3165                    }
3166                    catch (Exception e) {
3167                            throw processException(e);
3168                    }
3169                    finally {
3170                            closeSession(session);
3171                    }
3172            }
3173    
3174            protected DLFileShortcut getByG_F_A_PrevAndNext(Session session,
3175                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
3176                    boolean active, OrderByComparator orderByComparator, boolean previous) {
3177                    StringBundler query = null;
3178    
3179                    if (orderByComparator != null) {
3180                            query = new StringBundler(6 +
3181                                            (orderByComparator.getOrderByFields().length * 6));
3182                    }
3183                    else {
3184                            query = new StringBundler(3);
3185                    }
3186    
3187                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
3188    
3189                    query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
3190    
3191                    query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
3192    
3193                    query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2);
3194    
3195                    if (orderByComparator != null) {
3196                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3197    
3198                            if (orderByConditionFields.length > 0) {
3199                                    query.append(WHERE_AND);
3200                            }
3201    
3202                            for (int i = 0; i < orderByConditionFields.length; i++) {
3203                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3204                                    query.append(orderByConditionFields[i]);
3205    
3206                                    if ((i + 1) < orderByConditionFields.length) {
3207                                            if (orderByComparator.isAscending() ^ previous) {
3208                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3209                                            }
3210                                            else {
3211                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3212                                            }
3213                                    }
3214                                    else {
3215                                            if (orderByComparator.isAscending() ^ previous) {
3216                                                    query.append(WHERE_GREATER_THAN);
3217                                            }
3218                                            else {
3219                                                    query.append(WHERE_LESSER_THAN);
3220                                            }
3221                                    }
3222                            }
3223    
3224                            query.append(ORDER_BY_CLAUSE);
3225    
3226                            String[] orderByFields = orderByComparator.getOrderByFields();
3227    
3228                            for (int i = 0; i < orderByFields.length; i++) {
3229                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3230                                    query.append(orderByFields[i]);
3231    
3232                                    if ((i + 1) < orderByFields.length) {
3233                                            if (orderByComparator.isAscending() ^ previous) {
3234                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3235                                            }
3236                                            else {
3237                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3238                                            }
3239                                    }
3240                                    else {
3241                                            if (orderByComparator.isAscending() ^ previous) {
3242                                                    query.append(ORDER_BY_ASC);
3243                                            }
3244                                            else {
3245                                                    query.append(ORDER_BY_DESC);
3246                                            }
3247                                    }
3248                            }
3249                    }
3250                    else {
3251                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
3252                    }
3253    
3254                    String sql = query.toString();
3255    
3256                    Query q = session.createQuery(sql);
3257    
3258                    q.setFirstResult(0);
3259                    q.setMaxResults(2);
3260    
3261                    QueryPos qPos = QueryPos.getInstance(q);
3262    
3263                    qPos.add(groupId);
3264    
3265                    qPos.add(folderId);
3266    
3267                    qPos.add(active);
3268    
3269                    if (orderByComparator != null) {
3270                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
3271    
3272                            for (Object value : values) {
3273                                    qPos.add(value);
3274                            }
3275                    }
3276    
3277                    List<DLFileShortcut> list = q.list();
3278    
3279                    if (list.size() == 2) {
3280                            return list.get(1);
3281                    }
3282                    else {
3283                            return null;
3284                    }
3285            }
3286    
3287            /**
3288             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63;.
3289             *
3290             * @param groupId the group ID
3291             * @param folderId the folder ID
3292             * @param active the active
3293             * @return the matching document library file shortcuts that the user has permission to view
3294             * @throws SystemException if a system exception occurred
3295             */
3296            public List<DLFileShortcut> filterFindByG_F_A(long groupId, long folderId,
3297                    boolean active) throws SystemException {
3298                    return filterFindByG_F_A(groupId, folderId, active, QueryUtil.ALL_POS,
3299                            QueryUtil.ALL_POS, null);
3300            }
3301    
3302            /**
3303             * 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;.
3304             *
3305             * <p>
3306             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
3307             * </p>
3308             *
3309             * @param groupId the group ID
3310             * @param folderId the folder ID
3311             * @param active the active
3312             * @param start the lower bound of the range of document library file shortcuts
3313             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3314             * @return the range of matching document library file shortcuts that the user has permission to view
3315             * @throws SystemException if a system exception occurred
3316             */
3317            public List<DLFileShortcut> filterFindByG_F_A(long groupId, long folderId,
3318                    boolean active, int start, int end) throws SystemException {
3319                    return filterFindByG_F_A(groupId, folderId, active, start, end, null);
3320            }
3321    
3322            /**
3323             * 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;.
3324             *
3325             * <p>
3326             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
3327             * </p>
3328             *
3329             * @param groupId the group ID
3330             * @param folderId the folder ID
3331             * @param active the active
3332             * @param start the lower bound of the range of document library file shortcuts
3333             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3334             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3335             * @return the ordered range of matching document library file shortcuts that the user has permission to view
3336             * @throws SystemException if a system exception occurred
3337             */
3338            public List<DLFileShortcut> filterFindByG_F_A(long groupId, long folderId,
3339                    boolean active, int start, int end, OrderByComparator orderByComparator)
3340                    throws SystemException {
3341                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3342                            return findByG_F_A(groupId, folderId, active, start, end,
3343                                    orderByComparator);
3344                    }
3345    
3346                    StringBundler query = null;
3347    
3348                    if (orderByComparator != null) {
3349                            query = new StringBundler(5 +
3350                                            (orderByComparator.getOrderByFields().length * 3));
3351                    }
3352                    else {
3353                            query = new StringBundler(5);
3354                    }
3355    
3356                    if (getDB().isSupportsInlineDistinct()) {
3357                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
3358                    }
3359                    else {
3360                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
3361                    }
3362    
3363                    query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
3364    
3365                    query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
3366    
3367                    query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2_SQL);
3368    
3369                    if (!getDB().isSupportsInlineDistinct()) {
3370                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
3371                    }
3372    
3373                    if (orderByComparator != null) {
3374                            if (getDB().isSupportsInlineDistinct()) {
3375                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3376                                            orderByComparator, true);
3377                            }
3378                            else {
3379                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3380                                            orderByComparator, true);
3381                            }
3382                    }
3383                    else {
3384                            if (getDB().isSupportsInlineDistinct()) {
3385                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
3386                            }
3387                            else {
3388                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
3389                            }
3390                    }
3391    
3392                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3393                                    DLFileShortcut.class.getName(),
3394                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3395    
3396                    Session session = null;
3397    
3398                    try {
3399                            session = openSession();
3400    
3401                            SQLQuery q = session.createSQLQuery(sql);
3402    
3403                            if (getDB().isSupportsInlineDistinct()) {
3404                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
3405                            }
3406                            else {
3407                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
3408                            }
3409    
3410                            QueryPos qPos = QueryPos.getInstance(q);
3411    
3412                            qPos.add(groupId);
3413    
3414                            qPos.add(folderId);
3415    
3416                            qPos.add(active);
3417    
3418                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
3419                                    end);
3420                    }
3421                    catch (Exception e) {
3422                            throw processException(e);
3423                    }
3424                    finally {
3425                            closeSession(session);
3426                    }
3427            }
3428    
3429            /**
3430             * 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;.
3431             *
3432             * @param fileShortcutId the primary key of the current document library file shortcut
3433             * @param groupId the group ID
3434             * @param folderId the folder ID
3435             * @param active the active
3436             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3437             * @return the previous, current, and next document library file shortcut
3438             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
3439             * @throws SystemException if a system exception occurred
3440             */
3441            public DLFileShortcut[] filterFindByG_F_A_PrevAndNext(long fileShortcutId,
3442                    long groupId, long folderId, boolean active,
3443                    OrderByComparator orderByComparator)
3444                    throws NoSuchFileShortcutException, SystemException {
3445                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3446                            return findByG_F_A_PrevAndNext(fileShortcutId, groupId, folderId,
3447                                    active, orderByComparator);
3448                    }
3449    
3450                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
3451    
3452                    Session session = null;
3453    
3454                    try {
3455                            session = openSession();
3456    
3457                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
3458    
3459                            array[0] = filterGetByG_F_A_PrevAndNext(session, dlFileShortcut,
3460                                            groupId, folderId, active, orderByComparator, true);
3461    
3462                            array[1] = dlFileShortcut;
3463    
3464                            array[2] = filterGetByG_F_A_PrevAndNext(session, dlFileShortcut,
3465                                            groupId, folderId, active, orderByComparator, false);
3466    
3467                            return array;
3468                    }
3469                    catch (Exception e) {
3470                            throw processException(e);
3471                    }
3472                    finally {
3473                            closeSession(session);
3474                    }
3475            }
3476    
3477            protected DLFileShortcut filterGetByG_F_A_PrevAndNext(Session session,
3478                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
3479                    boolean active, OrderByComparator orderByComparator, boolean previous) {
3480                    StringBundler query = null;
3481    
3482                    if (orderByComparator != null) {
3483                            query = new StringBundler(6 +
3484                                            (orderByComparator.getOrderByFields().length * 6));
3485                    }
3486                    else {
3487                            query = new StringBundler(3);
3488                    }
3489    
3490                    if (getDB().isSupportsInlineDistinct()) {
3491                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
3492                    }
3493                    else {
3494                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
3495                    }
3496    
3497                    query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
3498    
3499                    query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
3500    
3501                    query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2_SQL);
3502    
3503                    if (!getDB().isSupportsInlineDistinct()) {
3504                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
3505                    }
3506    
3507                    if (orderByComparator != null) {
3508                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3509    
3510                            if (orderByConditionFields.length > 0) {
3511                                    query.append(WHERE_AND);
3512                            }
3513    
3514                            for (int i = 0; i < orderByConditionFields.length; i++) {
3515                                    if (getDB().isSupportsInlineDistinct()) {
3516                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3517                                    }
3518                                    else {
3519                                            query.append(_ORDER_BY_ENTITY_TABLE);
3520                                    }
3521    
3522                                    query.append(orderByConditionFields[i]);
3523    
3524                                    if ((i + 1) < orderByConditionFields.length) {
3525                                            if (orderByComparator.isAscending() ^ previous) {
3526                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3527                                            }
3528                                            else {
3529                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3530                                            }
3531                                    }
3532                                    else {
3533                                            if (orderByComparator.isAscending() ^ previous) {
3534                                                    query.append(WHERE_GREATER_THAN);
3535                                            }
3536                                            else {
3537                                                    query.append(WHERE_LESSER_THAN);
3538                                            }
3539                                    }
3540                            }
3541    
3542                            query.append(ORDER_BY_CLAUSE);
3543    
3544                            String[] orderByFields = orderByComparator.getOrderByFields();
3545    
3546                            for (int i = 0; i < orderByFields.length; i++) {
3547                                    if (getDB().isSupportsInlineDistinct()) {
3548                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3549                                    }
3550                                    else {
3551                                            query.append(_ORDER_BY_ENTITY_TABLE);
3552                                    }
3553    
3554                                    query.append(orderByFields[i]);
3555    
3556                                    if ((i + 1) < orderByFields.length) {
3557                                            if (orderByComparator.isAscending() ^ previous) {
3558                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3559                                            }
3560                                            else {
3561                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3562                                            }
3563                                    }
3564                                    else {
3565                                            if (orderByComparator.isAscending() ^ previous) {
3566                                                    query.append(ORDER_BY_ASC);
3567                                            }
3568                                            else {
3569                                                    query.append(ORDER_BY_DESC);
3570                                            }
3571                                    }
3572                            }
3573                    }
3574                    else {
3575                            if (getDB().isSupportsInlineDistinct()) {
3576                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
3577                            }
3578                            else {
3579                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
3580                            }
3581                    }
3582    
3583                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3584                                    DLFileShortcut.class.getName(),
3585                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3586    
3587                    SQLQuery q = session.createSQLQuery(sql);
3588    
3589                    q.setFirstResult(0);
3590                    q.setMaxResults(2);
3591    
3592                    if (getDB().isSupportsInlineDistinct()) {
3593                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
3594                    }
3595                    else {
3596                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
3597                    }
3598    
3599                    QueryPos qPos = QueryPos.getInstance(q);
3600    
3601                    qPos.add(groupId);
3602    
3603                    qPos.add(folderId);
3604    
3605                    qPos.add(active);
3606    
3607                    if (orderByComparator != null) {
3608                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
3609    
3610                            for (Object value : values) {
3611                                    qPos.add(value);
3612                            }
3613                    }
3614    
3615                    List<DLFileShortcut> list = q.list();
3616    
3617                    if (list.size() == 2) {
3618                            return list.get(1);
3619                    }
3620                    else {
3621                            return null;
3622                    }
3623            }
3624    
3625            /**
3626             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; from the database.
3627             *
3628             * @param groupId the group ID
3629             * @param folderId the folder ID
3630             * @param active the active
3631             * @throws SystemException if a system exception occurred
3632             */
3633            public void removeByG_F_A(long groupId, long folderId, boolean active)
3634                    throws SystemException {
3635                    for (DLFileShortcut dlFileShortcut : findByG_F_A(groupId, folderId,
3636                                    active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3637                            remove(dlFileShortcut);
3638                    }
3639            }
3640    
3641            /**
3642             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63;.
3643             *
3644             * @param groupId the group ID
3645             * @param folderId the folder ID
3646             * @param active the active
3647             * @return the number of matching document library file shortcuts
3648             * @throws SystemException if a system exception occurred
3649             */
3650            public int countByG_F_A(long groupId, long folderId, boolean active)
3651                    throws SystemException {
3652                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_A;
3653    
3654                    Object[] finderArgs = new Object[] { groupId, folderId, active };
3655    
3656                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3657                                    this);
3658    
3659                    if (count == null) {
3660                            StringBundler query = new StringBundler(4);
3661    
3662                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3663    
3664                            query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
3665    
3666                            query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
3667    
3668                            query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2);
3669    
3670                            String sql = query.toString();
3671    
3672                            Session session = null;
3673    
3674                            try {
3675                                    session = openSession();
3676    
3677                                    Query q = session.createQuery(sql);
3678    
3679                                    QueryPos qPos = QueryPos.getInstance(q);
3680    
3681                                    qPos.add(groupId);
3682    
3683                                    qPos.add(folderId);
3684    
3685                                    qPos.add(active);
3686    
3687                                    count = (Long)q.uniqueResult();
3688    
3689                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3690                            }
3691                            catch (Exception e) {
3692                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3693    
3694                                    throw processException(e);
3695                            }
3696                            finally {
3697                                    closeSession(session);
3698                            }
3699                    }
3700    
3701                    return count.intValue();
3702            }
3703    
3704            /**
3705             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and active = &#63;.
3706             *
3707             * @param groupId the group ID
3708             * @param folderId the folder ID
3709             * @param active the active
3710             * @return the number of matching document library file shortcuts that the user has permission to view
3711             * @throws SystemException if a system exception occurred
3712             */
3713            public int filterCountByG_F_A(long groupId, long folderId, boolean active)
3714                    throws SystemException {
3715                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3716                            return countByG_F_A(groupId, folderId, active);
3717                    }
3718    
3719                    StringBundler query = new StringBundler(4);
3720    
3721                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3722    
3723                    query.append(_FINDER_COLUMN_G_F_A_GROUPID_2);
3724    
3725                    query.append(_FINDER_COLUMN_G_F_A_FOLDERID_2);
3726    
3727                    query.append(_FINDER_COLUMN_G_F_A_ACTIVE_2_SQL);
3728    
3729                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3730                                    DLFileShortcut.class.getName(),
3731                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3732    
3733                    Session session = null;
3734    
3735                    try {
3736                            session = openSession();
3737    
3738                            SQLQuery q = session.createSQLQuery(sql);
3739    
3740                            q.addScalar(COUNT_COLUMN_NAME,
3741                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3742    
3743                            QueryPos qPos = QueryPos.getInstance(q);
3744    
3745                            qPos.add(groupId);
3746    
3747                            qPos.add(folderId);
3748    
3749                            qPos.add(active);
3750    
3751                            Long count = (Long)q.uniqueResult();
3752    
3753                            return count.intValue();
3754                    }
3755                    catch (Exception e) {
3756                            throw processException(e);
3757                    }
3758                    finally {
3759                            closeSession(session);
3760                    }
3761            }
3762    
3763            private static final String _FINDER_COLUMN_G_F_A_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
3764            private static final String _FINDER_COLUMN_G_F_A_FOLDERID_2 = "dlFileShortcut.folderId = ? AND ";
3765            private static final String _FINDER_COLUMN_G_F_A_ACTIVE_2 = "dlFileShortcut.active = ?";
3766            private static final String _FINDER_COLUMN_G_F_A_ACTIVE_2_SQL = "dlFileShortcut.active_ = ?";
3767            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_A_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
3768                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
3769                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3770                            "findByG_F_A_S",
3771                            new String[] {
3772                                    Long.class.getName(), Long.class.getName(),
3773                                    Boolean.class.getName(), Integer.class.getName(),
3774                                    
3775                            Integer.class.getName(), Integer.class.getName(),
3776                                    OrderByComparator.class.getName()
3777                            });
3778            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S =
3779                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
3780                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
3781                            DLFileShortcutImpl.class,
3782                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_A_S",
3783                            new String[] {
3784                                    Long.class.getName(), Long.class.getName(),
3785                                    Boolean.class.getName(), Integer.class.getName()
3786                            },
3787                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
3788                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK |
3789                            DLFileShortcutModelImpl.ACTIVE_COLUMN_BITMASK |
3790                            DLFileShortcutModelImpl.STATUS_COLUMN_BITMASK);
3791            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_A_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
3792                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
3793                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_A_S",
3794                            new String[] {
3795                                    Long.class.getName(), Long.class.getName(),
3796                                    Boolean.class.getName(), Integer.class.getName()
3797                            });
3798    
3799            /**
3800             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
3801             *
3802             * @param groupId the group ID
3803             * @param folderId the folder ID
3804             * @param active the active
3805             * @param status the status
3806             * @return the matching document library file shortcuts
3807             * @throws SystemException if a system exception occurred
3808             */
3809            public List<DLFileShortcut> findByG_F_A_S(long groupId, long folderId,
3810                    boolean active, int status) throws SystemException {
3811                    return findByG_F_A_S(groupId, folderId, active, status,
3812                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3813            }
3814    
3815            /**
3816             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
3817             *
3818             * <p>
3819             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
3820             * </p>
3821             *
3822             * @param groupId the group ID
3823             * @param folderId the folder ID
3824             * @param active the active
3825             * @param status the status
3826             * @param start the lower bound of the range of document library file shortcuts
3827             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3828             * @return the range of matching document library file shortcuts
3829             * @throws SystemException if a system exception occurred
3830             */
3831            public List<DLFileShortcut> findByG_F_A_S(long groupId, long folderId,
3832                    boolean active, int status, int start, int end)
3833                    throws SystemException {
3834                    return findByG_F_A_S(groupId, folderId, active, status, start, end, null);
3835            }
3836    
3837            /**
3838             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
3839             *
3840             * <p>
3841             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
3842             * </p>
3843             *
3844             * @param groupId the group ID
3845             * @param folderId the folder ID
3846             * @param active the active
3847             * @param status the status
3848             * @param start the lower bound of the range of document library file shortcuts
3849             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
3850             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3851             * @return the ordered range of matching document library file shortcuts
3852             * @throws SystemException if a system exception occurred
3853             */
3854            public List<DLFileShortcut> findByG_F_A_S(long groupId, long folderId,
3855                    boolean active, int status, int start, int end,
3856                    OrderByComparator orderByComparator) throws SystemException {
3857                    boolean pagination = true;
3858                    FinderPath finderPath = null;
3859                    Object[] finderArgs = null;
3860    
3861                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3862                                    (orderByComparator == null)) {
3863                            pagination = false;
3864                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S;
3865                            finderArgs = new Object[] { groupId, folderId, active, status };
3866                    }
3867                    else {
3868                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_A_S;
3869                            finderArgs = new Object[] {
3870                                            groupId, folderId, active, status,
3871                                            
3872                                            start, end, orderByComparator
3873                                    };
3874                    }
3875    
3876                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
3877                                    finderArgs, this);
3878    
3879                    if ((list != null) && !list.isEmpty()) {
3880                            for (DLFileShortcut dlFileShortcut : list) {
3881                                    if ((groupId != dlFileShortcut.getGroupId()) ||
3882                                                    (folderId != dlFileShortcut.getFolderId()) ||
3883                                                    (active != dlFileShortcut.getActive()) ||
3884                                                    (status != dlFileShortcut.getStatus())) {
3885                                            list = null;
3886    
3887                                            break;
3888                                    }
3889                            }
3890                    }
3891    
3892                    if (list == null) {
3893                            StringBundler query = null;
3894    
3895                            if (orderByComparator != null) {
3896                                    query = new StringBundler(6 +
3897                                                    (orderByComparator.getOrderByFields().length * 3));
3898                            }
3899                            else {
3900                                    query = new StringBundler(6);
3901                            }
3902    
3903                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
3904    
3905                            query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
3906    
3907                            query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
3908    
3909                            query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2);
3910    
3911                            query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
3912    
3913                            if (orderByComparator != null) {
3914                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3915                                            orderByComparator);
3916                            }
3917                            else
3918                             if (pagination) {
3919                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
3920                            }
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(groupId);
3934    
3935                                    qPos.add(folderId);
3936    
3937                                    qPos.add(active);
3938    
3939                                    qPos.add(status);
3940    
3941                                    if (!pagination) {
3942                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
3943                                                            getDialect(), start, end, false);
3944    
3945                                            Collections.sort(list);
3946    
3947                                            list = new UnmodifiableList<DLFileShortcut>(list);
3948                                    }
3949                                    else {
3950                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
3951                                                            getDialect(), start, end);
3952                                    }
3953    
3954                                    cacheResult(list);
3955    
3956                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3957                            }
3958                            catch (Exception e) {
3959                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3960    
3961                                    throw processException(e);
3962                            }
3963                            finally {
3964                                    closeSession(session);
3965                            }
3966                    }
3967    
3968                    return list;
3969            }
3970    
3971            /**
3972             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
3973             *
3974             * @param groupId the group ID
3975             * @param folderId the folder ID
3976             * @param active the active
3977             * @param status the status
3978             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3979             * @return the first matching document library file shortcut
3980             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
3981             * @throws SystemException if a system exception occurred
3982             */
3983            public DLFileShortcut findByG_F_A_S_First(long groupId, long folderId,
3984                    boolean active, int status, OrderByComparator orderByComparator)
3985                    throws NoSuchFileShortcutException, SystemException {
3986                    DLFileShortcut dlFileShortcut = fetchByG_F_A_S_First(groupId, folderId,
3987                                    active, status, orderByComparator);
3988    
3989                    if (dlFileShortcut != null) {
3990                            return dlFileShortcut;
3991                    }
3992    
3993                    StringBundler msg = new StringBundler(10);
3994    
3995                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3996    
3997                    msg.append("groupId=");
3998                    msg.append(groupId);
3999    
4000                    msg.append(", folderId=");
4001                    msg.append(folderId);
4002    
4003                    msg.append(", active=");
4004                    msg.append(active);
4005    
4006                    msg.append(", status=");
4007                    msg.append(status);
4008    
4009                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4010    
4011                    throw new NoSuchFileShortcutException(msg.toString());
4012            }
4013    
4014            /**
4015             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
4016             *
4017             * @param groupId the group ID
4018             * @param folderId the folder ID
4019             * @param active the active
4020             * @param status the status
4021             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4022             * @return the first matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
4023             * @throws SystemException if a system exception occurred
4024             */
4025            public DLFileShortcut fetchByG_F_A_S_First(long groupId, long folderId,
4026                    boolean active, int status, OrderByComparator orderByComparator)
4027                    throws SystemException {
4028                    List<DLFileShortcut> list = findByG_F_A_S(groupId, folderId, active,
4029                                    status, 0, 1, orderByComparator);
4030    
4031                    if (!list.isEmpty()) {
4032                            return list.get(0);
4033                    }
4034    
4035                    return null;
4036            }
4037    
4038            /**
4039             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
4040             *
4041             * @param groupId the group ID
4042             * @param folderId the folder ID
4043             * @param active the active
4044             * @param status the status
4045             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4046             * @return the last matching document library file shortcut
4047             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
4048             * @throws SystemException if a system exception occurred
4049             */
4050            public DLFileShortcut findByG_F_A_S_Last(long groupId, long folderId,
4051                    boolean active, int status, OrderByComparator orderByComparator)
4052                    throws NoSuchFileShortcutException, SystemException {
4053                    DLFileShortcut dlFileShortcut = fetchByG_F_A_S_Last(groupId, folderId,
4054                                    active, status, orderByComparator);
4055    
4056                    if (dlFileShortcut != null) {
4057                            return dlFileShortcut;
4058                    }
4059    
4060                    StringBundler msg = new StringBundler(10);
4061    
4062                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4063    
4064                    msg.append("groupId=");
4065                    msg.append(groupId);
4066    
4067                    msg.append(", folderId=");
4068                    msg.append(folderId);
4069    
4070                    msg.append(", active=");
4071                    msg.append(active);
4072    
4073                    msg.append(", status=");
4074                    msg.append(status);
4075    
4076                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4077    
4078                    throw new NoSuchFileShortcutException(msg.toString());
4079            }
4080    
4081            /**
4082             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
4083             *
4084             * @param groupId the group ID
4085             * @param folderId the folder ID
4086             * @param active the active
4087             * @param status the status
4088             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4089             * @return the last matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
4090             * @throws SystemException if a system exception occurred
4091             */
4092            public DLFileShortcut fetchByG_F_A_S_Last(long groupId, long folderId,
4093                    boolean active, int status, OrderByComparator orderByComparator)
4094                    throws SystemException {
4095                    int count = countByG_F_A_S(groupId, folderId, active, status);
4096    
4097                    List<DLFileShortcut> list = findByG_F_A_S(groupId, folderId, active,
4098                                    status, count - 1, count, orderByComparator);
4099    
4100                    if (!list.isEmpty()) {
4101                            return list.get(0);
4102                    }
4103    
4104                    return null;
4105            }
4106    
4107            /**
4108             * 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;.
4109             *
4110             * @param fileShortcutId the primary key of the current document library file shortcut
4111             * @param groupId the group ID
4112             * @param folderId the folder ID
4113             * @param active the active
4114             * @param status the status
4115             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4116             * @return the previous, current, and next document library file shortcut
4117             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
4118             * @throws SystemException if a system exception occurred
4119             */
4120            public DLFileShortcut[] findByG_F_A_S_PrevAndNext(long fileShortcutId,
4121                    long groupId, long folderId, boolean active, int status,
4122                    OrderByComparator orderByComparator)
4123                    throws NoSuchFileShortcutException, SystemException {
4124                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
4125    
4126                    Session session = null;
4127    
4128                    try {
4129                            session = openSession();
4130    
4131                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
4132    
4133                            array[0] = getByG_F_A_S_PrevAndNext(session, dlFileShortcut,
4134                                            groupId, folderId, active, status, orderByComparator, true);
4135    
4136                            array[1] = dlFileShortcut;
4137    
4138                            array[2] = getByG_F_A_S_PrevAndNext(session, dlFileShortcut,
4139                                            groupId, folderId, active, status, orderByComparator, false);
4140    
4141                            return array;
4142                    }
4143                    catch (Exception e) {
4144                            throw processException(e);
4145                    }
4146                    finally {
4147                            closeSession(session);
4148                    }
4149            }
4150    
4151            protected DLFileShortcut getByG_F_A_S_PrevAndNext(Session session,
4152                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
4153                    boolean active, int status, OrderByComparator orderByComparator,
4154                    boolean previous) {
4155                    StringBundler query = null;
4156    
4157                    if (orderByComparator != null) {
4158                            query = new StringBundler(6 +
4159                                            (orderByComparator.getOrderByFields().length * 6));
4160                    }
4161                    else {
4162                            query = new StringBundler(3);
4163                    }
4164    
4165                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
4166    
4167                    query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
4168    
4169                    query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
4170    
4171                    query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2);
4172    
4173                    query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
4174    
4175                    if (orderByComparator != null) {
4176                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4177    
4178                            if (orderByConditionFields.length > 0) {
4179                                    query.append(WHERE_AND);
4180                            }
4181    
4182                            for (int i = 0; i < orderByConditionFields.length; i++) {
4183                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4184                                    query.append(orderByConditionFields[i]);
4185    
4186                                    if ((i + 1) < orderByConditionFields.length) {
4187                                            if (orderByComparator.isAscending() ^ previous) {
4188                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4189                                            }
4190                                            else {
4191                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4192                                            }
4193                                    }
4194                                    else {
4195                                            if (orderByComparator.isAscending() ^ previous) {
4196                                                    query.append(WHERE_GREATER_THAN);
4197                                            }
4198                                            else {
4199                                                    query.append(WHERE_LESSER_THAN);
4200                                            }
4201                                    }
4202                            }
4203    
4204                            query.append(ORDER_BY_CLAUSE);
4205    
4206                            String[] orderByFields = orderByComparator.getOrderByFields();
4207    
4208                            for (int i = 0; i < orderByFields.length; i++) {
4209                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4210                                    query.append(orderByFields[i]);
4211    
4212                                    if ((i + 1) < orderByFields.length) {
4213                                            if (orderByComparator.isAscending() ^ previous) {
4214                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4215                                            }
4216                                            else {
4217                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4218                                            }
4219                                    }
4220                                    else {
4221                                            if (orderByComparator.isAscending() ^ previous) {
4222                                                    query.append(ORDER_BY_ASC);
4223                                            }
4224                                            else {
4225                                                    query.append(ORDER_BY_DESC);
4226                                            }
4227                                    }
4228                            }
4229                    }
4230                    else {
4231                            query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
4232                    }
4233    
4234                    String sql = query.toString();
4235    
4236                    Query q = session.createQuery(sql);
4237    
4238                    q.setFirstResult(0);
4239                    q.setMaxResults(2);
4240    
4241                    QueryPos qPos = QueryPos.getInstance(q);
4242    
4243                    qPos.add(groupId);
4244    
4245                    qPos.add(folderId);
4246    
4247                    qPos.add(active);
4248    
4249                    qPos.add(status);
4250    
4251                    if (orderByComparator != null) {
4252                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
4253    
4254                            for (Object value : values) {
4255                                    qPos.add(value);
4256                            }
4257                    }
4258    
4259                    List<DLFileShortcut> list = q.list();
4260    
4261                    if (list.size() == 2) {
4262                            return list.get(1);
4263                    }
4264                    else {
4265                            return null;
4266                    }
4267            }
4268    
4269            /**
4270             * 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;.
4271             *
4272             * @param groupId the group ID
4273             * @param folderId the folder ID
4274             * @param active the active
4275             * @param status the status
4276             * @return the matching document library file shortcuts that the user has permission to view
4277             * @throws SystemException if a system exception occurred
4278             */
4279            public List<DLFileShortcut> filterFindByG_F_A_S(long groupId,
4280                    long folderId, boolean active, int status) throws SystemException {
4281                    return filterFindByG_F_A_S(groupId, folderId, active, status,
4282                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4283            }
4284    
4285            /**
4286             * 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;.
4287             *
4288             * <p>
4289             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
4290             * </p>
4291             *
4292             * @param groupId the group ID
4293             * @param folderId the folder ID
4294             * @param active the active
4295             * @param status the status
4296             * @param start the lower bound of the range of document library file shortcuts
4297             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
4298             * @return the range of matching document library file shortcuts that the user has permission to view
4299             * @throws SystemException if a system exception occurred
4300             */
4301            public List<DLFileShortcut> filterFindByG_F_A_S(long groupId,
4302                    long folderId, boolean active, int status, int start, int end)
4303                    throws SystemException {
4304                    return filterFindByG_F_A_S(groupId, folderId, active, status, start,
4305                            end, null);
4306            }
4307    
4308            /**
4309             * 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;.
4310             *
4311             * <p>
4312             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
4313             * </p>
4314             *
4315             * @param groupId the group ID
4316             * @param folderId the folder ID
4317             * @param active the active
4318             * @param status the status
4319             * @param start the lower bound of the range of document library file shortcuts
4320             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
4321             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4322             * @return the ordered range of matching document library file shortcuts that the user has permission to view
4323             * @throws SystemException if a system exception occurred
4324             */
4325            public List<DLFileShortcut> filterFindByG_F_A_S(long groupId,
4326                    long folderId, boolean active, int status, int start, int end,
4327                    OrderByComparator orderByComparator) throws SystemException {
4328                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4329                            return findByG_F_A_S(groupId, folderId, active, status, start, end,
4330                                    orderByComparator);
4331                    }
4332    
4333                    StringBundler query = null;
4334    
4335                    if (orderByComparator != null) {
4336                            query = new StringBundler(6 +
4337                                            (orderByComparator.getOrderByFields().length * 3));
4338                    }
4339                    else {
4340                            query = new StringBundler(6);
4341                    }
4342    
4343                    if (getDB().isSupportsInlineDistinct()) {
4344                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
4345                    }
4346                    else {
4347                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
4348                    }
4349    
4350                    query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
4351    
4352                    query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
4353    
4354                    query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2_SQL);
4355    
4356                    query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
4357    
4358                    if (!getDB().isSupportsInlineDistinct()) {
4359                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
4360                    }
4361    
4362                    if (orderByComparator != null) {
4363                            if (getDB().isSupportsInlineDistinct()) {
4364                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4365                                            orderByComparator, true);
4366                            }
4367                            else {
4368                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4369                                            orderByComparator, true);
4370                            }
4371                    }
4372                    else {
4373                            if (getDB().isSupportsInlineDistinct()) {
4374                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
4375                            }
4376                            else {
4377                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
4378                            }
4379                    }
4380    
4381                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4382                                    DLFileShortcut.class.getName(),
4383                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4384    
4385                    Session session = null;
4386    
4387                    try {
4388                            session = openSession();
4389    
4390                            SQLQuery q = session.createSQLQuery(sql);
4391    
4392                            if (getDB().isSupportsInlineDistinct()) {
4393                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
4394                            }
4395                            else {
4396                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
4397                            }
4398    
4399                            QueryPos qPos = QueryPos.getInstance(q);
4400    
4401                            qPos.add(groupId);
4402    
4403                            qPos.add(folderId);
4404    
4405                            qPos.add(active);
4406    
4407                            qPos.add(status);
4408    
4409                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
4410                                    end);
4411                    }
4412                    catch (Exception e) {
4413                            throw processException(e);
4414                    }
4415                    finally {
4416                            closeSession(session);
4417                    }
4418            }
4419    
4420            /**
4421             * 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;.
4422             *
4423             * @param fileShortcutId the primary key of the current document library file shortcut
4424             * @param groupId the group ID
4425             * @param folderId the folder ID
4426             * @param active the active
4427             * @param status the status
4428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4429             * @return the previous, current, and next document library file shortcut
4430             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
4431             * @throws SystemException if a system exception occurred
4432             */
4433            public DLFileShortcut[] filterFindByG_F_A_S_PrevAndNext(
4434                    long fileShortcutId, long groupId, long folderId, boolean active,
4435                    int status, OrderByComparator orderByComparator)
4436                    throws NoSuchFileShortcutException, SystemException {
4437                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4438                            return findByG_F_A_S_PrevAndNext(fileShortcutId, groupId, folderId,
4439                                    active, status, orderByComparator);
4440                    }
4441    
4442                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
4443    
4444                    Session session = null;
4445    
4446                    try {
4447                            session = openSession();
4448    
4449                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
4450    
4451                            array[0] = filterGetByG_F_A_S_PrevAndNext(session, dlFileShortcut,
4452                                            groupId, folderId, active, status, orderByComparator, true);
4453    
4454                            array[1] = dlFileShortcut;
4455    
4456                            array[2] = filterGetByG_F_A_S_PrevAndNext(session, dlFileShortcut,
4457                                            groupId, folderId, active, status, orderByComparator, false);
4458    
4459                            return array;
4460                    }
4461                    catch (Exception e) {
4462                            throw processException(e);
4463                    }
4464                    finally {
4465                            closeSession(session);
4466                    }
4467            }
4468    
4469            protected DLFileShortcut filterGetByG_F_A_S_PrevAndNext(Session session,
4470                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
4471                    boolean active, int status, OrderByComparator orderByComparator,
4472                    boolean previous) {
4473                    StringBundler query = null;
4474    
4475                    if (orderByComparator != null) {
4476                            query = new StringBundler(6 +
4477                                            (orderByComparator.getOrderByFields().length * 6));
4478                    }
4479                    else {
4480                            query = new StringBundler(3);
4481                    }
4482    
4483                    if (getDB().isSupportsInlineDistinct()) {
4484                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
4485                    }
4486                    else {
4487                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
4488                    }
4489    
4490                    query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
4491    
4492                    query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
4493    
4494                    query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2_SQL);
4495    
4496                    query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
4497    
4498                    if (!getDB().isSupportsInlineDistinct()) {
4499                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
4500                    }
4501    
4502                    if (orderByComparator != null) {
4503                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4504    
4505                            if (orderByConditionFields.length > 0) {
4506                                    query.append(WHERE_AND);
4507                            }
4508    
4509                            for (int i = 0; i < orderByConditionFields.length; i++) {
4510                                    if (getDB().isSupportsInlineDistinct()) {
4511                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4512                                    }
4513                                    else {
4514                                            query.append(_ORDER_BY_ENTITY_TABLE);
4515                                    }
4516    
4517                                    query.append(orderByConditionFields[i]);
4518    
4519                                    if ((i + 1) < orderByConditionFields.length) {
4520                                            if (orderByComparator.isAscending() ^ previous) {
4521                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4522                                            }
4523                                            else {
4524                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4525                                            }
4526                                    }
4527                                    else {
4528                                            if (orderByComparator.isAscending() ^ previous) {
4529                                                    query.append(WHERE_GREATER_THAN);
4530                                            }
4531                                            else {
4532                                                    query.append(WHERE_LESSER_THAN);
4533                                            }
4534                                    }
4535                            }
4536    
4537                            query.append(ORDER_BY_CLAUSE);
4538    
4539                            String[] orderByFields = orderByComparator.getOrderByFields();
4540    
4541                            for (int i = 0; i < orderByFields.length; i++) {
4542                                    if (getDB().isSupportsInlineDistinct()) {
4543                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4544                                    }
4545                                    else {
4546                                            query.append(_ORDER_BY_ENTITY_TABLE);
4547                                    }
4548    
4549                                    query.append(orderByFields[i]);
4550    
4551                                    if ((i + 1) < orderByFields.length) {
4552                                            if (orderByComparator.isAscending() ^ previous) {
4553                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4554                                            }
4555                                            else {
4556                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4557                                            }
4558                                    }
4559                                    else {
4560                                            if (orderByComparator.isAscending() ^ previous) {
4561                                                    query.append(ORDER_BY_ASC);
4562                                            }
4563                                            else {
4564                                                    query.append(ORDER_BY_DESC);
4565                                            }
4566                                    }
4567                            }
4568                    }
4569                    else {
4570                            if (getDB().isSupportsInlineDistinct()) {
4571                                    query.append(DLFileShortcutModelImpl.ORDER_BY_JPQL);
4572                            }
4573                            else {
4574                                    query.append(DLFileShortcutModelImpl.ORDER_BY_SQL);
4575                            }
4576                    }
4577    
4578                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4579                                    DLFileShortcut.class.getName(),
4580                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4581    
4582                    SQLQuery q = session.createSQLQuery(sql);
4583    
4584                    q.setFirstResult(0);
4585                    q.setMaxResults(2);
4586    
4587                    if (getDB().isSupportsInlineDistinct()) {
4588                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
4589                    }
4590                    else {
4591                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
4592                    }
4593    
4594                    QueryPos qPos = QueryPos.getInstance(q);
4595    
4596                    qPos.add(groupId);
4597    
4598                    qPos.add(folderId);
4599    
4600                    qPos.add(active);
4601    
4602                    qPos.add(status);
4603    
4604                    if (orderByComparator != null) {
4605                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
4606    
4607                            for (Object value : values) {
4608                                    qPos.add(value);
4609                            }
4610                    }
4611    
4612                    List<DLFileShortcut> list = q.list();
4613    
4614                    if (list.size() == 2) {
4615                            return list.get(1);
4616                    }
4617                    else {
4618                            return null;
4619                    }
4620            }
4621    
4622            /**
4623             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63; from the database.
4624             *
4625             * @param groupId the group ID
4626             * @param folderId the folder ID
4627             * @param active the active
4628             * @param status the status
4629             * @throws SystemException if a system exception occurred
4630             */
4631            public void removeByG_F_A_S(long groupId, long folderId, boolean active,
4632                    int status) throws SystemException {
4633                    for (DLFileShortcut dlFileShortcut : findByG_F_A_S(groupId, folderId,
4634                                    active, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4635                            remove(dlFileShortcut);
4636                    }
4637            }
4638    
4639            /**
4640             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63; and active = &#63; and status = &#63;.
4641             *
4642             * @param groupId the group ID
4643             * @param folderId the folder ID
4644             * @param active the active
4645             * @param status the status
4646             * @return the number of matching document library file shortcuts
4647             * @throws SystemException if a system exception occurred
4648             */
4649            public int countByG_F_A_S(long groupId, long folderId, boolean active,
4650                    int status) throws SystemException {
4651                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_A_S;
4652    
4653                    Object[] finderArgs = new Object[] { groupId, folderId, active, status };
4654    
4655                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4656                                    this);
4657    
4658                    if (count == null) {
4659                            StringBundler query = new StringBundler(5);
4660    
4661                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
4662    
4663                            query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
4664    
4665                            query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
4666    
4667                            query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2);
4668    
4669                            query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
4670    
4671                            String sql = query.toString();
4672    
4673                            Session session = null;
4674    
4675                            try {
4676                                    session = openSession();
4677    
4678                                    Query q = session.createQuery(sql);
4679    
4680                                    QueryPos qPos = QueryPos.getInstance(q);
4681    
4682                                    qPos.add(groupId);
4683    
4684                                    qPos.add(folderId);
4685    
4686                                    qPos.add(active);
4687    
4688                                    qPos.add(status);
4689    
4690                                    count = (Long)q.uniqueResult();
4691    
4692                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4693                            }
4694                            catch (Exception e) {
4695                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4696    
4697                                    throw processException(e);
4698                            }
4699                            finally {
4700                                    closeSession(session);
4701                            }
4702                    }
4703    
4704                    return count.intValue();
4705            }
4706    
4707            /**
4708             * 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;.
4709             *
4710             * @param groupId the group ID
4711             * @param folderId the folder ID
4712             * @param active the active
4713             * @param status the status
4714             * @return the number of matching document library file shortcuts that the user has permission to view
4715             * @throws SystemException if a system exception occurred
4716             */
4717            public int filterCountByG_F_A_S(long groupId, long folderId,
4718                    boolean active, int status) throws SystemException {
4719                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4720                            return countByG_F_A_S(groupId, folderId, active, status);
4721                    }
4722    
4723                    StringBundler query = new StringBundler(5);
4724    
4725                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
4726    
4727                    query.append(_FINDER_COLUMN_G_F_A_S_GROUPID_2);
4728    
4729                    query.append(_FINDER_COLUMN_G_F_A_S_FOLDERID_2);
4730    
4731                    query.append(_FINDER_COLUMN_G_F_A_S_ACTIVE_2_SQL);
4732    
4733                    query.append(_FINDER_COLUMN_G_F_A_S_STATUS_2);
4734    
4735                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4736                                    DLFileShortcut.class.getName(),
4737                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4738    
4739                    Session session = null;
4740    
4741                    try {
4742                            session = openSession();
4743    
4744                            SQLQuery q = session.createSQLQuery(sql);
4745    
4746                            q.addScalar(COUNT_COLUMN_NAME,
4747                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4748    
4749                            QueryPos qPos = QueryPos.getInstance(q);
4750    
4751                            qPos.add(groupId);
4752    
4753                            qPos.add(folderId);
4754    
4755                            qPos.add(active);
4756    
4757                            qPos.add(status);
4758    
4759                            Long count = (Long)q.uniqueResult();
4760    
4761                            return count.intValue();
4762                    }
4763                    catch (Exception e) {
4764                            throw processException(e);
4765                    }
4766                    finally {
4767                            closeSession(session);
4768                    }
4769            }
4770    
4771            private static final String _FINDER_COLUMN_G_F_A_S_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
4772            private static final String _FINDER_COLUMN_G_F_A_S_FOLDERID_2 = "dlFileShortcut.folderId = ? AND ";
4773            private static final String _FINDER_COLUMN_G_F_A_S_ACTIVE_2 = "dlFileShortcut.active = ? AND ";
4774            private static final String _FINDER_COLUMN_G_F_A_S_ACTIVE_2_SQL = "dlFileShortcut.active_ = ? AND ";
4775            private static final String _FINDER_COLUMN_G_F_A_S_STATUS_2 = "dlFileShortcut.status = ?";
4776    
4777            /**
4778             * Caches the document library file shortcut in the entity cache if it is enabled.
4779             *
4780             * @param dlFileShortcut the document library file shortcut
4781             */
4782            public void cacheResult(DLFileShortcut dlFileShortcut) {
4783                    EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
4784                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
4785                            dlFileShortcut);
4786    
4787                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
4788                            new Object[] { dlFileShortcut.getUuid(), dlFileShortcut.getGroupId() },
4789                            dlFileShortcut);
4790    
4791                    dlFileShortcut.resetOriginalValues();
4792            }
4793    
4794            /**
4795             * Caches the document library file shortcuts in the entity cache if it is enabled.
4796             *
4797             * @param dlFileShortcuts the document library file shortcuts
4798             */
4799            public void cacheResult(List<DLFileShortcut> dlFileShortcuts) {
4800                    for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
4801                            if (EntityCacheUtil.getResult(
4802                                                    DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
4803                                                    DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey()) == null) {
4804                                    cacheResult(dlFileShortcut);
4805                            }
4806                            else {
4807                                    dlFileShortcut.resetOriginalValues();
4808                            }
4809                    }
4810            }
4811    
4812            /**
4813             * Clears the cache for all document library file shortcuts.
4814             *
4815             * <p>
4816             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
4817             * </p>
4818             */
4819            @Override
4820            public void clearCache() {
4821                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4822                            CacheRegistryUtil.clear(DLFileShortcutImpl.class.getName());
4823                    }
4824    
4825                    EntityCacheUtil.clearCache(DLFileShortcutImpl.class.getName());
4826    
4827                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4828                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4829                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4830            }
4831    
4832            /**
4833             * Clears the cache for the document library file shortcut.
4834             *
4835             * <p>
4836             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
4837             * </p>
4838             */
4839            @Override
4840            public void clearCache(DLFileShortcut dlFileShortcut) {
4841                    EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
4842                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
4843    
4844                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4845                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4846    
4847                    clearUniqueFindersCache(dlFileShortcut);
4848            }
4849    
4850            @Override
4851            public void clearCache(List<DLFileShortcut> dlFileShortcuts) {
4852                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4853                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4854    
4855                    for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
4856                            EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
4857                                    DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
4858    
4859                            clearUniqueFindersCache(dlFileShortcut);
4860                    }
4861            }
4862    
4863            protected void cacheUniqueFindersCache(DLFileShortcut dlFileShortcut) {
4864                    if (dlFileShortcut.isNew()) {
4865                            Object[] args = new Object[] {
4866                                            dlFileShortcut.getUuid(), dlFileShortcut.getGroupId()
4867                                    };
4868    
4869                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
4870                                    Long.valueOf(1));
4871                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
4872                                    dlFileShortcut);
4873                    }
4874                    else {
4875                            DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
4876    
4877                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
4878                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
4879                                    Object[] args = new Object[] {
4880                                                    dlFileShortcut.getUuid(), dlFileShortcut.getGroupId()
4881                                            };
4882    
4883                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
4884                                            Long.valueOf(1));
4885                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
4886                                            dlFileShortcut);
4887                            }
4888                    }
4889            }
4890    
4891            protected void clearUniqueFindersCache(DLFileShortcut dlFileShortcut) {
4892                    DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
4893    
4894                    Object[] args = new Object[] {
4895                                    dlFileShortcut.getUuid(), dlFileShortcut.getGroupId()
4896                            };
4897    
4898                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
4899                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
4900    
4901                    if ((dlFileShortcutModelImpl.getColumnBitmask() &
4902                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
4903                            args = new Object[] {
4904                                            dlFileShortcutModelImpl.getOriginalUuid(),
4905                                            dlFileShortcutModelImpl.getOriginalGroupId()
4906                                    };
4907    
4908                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
4909                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
4910                    }
4911            }
4912    
4913            /**
4914             * Creates a new document library file shortcut with the primary key. Does not add the document library file shortcut to the database.
4915             *
4916             * @param fileShortcutId the primary key for the new document library file shortcut
4917             * @return the new document library file shortcut
4918             */
4919            public DLFileShortcut create(long fileShortcutId) {
4920                    DLFileShortcut dlFileShortcut = new DLFileShortcutImpl();
4921    
4922                    dlFileShortcut.setNew(true);
4923                    dlFileShortcut.setPrimaryKey(fileShortcutId);
4924    
4925                    String uuid = PortalUUIDUtil.generate();
4926    
4927                    dlFileShortcut.setUuid(uuid);
4928    
4929                    return dlFileShortcut;
4930            }
4931    
4932            /**
4933             * Removes the document library file shortcut with the primary key from the database. Also notifies the appropriate model listeners.
4934             *
4935             * @param fileShortcutId the primary key of the document library file shortcut
4936             * @return the document library file shortcut that was removed
4937             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
4938             * @throws SystemException if a system exception occurred
4939             */
4940            public DLFileShortcut remove(long fileShortcutId)
4941                    throws NoSuchFileShortcutException, SystemException {
4942                    return remove((Serializable)fileShortcutId);
4943            }
4944    
4945            /**
4946             * Removes the document library file shortcut with the primary key from the database. Also notifies the appropriate model listeners.
4947             *
4948             * @param primaryKey the primary key of the document library file shortcut
4949             * @return the document library file shortcut that was removed
4950             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
4951             * @throws SystemException if a system exception occurred
4952             */
4953            @Override
4954            public DLFileShortcut remove(Serializable primaryKey)
4955                    throws NoSuchFileShortcutException, SystemException {
4956                    Session session = null;
4957    
4958                    try {
4959                            session = openSession();
4960    
4961                            DLFileShortcut dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
4962                                            primaryKey);
4963    
4964                            if (dlFileShortcut == null) {
4965                                    if (_log.isWarnEnabled()) {
4966                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4967                                    }
4968    
4969                                    throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4970                                            primaryKey);
4971                            }
4972    
4973                            return remove(dlFileShortcut);
4974                    }
4975                    catch (NoSuchFileShortcutException nsee) {
4976                            throw nsee;
4977                    }
4978                    catch (Exception e) {
4979                            throw processException(e);
4980                    }
4981                    finally {
4982                            closeSession(session);
4983                    }
4984            }
4985    
4986            @Override
4987            protected DLFileShortcut removeImpl(DLFileShortcut dlFileShortcut)
4988                    throws SystemException {
4989                    dlFileShortcut = toUnwrappedModel(dlFileShortcut);
4990    
4991                    Session session = null;
4992    
4993                    try {
4994                            session = openSession();
4995    
4996                            if (!session.contains(dlFileShortcut)) {
4997                                    dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
4998                                                    dlFileShortcut.getPrimaryKeyObj());
4999                            }
5000    
5001                            if (dlFileShortcut != null) {
5002                                    session.delete(dlFileShortcut);
5003                            }
5004                    }
5005                    catch (Exception e) {
5006                            throw processException(e);
5007                    }
5008                    finally {
5009                            closeSession(session);
5010                    }
5011    
5012                    if (dlFileShortcut != null) {
5013                            clearCache(dlFileShortcut);
5014                    }
5015    
5016                    return dlFileShortcut;
5017            }
5018    
5019            @Override
5020            public DLFileShortcut updateImpl(
5021                    com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut)
5022                    throws SystemException {
5023                    dlFileShortcut = toUnwrappedModel(dlFileShortcut);
5024    
5025                    boolean isNew = dlFileShortcut.isNew();
5026    
5027                    DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
5028    
5029                    if (Validator.isNull(dlFileShortcut.getUuid())) {
5030                            String uuid = PortalUUIDUtil.generate();
5031    
5032                            dlFileShortcut.setUuid(uuid);
5033                    }
5034    
5035                    Session session = null;
5036    
5037                    try {
5038                            session = openSession();
5039    
5040                            if (dlFileShortcut.isNew()) {
5041                                    session.save(dlFileShortcut);
5042    
5043                                    dlFileShortcut.setNew(false);
5044                            }
5045                            else {
5046                                    session.merge(dlFileShortcut);
5047                            }
5048                    }
5049                    catch (Exception e) {
5050                            throw processException(e);
5051                    }
5052                    finally {
5053                            closeSession(session);
5054                    }
5055    
5056                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5057    
5058                    if (isNew || !DLFileShortcutModelImpl.COLUMN_BITMASK_ENABLED) {
5059                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5060                    }
5061    
5062                    else {
5063                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
5064                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
5065                                    Object[] args = new Object[] {
5066                                                    dlFileShortcutModelImpl.getOriginalUuid()
5067                                            };
5068    
5069                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5070                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5071                                            args);
5072    
5073                                    args = new Object[] { dlFileShortcutModelImpl.getUuid() };
5074    
5075                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5076                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5077                                            args);
5078                            }
5079    
5080                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
5081                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
5082                                    Object[] args = new Object[] {
5083                                                    dlFileShortcutModelImpl.getOriginalUuid(),
5084                                                    dlFileShortcutModelImpl.getOriginalCompanyId()
5085                                            };
5086    
5087                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5088                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5089                                            args);
5090    
5091                                    args = new Object[] {
5092                                                    dlFileShortcutModelImpl.getUuid(),
5093                                                    dlFileShortcutModelImpl.getCompanyId()
5094                                            };
5095    
5096                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5097                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5098                                            args);
5099                            }
5100    
5101                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
5102                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID.getColumnBitmask()) != 0) {
5103                                    Object[] args = new Object[] {
5104                                                    dlFileShortcutModelImpl.getOriginalToFileEntryId()
5105                                            };
5106    
5107                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
5108                                            args);
5109                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID,
5110                                            args);
5111    
5112                                    args = new Object[] { dlFileShortcutModelImpl.getToFileEntryId() };
5113    
5114                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
5115                                            args);
5116                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID,
5117                                            args);
5118                            }
5119    
5120                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
5121                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
5122                                    Object[] args = new Object[] {
5123                                                    dlFileShortcutModelImpl.getOriginalGroupId(),
5124                                                    dlFileShortcutModelImpl.getOriginalFolderId()
5125                                            };
5126    
5127                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
5128                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
5129                                            args);
5130    
5131                                    args = new Object[] {
5132                                                    dlFileShortcutModelImpl.getGroupId(),
5133                                                    dlFileShortcutModelImpl.getFolderId()
5134                                            };
5135    
5136                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
5137                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
5138                                            args);
5139                            }
5140    
5141                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
5142                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A.getColumnBitmask()) != 0) {
5143                                    Object[] args = new Object[] {
5144                                                    dlFileShortcutModelImpl.getOriginalGroupId(),
5145                                                    dlFileShortcutModelImpl.getOriginalFolderId(),
5146                                                    dlFileShortcutModelImpl.getOriginalActive()
5147                                            };
5148    
5149                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_A, args);
5150                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A,
5151                                            args);
5152    
5153                                    args = new Object[] {
5154                                                    dlFileShortcutModelImpl.getGroupId(),
5155                                                    dlFileShortcutModelImpl.getFolderId(),
5156                                                    dlFileShortcutModelImpl.getActive()
5157                                            };
5158    
5159                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_A, args);
5160                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A,
5161                                            args);
5162                            }
5163    
5164                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
5165                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S.getColumnBitmask()) != 0) {
5166                                    Object[] args = new Object[] {
5167                                                    dlFileShortcutModelImpl.getOriginalGroupId(),
5168                                                    dlFileShortcutModelImpl.getOriginalFolderId(),
5169                                                    dlFileShortcutModelImpl.getOriginalActive(),
5170                                                    dlFileShortcutModelImpl.getOriginalStatus()
5171                                            };
5172    
5173                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_A_S, args);
5174                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S,
5175                                            args);
5176    
5177                                    args = new Object[] {
5178                                                    dlFileShortcutModelImpl.getGroupId(),
5179                                                    dlFileShortcutModelImpl.getFolderId(),
5180                                                    dlFileShortcutModelImpl.getActive(),
5181                                                    dlFileShortcutModelImpl.getStatus()
5182                                            };
5183    
5184                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_A_S, args);
5185                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_A_S,
5186                                            args);
5187                            }
5188                    }
5189    
5190                    EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
5191                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
5192                            dlFileShortcut);
5193    
5194                    clearUniqueFindersCache(dlFileShortcut);
5195                    cacheUniqueFindersCache(dlFileShortcut);
5196    
5197                    return dlFileShortcut;
5198            }
5199    
5200            protected DLFileShortcut toUnwrappedModel(DLFileShortcut dlFileShortcut) {
5201                    if (dlFileShortcut instanceof DLFileShortcutImpl) {
5202                            return dlFileShortcut;
5203                    }
5204    
5205                    DLFileShortcutImpl dlFileShortcutImpl = new DLFileShortcutImpl();
5206    
5207                    dlFileShortcutImpl.setNew(dlFileShortcut.isNew());
5208                    dlFileShortcutImpl.setPrimaryKey(dlFileShortcut.getPrimaryKey());
5209    
5210                    dlFileShortcutImpl.setUuid(dlFileShortcut.getUuid());
5211                    dlFileShortcutImpl.setFileShortcutId(dlFileShortcut.getFileShortcutId());
5212                    dlFileShortcutImpl.setGroupId(dlFileShortcut.getGroupId());
5213                    dlFileShortcutImpl.setCompanyId(dlFileShortcut.getCompanyId());
5214                    dlFileShortcutImpl.setUserId(dlFileShortcut.getUserId());
5215                    dlFileShortcutImpl.setUserName(dlFileShortcut.getUserName());
5216                    dlFileShortcutImpl.setCreateDate(dlFileShortcut.getCreateDate());
5217                    dlFileShortcutImpl.setModifiedDate(dlFileShortcut.getModifiedDate());
5218                    dlFileShortcutImpl.setRepositoryId(dlFileShortcut.getRepositoryId());
5219                    dlFileShortcutImpl.setFolderId(dlFileShortcut.getFolderId());
5220                    dlFileShortcutImpl.setToFileEntryId(dlFileShortcut.getToFileEntryId());
5221                    dlFileShortcutImpl.setActive(dlFileShortcut.isActive());
5222                    dlFileShortcutImpl.setStatus(dlFileShortcut.getStatus());
5223                    dlFileShortcutImpl.setStatusByUserId(dlFileShortcut.getStatusByUserId());
5224                    dlFileShortcutImpl.setStatusByUserName(dlFileShortcut.getStatusByUserName());
5225                    dlFileShortcutImpl.setStatusDate(dlFileShortcut.getStatusDate());
5226    
5227                    return dlFileShortcutImpl;
5228            }
5229    
5230            /**
5231             * Returns the document library file shortcut with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
5232             *
5233             * @param primaryKey the primary key of the document library file shortcut
5234             * @return the document library file shortcut
5235             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
5236             * @throws SystemException if a system exception occurred
5237             */
5238            @Override
5239            public DLFileShortcut findByPrimaryKey(Serializable primaryKey)
5240                    throws NoSuchFileShortcutException, SystemException {
5241                    DLFileShortcut dlFileShortcut = fetchByPrimaryKey(primaryKey);
5242    
5243                    if (dlFileShortcut == null) {
5244                            if (_log.isWarnEnabled()) {
5245                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5246                            }
5247    
5248                            throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5249                                    primaryKey);
5250                    }
5251    
5252                    return dlFileShortcut;
5253            }
5254    
5255            /**
5256             * Returns the document library file shortcut with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileShortcutException} if it could not be found.
5257             *
5258             * @param fileShortcutId the primary key of the document library file shortcut
5259             * @return the document library file shortcut
5260             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
5261             * @throws SystemException if a system exception occurred
5262             */
5263            public DLFileShortcut findByPrimaryKey(long fileShortcutId)
5264                    throws NoSuchFileShortcutException, SystemException {
5265                    return findByPrimaryKey((Serializable)fileShortcutId);
5266            }
5267    
5268            /**
5269             * Returns the document library file shortcut with the primary key or returns <code>null</code> if it could not be found.
5270             *
5271             * @param primaryKey the primary key of the document library file shortcut
5272             * @return the document library file shortcut, or <code>null</code> if a document library file shortcut with the primary key could not be found
5273             * @throws SystemException if a system exception occurred
5274             */
5275            @Override
5276            public DLFileShortcut fetchByPrimaryKey(Serializable primaryKey)
5277                    throws SystemException {
5278                    DLFileShortcut dlFileShortcut = (DLFileShortcut)EntityCacheUtil.getResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
5279                                    DLFileShortcutImpl.class, primaryKey);
5280    
5281                    if (dlFileShortcut == _nullDLFileShortcut) {
5282                            return null;
5283                    }
5284    
5285                    if (dlFileShortcut == null) {
5286                            Session session = null;
5287    
5288                            try {
5289                                    session = openSession();
5290    
5291                                    dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
5292                                                    primaryKey);
5293    
5294                                    if (dlFileShortcut != null) {
5295                                            cacheResult(dlFileShortcut);
5296                                    }
5297                                    else {
5298                                            EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
5299                                                    DLFileShortcutImpl.class, primaryKey,
5300                                                    _nullDLFileShortcut);
5301                                    }
5302                            }
5303                            catch (Exception e) {
5304                                    EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
5305                                            DLFileShortcutImpl.class, primaryKey);
5306    
5307                                    throw processException(e);
5308                            }
5309                            finally {
5310                                    closeSession(session);
5311                            }
5312                    }
5313    
5314                    return dlFileShortcut;
5315            }
5316    
5317            /**
5318             * Returns the document library file shortcut with the primary key or returns <code>null</code> if it could not be found.
5319             *
5320             * @param fileShortcutId the primary key of the document library file shortcut
5321             * @return the document library file shortcut, or <code>null</code> if a document library file shortcut with the primary key could not be found
5322             * @throws SystemException if a system exception occurred
5323             */
5324            public DLFileShortcut fetchByPrimaryKey(long fileShortcutId)
5325                    throws SystemException {
5326                    return fetchByPrimaryKey((Serializable)fileShortcutId);
5327            }
5328    
5329            /**
5330             * Returns all the document library file shortcuts.
5331             *
5332             * @return the document library file shortcuts
5333             * @throws SystemException if a system exception occurred
5334             */
5335            public List<DLFileShortcut> findAll() throws SystemException {
5336                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5337            }
5338    
5339            /**
5340             * Returns a range of all the document library file shortcuts.
5341             *
5342             * <p>
5343             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
5344             * </p>
5345             *
5346             * @param start the lower bound of the range of document library file shortcuts
5347             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
5348             * @return the range of document library file shortcuts
5349             * @throws SystemException if a system exception occurred
5350             */
5351            public List<DLFileShortcut> findAll(int start, int end)
5352                    throws SystemException {
5353                    return findAll(start, end, null);
5354            }
5355    
5356            /**
5357             * Returns an ordered range of all the document library file shortcuts.
5358             *
5359             * <p>
5360             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.documentlibrary.model.impl.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.
5361             * </p>
5362             *
5363             * @param start the lower bound of the range of document library file shortcuts
5364             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
5365             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5366             * @return the ordered range of document library file shortcuts
5367             * @throws SystemException if a system exception occurred
5368             */
5369            public List<DLFileShortcut> findAll(int start, int end,
5370                    OrderByComparator orderByComparator) throws SystemException {
5371                    boolean pagination = true;
5372                    FinderPath finderPath = null;
5373                    Object[] finderArgs = null;
5374    
5375                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5376                                    (orderByComparator == null)) {
5377                            pagination = false;
5378                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5379                            finderArgs = FINDER_ARGS_EMPTY;
5380                    }
5381                    else {
5382                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5383                            finderArgs = new Object[] { start, end, orderByComparator };
5384                    }
5385    
5386                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
5387                                    finderArgs, this);
5388    
5389                    if (list == null) {
5390                            StringBundler query = null;
5391                            String sql = null;
5392    
5393                            if (orderByComparator != null) {
5394                                    query = new StringBundler(2 +
5395                                                    (orderByComparator.getOrderByFields().length * 3));
5396    
5397                                    query.append(_SQL_SELECT_DLFILESHORTCUT);
5398    
5399                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5400                                            orderByComparator);
5401    
5402                                    sql = query.toString();
5403                            }
5404                            else {
5405                                    sql = _SQL_SELECT_DLFILESHORTCUT;
5406    
5407                                    if (pagination) {
5408                                            sql = sql.concat(DLFileShortcutModelImpl.ORDER_BY_JPQL);
5409                                    }
5410                            }
5411    
5412                            Session session = null;
5413    
5414                            try {
5415                                    session = openSession();
5416    
5417                                    Query q = session.createQuery(sql);
5418    
5419                                    if (!pagination) {
5420                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
5421                                                            getDialect(), start, end, false);
5422    
5423                                            Collections.sort(list);
5424    
5425                                            list = new UnmodifiableList<DLFileShortcut>(list);
5426                                    }
5427                                    else {
5428                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
5429                                                            getDialect(), start, end);
5430                                    }
5431    
5432                                    cacheResult(list);
5433    
5434                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5435                            }
5436                            catch (Exception e) {
5437                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5438    
5439                                    throw processException(e);
5440                            }
5441                            finally {
5442                                    closeSession(session);
5443                            }
5444                    }
5445    
5446                    return list;
5447            }
5448    
5449            /**
5450             * Removes all the document library file shortcuts from the database.
5451             *
5452             * @throws SystemException if a system exception occurred
5453             */
5454            public void removeAll() throws SystemException {
5455                    for (DLFileShortcut dlFileShortcut : findAll()) {
5456                            remove(dlFileShortcut);
5457                    }
5458            }
5459    
5460            /**
5461             * Returns the number of document library file shortcuts.
5462             *
5463             * @return the number of document library file shortcuts
5464             * @throws SystemException if a system exception occurred
5465             */
5466            public int countAll() throws SystemException {
5467                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5468                                    FINDER_ARGS_EMPTY, this);
5469    
5470                    if (count == null) {
5471                            Session session = null;
5472    
5473                            try {
5474                                    session = openSession();
5475    
5476                                    Query q = session.createQuery(_SQL_COUNT_DLFILESHORTCUT);
5477    
5478                                    count = (Long)q.uniqueResult();
5479    
5480                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5481                                            FINDER_ARGS_EMPTY, count);
5482                            }
5483                            catch (Exception e) {
5484                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5485                                            FINDER_ARGS_EMPTY);
5486    
5487                                    throw processException(e);
5488                            }
5489                            finally {
5490                                    closeSession(session);
5491                            }
5492                    }
5493    
5494                    return count.intValue();
5495            }
5496    
5497            @Override
5498            protected Set<String> getBadColumnNames() {
5499                    return _badColumnNames;
5500            }
5501    
5502            /**
5503             * Initializes the document library file shortcut persistence.
5504             */
5505            public void afterPropertiesSet() {
5506                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5507                                            com.liferay.portal.util.PropsUtil.get(
5508                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileShortcut")));
5509    
5510                    if (listenerClassNames.length > 0) {
5511                            try {
5512                                    List<ModelListener<DLFileShortcut>> listenersList = new ArrayList<ModelListener<DLFileShortcut>>();
5513    
5514                                    for (String listenerClassName : listenerClassNames) {
5515                                            listenersList.add((ModelListener<DLFileShortcut>)InstanceFactory.newInstance(
5516                                                            getClassLoader(), listenerClassName));
5517                                    }
5518    
5519                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5520                            }
5521                            catch (Exception e) {
5522                                    _log.error(e);
5523                            }
5524                    }
5525            }
5526    
5527            public void destroy() {
5528                    EntityCacheUtil.removeCache(DLFileShortcutImpl.class.getName());
5529                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5530                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5531                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5532            }
5533    
5534            private static final String _SQL_SELECT_DLFILESHORTCUT = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut";
5535            private static final String _SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ";
5536            private static final String _SQL_COUNT_DLFILESHORTCUT = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut";
5537            private static final String _SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut WHERE ";
5538            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileShortcut.fileShortcutId";
5539            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT DISTINCT {dlFileShortcut.*} FROM DLFileShortcut dlFileShortcut WHERE ";
5540            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1 =
5541                    "SELECT {DLFileShortcut.*} FROM (SELECT DISTINCT dlFileShortcut.fileShortcutId FROM DLFileShortcut dlFileShortcut WHERE ";
5542            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2 =
5543                    ") TEMP_TABLE INNER JOIN DLFileShortcut ON TEMP_TABLE.fileShortcutId = DLFileShortcut.fileShortcutId";
5544            private static final String _FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(DISTINCT dlFileShortcut.fileShortcutId) AS COUNT_VALUE FROM DLFileShortcut dlFileShortcut WHERE ";
5545            private static final String _FILTER_ENTITY_ALIAS = "dlFileShortcut";
5546            private static final String _FILTER_ENTITY_TABLE = "DLFileShortcut";
5547            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileShortcut.";
5548            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileShortcut.";
5549            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileShortcut exists with the primary key ";
5550            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileShortcut exists with the key {";
5551            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5552            private static Log _log = LogFactoryUtil.getLog(DLFileShortcutPersistenceImpl.class);
5553            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
5554                                    "uuid", "active"
5555                            });
5556            private static DLFileShortcut _nullDLFileShortcut = new DLFileShortcutImpl() {
5557                            @Override
5558                            public Object clone() {
5559                                    return this;
5560                            }
5561    
5562                            @Override
5563                            public CacheModel<DLFileShortcut> toCacheModel() {
5564                                    return _nullDLFileShortcutCacheModel;
5565                            }
5566                    };
5567    
5568            private static CacheModel<DLFileShortcut> _nullDLFileShortcutCacheModel = new CacheModel<DLFileShortcut>() {
5569                            public DLFileShortcut toEntityModel() {
5570                                    return _nullDLFileShortcut;
5571                            }
5572                    };
5573    }