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