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