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