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