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