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