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