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