001    /**
002     * Copyright (c) 2000-2012 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;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.BatchSessionUtil;
043    import com.liferay.portal.service.persistence.ResourcePersistence;
044    import com.liferay.portal.service.persistence.UserPersistence;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
048    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
049    import com.liferay.portlet.documentlibrary.NoSuchFileShortcutException;
050    import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
051    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutImpl;
052    import com.liferay.portlet.documentlibrary.model.impl.DLFileShortcutModelImpl;
053    
054    import java.io.Serializable;
055    
056    import java.util.ArrayList;
057    import java.util.Collections;
058    import java.util.List;
059    
060    /**
061     * The persistence implementation for the document library file shortcut service.
062     *
063     * <p>
064     * Caching information and settings can be found in <code>portal.properties</code>
065     * </p>
066     *
067     * @author Brian Wing Shun Chan
068     * @see DLFileShortcutPersistence
069     * @see DLFileShortcutUtil
070     * @generated
071     */
072    public class DLFileShortcutPersistenceImpl extends BasePersistenceImpl<DLFileShortcut>
073            implements DLFileShortcutPersistence {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * 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.
078             */
079            public static final String FINDER_CLASS_NAME_ENTITY = DLFileShortcutImpl.class.getName();
080            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List1";
082            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083                    ".List2";
084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
085                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
086                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
087                            "findByUuid",
088                            new String[] {
089                                    String.class.getName(),
090                                    
091                            "java.lang.Integer", "java.lang.Integer",
092                                    "com.liferay.portal.kernel.util.OrderByComparator"
093                            });
094            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
095                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
096                            DLFileShortcutImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
098                            new String[] { String.class.getName() },
099                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK);
100            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
101                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
103                            new String[] { String.class.getName() });
104            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
105                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
106                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_ENTITY,
107                            "fetchByUUID_G",
108                            new String[] { String.class.getName(), Long.class.getName() },
109                            DLFileShortcutModelImpl.UUID_COLUMN_BITMASK |
110                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK);
111            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
112                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
114                            new String[] { String.class.getName(), Long.class.getName() });
115            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TOFILEENTRYID =
116                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
117                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
118                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
119                            "findByToFileEntryId",
120                            new String[] {
121                                    Long.class.getName(),
122                                    
123                            "java.lang.Integer", "java.lang.Integer",
124                                    "com.liferay.portal.kernel.util.OrderByComparator"
125                            });
126            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID =
127                    new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
128                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
129                            DLFileShortcutImpl.class,
130                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByToFileEntryId",
131                            new String[] { Long.class.getName() },
132                            DLFileShortcutModelImpl.TOFILEENTRYID_COLUMN_BITMASK);
133            public static final FinderPath FINDER_PATH_COUNT_BY_TOFILEENTRYID = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
134                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
135                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByToFileEntryId",
136                            new String[] { Long.class.getName() });
137            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
138                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
139                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
140                            "findByG_F",
141                            new String[] {
142                                    Long.class.getName(), Long.class.getName(),
143                                    
144                            "java.lang.Integer", "java.lang.Integer",
145                                    "com.liferay.portal.kernel.util.OrderByComparator"
146                            });
147            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
148                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
149                            DLFileShortcutImpl.class,
150                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
151                            new String[] { Long.class.getName(), Long.class.getName() },
152                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
153                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK);
154            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
155                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
156                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
157                            new String[] { Long.class.getName(), Long.class.getName() });
158            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
159                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
160                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
161                            "findByG_F_S",
162                            new String[] {
163                                    Long.class.getName(), Long.class.getName(),
164                                    Integer.class.getName(),
165                                    
166                            "java.lang.Integer", "java.lang.Integer",
167                                    "com.liferay.portal.kernel.util.OrderByComparator"
168                            });
169            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
170                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
171                            DLFileShortcutImpl.class,
172                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_S",
173                            new String[] {
174                                    Long.class.getName(), Long.class.getName(),
175                                    Integer.class.getName()
176                            },
177                            DLFileShortcutModelImpl.GROUPID_COLUMN_BITMASK |
178                            DLFileShortcutModelImpl.FOLDERID_COLUMN_BITMASK |
179                            DLFileShortcutModelImpl.STATUS_COLUMN_BITMASK);
180            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
181                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
182                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_S",
183                            new String[] {
184                                    Long.class.getName(), Long.class.getName(),
185                                    Integer.class.getName()
186                            });
187            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
188                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
189                            DLFileShortcutImpl.class,
190                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
191            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
192                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED,
193                            DLFileShortcutImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
194                            "findAll", new String[0]);
195            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
196                            DLFileShortcutModelImpl.FINDER_CACHE_ENABLED, Long.class,
197                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
198    
199            /**
200             * Caches the document library file shortcut in the entity cache if it is enabled.
201             *
202             * @param dlFileShortcut the document library file shortcut
203             */
204            public void cacheResult(DLFileShortcut dlFileShortcut) {
205                    EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
206                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
207                            dlFileShortcut);
208    
209                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
210                            new Object[] {
211                                    dlFileShortcut.getUuid(),
212                                    Long.valueOf(dlFileShortcut.getGroupId())
213                            }, dlFileShortcut);
214    
215                    dlFileShortcut.resetOriginalValues();
216            }
217    
218            /**
219             * Caches the document library file shortcuts in the entity cache if it is enabled.
220             *
221             * @param dlFileShortcuts the document library file shortcuts
222             */
223            public void cacheResult(List<DLFileShortcut> dlFileShortcuts) {
224                    for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
225                            if (EntityCacheUtil.getResult(
226                                                    DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
227                                                    DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey()) == null) {
228                                    cacheResult(dlFileShortcut);
229                            }
230                            else {
231                                    dlFileShortcut.resetOriginalValues();
232                            }
233                    }
234            }
235    
236            /**
237             * Clears the cache for all document library file shortcuts.
238             *
239             * <p>
240             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
241             * </p>
242             */
243            @Override
244            public void clearCache() {
245                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
246                            CacheRegistryUtil.clear(DLFileShortcutImpl.class.getName());
247                    }
248    
249                    EntityCacheUtil.clearCache(DLFileShortcutImpl.class.getName());
250    
251                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
252                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
253                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
254            }
255    
256            /**
257             * Clears the cache for the document library file shortcut.
258             *
259             * <p>
260             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
261             * </p>
262             */
263            @Override
264            public void clearCache(DLFileShortcut dlFileShortcut) {
265                    EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
266                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
267    
268                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
269                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
270    
271                    clearUniqueFindersCache(dlFileShortcut);
272            }
273    
274            @Override
275            public void clearCache(List<DLFileShortcut> dlFileShortcuts) {
276                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
277                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
278    
279                    for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {
280                            EntityCacheUtil.removeResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
281                                    DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey());
282    
283                            clearUniqueFindersCache(dlFileShortcut);
284                    }
285            }
286    
287            protected void clearUniqueFindersCache(DLFileShortcut dlFileShortcut) {
288                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
289                            new Object[] {
290                                    dlFileShortcut.getUuid(),
291                                    Long.valueOf(dlFileShortcut.getGroupId())
292                            });
293            }
294    
295            /**
296             * Creates a new document library file shortcut with the primary key. Does not add the document library file shortcut to the database.
297             *
298             * @param fileShortcutId the primary key for the new document library file shortcut
299             * @return the new document library file shortcut
300             */
301            public DLFileShortcut create(long fileShortcutId) {
302                    DLFileShortcut dlFileShortcut = new DLFileShortcutImpl();
303    
304                    dlFileShortcut.setNew(true);
305                    dlFileShortcut.setPrimaryKey(fileShortcutId);
306    
307                    String uuid = PortalUUIDUtil.generate();
308    
309                    dlFileShortcut.setUuid(uuid);
310    
311                    return dlFileShortcut;
312            }
313    
314            /**
315             * Removes the document library file shortcut with the primary key from the database. Also notifies the appropriate model listeners.
316             *
317             * @param fileShortcutId the primary key of the document library file shortcut
318             * @return the document library file shortcut that was removed
319             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
320             * @throws SystemException if a system exception occurred
321             */
322            public DLFileShortcut remove(long fileShortcutId)
323                    throws NoSuchFileShortcutException, SystemException {
324                    return remove(Long.valueOf(fileShortcutId));
325            }
326    
327            /**
328             * Removes the document library file shortcut with the primary key from the database. Also notifies the appropriate model listeners.
329             *
330             * @param primaryKey the primary key of the document library file shortcut
331             * @return the document library file shortcut that was removed
332             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
333             * @throws SystemException if a system exception occurred
334             */
335            @Override
336            public DLFileShortcut remove(Serializable primaryKey)
337                    throws NoSuchFileShortcutException, SystemException {
338                    Session session = null;
339    
340                    try {
341                            session = openSession();
342    
343                            DLFileShortcut dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
344                                            primaryKey);
345    
346                            if (dlFileShortcut == null) {
347                                    if (_log.isWarnEnabled()) {
348                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
349                                    }
350    
351                                    throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
352                                            primaryKey);
353                            }
354    
355                            return remove(dlFileShortcut);
356                    }
357                    catch (NoSuchFileShortcutException nsee) {
358                            throw nsee;
359                    }
360                    catch (Exception e) {
361                            throw processException(e);
362                    }
363                    finally {
364                            closeSession(session);
365                    }
366            }
367    
368            @Override
369            protected DLFileShortcut removeImpl(DLFileShortcut dlFileShortcut)
370                    throws SystemException {
371                    dlFileShortcut = toUnwrappedModel(dlFileShortcut);
372    
373                    Session session = null;
374    
375                    try {
376                            session = openSession();
377    
378                            BatchSessionUtil.delete(session, dlFileShortcut);
379                    }
380                    catch (Exception e) {
381                            throw processException(e);
382                    }
383                    finally {
384                            closeSession(session);
385                    }
386    
387                    clearCache(dlFileShortcut);
388    
389                    return dlFileShortcut;
390            }
391    
392            @Override
393            public DLFileShortcut updateImpl(
394                    com.liferay.portlet.documentlibrary.model.DLFileShortcut dlFileShortcut,
395                    boolean merge) throws SystemException {
396                    dlFileShortcut = toUnwrappedModel(dlFileShortcut);
397    
398                    boolean isNew = dlFileShortcut.isNew();
399    
400                    DLFileShortcutModelImpl dlFileShortcutModelImpl = (DLFileShortcutModelImpl)dlFileShortcut;
401    
402                    if (Validator.isNull(dlFileShortcut.getUuid())) {
403                            String uuid = PortalUUIDUtil.generate();
404    
405                            dlFileShortcut.setUuid(uuid);
406                    }
407    
408                    Session session = null;
409    
410                    try {
411                            session = openSession();
412    
413                            BatchSessionUtil.update(session, dlFileShortcut, merge);
414    
415                            dlFileShortcut.setNew(false);
416                    }
417                    catch (Exception e) {
418                            throw processException(e);
419                    }
420                    finally {
421                            closeSession(session);
422                    }
423    
424                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
425    
426                    if (isNew || !DLFileShortcutModelImpl.COLUMN_BITMASK_ENABLED) {
427                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
428                    }
429    
430                    else {
431                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
432                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
433                                    Object[] args = new Object[] {
434                                                    dlFileShortcutModelImpl.getOriginalUuid()
435                                            };
436    
437                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
438                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
439                                            args);
440    
441                                    args = new Object[] { dlFileShortcutModelImpl.getUuid() };
442    
443                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
444                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
445                                            args);
446                            }
447    
448                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
449                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID.getColumnBitmask()) != 0) {
450                                    Object[] args = new Object[] {
451                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalToFileEntryId())
452                                            };
453    
454                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
455                                            args);
456                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID,
457                                            args);
458    
459                                    args = new Object[] {
460                                                    Long.valueOf(dlFileShortcutModelImpl.getToFileEntryId())
461                                            };
462    
463                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
464                                            args);
465                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID,
466                                            args);
467                            }
468    
469                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
470                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
471                                    Object[] args = new Object[] {
472                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalGroupId()),
473                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalFolderId())
474                                            };
475    
476                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
477                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
478                                            args);
479    
480                                    args = new Object[] {
481                                                    Long.valueOf(dlFileShortcutModelImpl.getGroupId()),
482                                                    Long.valueOf(dlFileShortcutModelImpl.getFolderId())
483                                            };
484    
485                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
486                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
487                                            args);
488                            }
489    
490                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
491                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S.getColumnBitmask()) != 0) {
492                                    Object[] args = new Object[] {
493                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalGroupId()),
494                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalFolderId()),
495                                                    Integer.valueOf(dlFileShortcutModelImpl.getOriginalStatus())
496                                            };
497    
498                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
499                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
500                                            args);
501    
502                                    args = new Object[] {
503                                                    Long.valueOf(dlFileShortcutModelImpl.getGroupId()),
504                                                    Long.valueOf(dlFileShortcutModelImpl.getFolderId()),
505                                                    Integer.valueOf(dlFileShortcutModelImpl.getStatus())
506                                            };
507    
508                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
509                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
510                                            args);
511                            }
512                    }
513    
514                    EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
515                            DLFileShortcutImpl.class, dlFileShortcut.getPrimaryKey(),
516                            dlFileShortcut);
517    
518                    if (isNew) {
519                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
520                                    new Object[] {
521                                            dlFileShortcut.getUuid(),
522                                            Long.valueOf(dlFileShortcut.getGroupId())
523                                    }, dlFileShortcut);
524                    }
525                    else {
526                            if ((dlFileShortcutModelImpl.getColumnBitmask() &
527                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
528                                    Object[] args = new Object[] {
529                                                    dlFileShortcutModelImpl.getOriginalUuid(),
530                                                    Long.valueOf(dlFileShortcutModelImpl.getOriginalGroupId())
531                                            };
532    
533                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
534                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
535    
536                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
537                                            new Object[] {
538                                                    dlFileShortcut.getUuid(),
539                                                    Long.valueOf(dlFileShortcut.getGroupId())
540                                            }, dlFileShortcut);
541                            }
542                    }
543    
544                    return dlFileShortcut;
545            }
546    
547            protected DLFileShortcut toUnwrappedModel(DLFileShortcut dlFileShortcut) {
548                    if (dlFileShortcut instanceof DLFileShortcutImpl) {
549                            return dlFileShortcut;
550                    }
551    
552                    DLFileShortcutImpl dlFileShortcutImpl = new DLFileShortcutImpl();
553    
554                    dlFileShortcutImpl.setNew(dlFileShortcut.isNew());
555                    dlFileShortcutImpl.setPrimaryKey(dlFileShortcut.getPrimaryKey());
556    
557                    dlFileShortcutImpl.setUuid(dlFileShortcut.getUuid());
558                    dlFileShortcutImpl.setFileShortcutId(dlFileShortcut.getFileShortcutId());
559                    dlFileShortcutImpl.setGroupId(dlFileShortcut.getGroupId());
560                    dlFileShortcutImpl.setCompanyId(dlFileShortcut.getCompanyId());
561                    dlFileShortcutImpl.setUserId(dlFileShortcut.getUserId());
562                    dlFileShortcutImpl.setUserName(dlFileShortcut.getUserName());
563                    dlFileShortcutImpl.setCreateDate(dlFileShortcut.getCreateDate());
564                    dlFileShortcutImpl.setModifiedDate(dlFileShortcut.getModifiedDate());
565                    dlFileShortcutImpl.setRepositoryId(dlFileShortcut.getRepositoryId());
566                    dlFileShortcutImpl.setFolderId(dlFileShortcut.getFolderId());
567                    dlFileShortcutImpl.setToFileEntryId(dlFileShortcut.getToFileEntryId());
568                    dlFileShortcutImpl.setStatus(dlFileShortcut.getStatus());
569                    dlFileShortcutImpl.setStatusByUserId(dlFileShortcut.getStatusByUserId());
570                    dlFileShortcutImpl.setStatusByUserName(dlFileShortcut.getStatusByUserName());
571                    dlFileShortcutImpl.setStatusDate(dlFileShortcut.getStatusDate());
572    
573                    return dlFileShortcutImpl;
574            }
575    
576            /**
577             * Returns the document library file shortcut with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
578             *
579             * @param primaryKey the primary key of the document library file shortcut
580             * @return the document library file shortcut
581             * @throws com.liferay.portal.NoSuchModelException if a document library file shortcut with the primary key could not be found
582             * @throws SystemException if a system exception occurred
583             */
584            @Override
585            public DLFileShortcut findByPrimaryKey(Serializable primaryKey)
586                    throws NoSuchModelException, SystemException {
587                    return findByPrimaryKey(((Long)primaryKey).longValue());
588            }
589    
590            /**
591             * Returns the document library file shortcut with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileShortcutException} if it could not be found.
592             *
593             * @param fileShortcutId the primary key of the document library file shortcut
594             * @return the document library file shortcut
595             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
596             * @throws SystemException if a system exception occurred
597             */
598            public DLFileShortcut findByPrimaryKey(long fileShortcutId)
599                    throws NoSuchFileShortcutException, SystemException {
600                    DLFileShortcut dlFileShortcut = fetchByPrimaryKey(fileShortcutId);
601    
602                    if (dlFileShortcut == null) {
603                            if (_log.isWarnEnabled()) {
604                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileShortcutId);
605                            }
606    
607                            throw new NoSuchFileShortcutException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
608                                    fileShortcutId);
609                    }
610    
611                    return dlFileShortcut;
612            }
613    
614            /**
615             * Returns the document library file shortcut with the primary key or returns <code>null</code> if it could not be found.
616             *
617             * @param primaryKey the primary key of the document library file shortcut
618             * @return the document library file shortcut, or <code>null</code> if a document library file shortcut with the primary key could not be found
619             * @throws SystemException if a system exception occurred
620             */
621            @Override
622            public DLFileShortcut fetchByPrimaryKey(Serializable primaryKey)
623                    throws SystemException {
624                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
625            }
626    
627            /**
628             * Returns the document library file shortcut with the primary key or returns <code>null</code> if it could not be found.
629             *
630             * @param fileShortcutId the primary key of the document library file shortcut
631             * @return the document library file shortcut, or <code>null</code> if a document library file shortcut with the primary key could not be found
632             * @throws SystemException if a system exception occurred
633             */
634            public DLFileShortcut fetchByPrimaryKey(long fileShortcutId)
635                    throws SystemException {
636                    DLFileShortcut dlFileShortcut = (DLFileShortcut)EntityCacheUtil.getResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
637                                    DLFileShortcutImpl.class, fileShortcutId);
638    
639                    if (dlFileShortcut == _nullDLFileShortcut) {
640                            return null;
641                    }
642    
643                    if (dlFileShortcut == null) {
644                            Session session = null;
645    
646                            boolean hasException = false;
647    
648                            try {
649                                    session = openSession();
650    
651                                    dlFileShortcut = (DLFileShortcut)session.get(DLFileShortcutImpl.class,
652                                                    Long.valueOf(fileShortcutId));
653                            }
654                            catch (Exception e) {
655                                    hasException = true;
656    
657                                    throw processException(e);
658                            }
659                            finally {
660                                    if (dlFileShortcut != null) {
661                                            cacheResult(dlFileShortcut);
662                                    }
663                                    else if (!hasException) {
664                                            EntityCacheUtil.putResult(DLFileShortcutModelImpl.ENTITY_CACHE_ENABLED,
665                                                    DLFileShortcutImpl.class, fileShortcutId,
666                                                    _nullDLFileShortcut);
667                                    }
668    
669                                    closeSession(session);
670                            }
671                    }
672    
673                    return dlFileShortcut;
674            }
675    
676            /**
677             * Returns all the document library file shortcuts where uuid = &#63;.
678             *
679             * @param uuid the uuid
680             * @return the matching document library file shortcuts
681             * @throws SystemException if a system exception occurred
682             */
683            public List<DLFileShortcut> findByUuid(String uuid)
684                    throws SystemException {
685                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
686            }
687    
688            /**
689             * Returns a range of all the document library file shortcuts where uuid = &#63;.
690             *
691             * <p>
692             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
693             * </p>
694             *
695             * @param uuid the uuid
696             * @param start the lower bound of the range of document library file shortcuts
697             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
698             * @return the range of matching document library file shortcuts
699             * @throws SystemException if a system exception occurred
700             */
701            public List<DLFileShortcut> findByUuid(String uuid, int start, int end)
702                    throws SystemException {
703                    return findByUuid(uuid, start, end, null);
704            }
705    
706            /**
707             * Returns an ordered range of all the document library file shortcuts where uuid = &#63;.
708             *
709             * <p>
710             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
711             * </p>
712             *
713             * @param uuid the uuid
714             * @param start the lower bound of the range of document library file shortcuts
715             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
716             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
717             * @return the ordered range of matching document library file shortcuts
718             * @throws SystemException if a system exception occurred
719             */
720            public List<DLFileShortcut> findByUuid(String uuid, int start, int end,
721                    OrderByComparator orderByComparator) throws SystemException {
722                    FinderPath finderPath = null;
723                    Object[] finderArgs = null;
724    
725                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
726                                    (orderByComparator == null)) {
727                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
728                            finderArgs = new Object[] { uuid };
729                    }
730                    else {
731                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
732                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
733                    }
734    
735                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
736                                    finderArgs, this);
737    
738                    if (list == null) {
739                            StringBundler query = null;
740    
741                            if (orderByComparator != null) {
742                                    query = new StringBundler(3 +
743                                                    (orderByComparator.getOrderByFields().length * 3));
744                            }
745                            else {
746                                    query = new StringBundler(2);
747                            }
748    
749                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
750    
751                            if (uuid == null) {
752                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
753                            }
754                            else {
755                                    if (uuid.equals(StringPool.BLANK)) {
756                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
757                                    }
758                                    else {
759                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
760                                    }
761                            }
762    
763                            if (orderByComparator != null) {
764                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
765                                            orderByComparator);
766                            }
767    
768                            String sql = query.toString();
769    
770                            Session session = null;
771    
772                            try {
773                                    session = openSession();
774    
775                                    Query q = session.createQuery(sql);
776    
777                                    QueryPos qPos = QueryPos.getInstance(q);
778    
779                                    if (uuid != null) {
780                                            qPos.add(uuid);
781                                    }
782    
783                                    list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
784                                                    start, end);
785                            }
786                            catch (Exception e) {
787                                    throw processException(e);
788                            }
789                            finally {
790                                    if (list == null) {
791                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
792                                    }
793                                    else {
794                                            cacheResult(list);
795    
796                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
797                                    }
798    
799                                    closeSession(session);
800                            }
801                    }
802    
803                    return list;
804            }
805    
806            /**
807             * Returns the first document library file shortcut in the ordered set where uuid = &#63;.
808             *
809             * <p>
810             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
811             * </p>
812             *
813             * @param uuid the uuid
814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
815             * @return the first matching document library file shortcut
816             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
817             * @throws SystemException if a system exception occurred
818             */
819            public DLFileShortcut findByUuid_First(String uuid,
820                    OrderByComparator orderByComparator)
821                    throws NoSuchFileShortcutException, SystemException {
822                    List<DLFileShortcut> list = findByUuid(uuid, 0, 1, orderByComparator);
823    
824                    if (list.isEmpty()) {
825                            StringBundler msg = new StringBundler(4);
826    
827                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
828    
829                            msg.append("uuid=");
830                            msg.append(uuid);
831    
832                            msg.append(StringPool.CLOSE_CURLY_BRACE);
833    
834                            throw new NoSuchFileShortcutException(msg.toString());
835                    }
836                    else {
837                            return list.get(0);
838                    }
839            }
840    
841            /**
842             * Returns the last document library file shortcut in the ordered set where uuid = &#63;.
843             *
844             * <p>
845             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
846             * </p>
847             *
848             * @param uuid the uuid
849             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
850             * @return the last matching document library file shortcut
851             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
852             * @throws SystemException if a system exception occurred
853             */
854            public DLFileShortcut findByUuid_Last(String uuid,
855                    OrderByComparator orderByComparator)
856                    throws NoSuchFileShortcutException, SystemException {
857                    int count = countByUuid(uuid);
858    
859                    List<DLFileShortcut> list = findByUuid(uuid, count - 1, count,
860                                    orderByComparator);
861    
862                    if (list.isEmpty()) {
863                            StringBundler msg = new StringBundler(4);
864    
865                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
866    
867                            msg.append("uuid=");
868                            msg.append(uuid);
869    
870                            msg.append(StringPool.CLOSE_CURLY_BRACE);
871    
872                            throw new NoSuchFileShortcutException(msg.toString());
873                    }
874                    else {
875                            return list.get(0);
876                    }
877            }
878    
879            /**
880             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where uuid = &#63;.
881             *
882             * <p>
883             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
884             * </p>
885             *
886             * @param fileShortcutId the primary key of the current document library file shortcut
887             * @param uuid the uuid
888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
889             * @return the previous, current, and next document library file shortcut
890             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
891             * @throws SystemException if a system exception occurred
892             */
893            public DLFileShortcut[] findByUuid_PrevAndNext(long fileShortcutId,
894                    String uuid, OrderByComparator orderByComparator)
895                    throws NoSuchFileShortcutException, SystemException {
896                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
897    
898                    Session session = null;
899    
900                    try {
901                            session = openSession();
902    
903                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
904    
905                            array[0] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
906                                            orderByComparator, true);
907    
908                            array[1] = dlFileShortcut;
909    
910                            array[2] = getByUuid_PrevAndNext(session, dlFileShortcut, uuid,
911                                            orderByComparator, false);
912    
913                            return array;
914                    }
915                    catch (Exception e) {
916                            throw processException(e);
917                    }
918                    finally {
919                            closeSession(session);
920                    }
921            }
922    
923            protected DLFileShortcut getByUuid_PrevAndNext(Session session,
924                    DLFileShortcut dlFileShortcut, String uuid,
925                    OrderByComparator orderByComparator, boolean previous) {
926                    StringBundler query = null;
927    
928                    if (orderByComparator != null) {
929                            query = new StringBundler(6 +
930                                            (orderByComparator.getOrderByFields().length * 6));
931                    }
932                    else {
933                            query = new StringBundler(3);
934                    }
935    
936                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
937    
938                    if (uuid == null) {
939                            query.append(_FINDER_COLUMN_UUID_UUID_1);
940                    }
941                    else {
942                            if (uuid.equals(StringPool.BLANK)) {
943                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
944                            }
945                            else {
946                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
947                            }
948                    }
949    
950                    if (orderByComparator != null) {
951                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
952    
953                            if (orderByConditionFields.length > 0) {
954                                    query.append(WHERE_AND);
955                            }
956    
957                            for (int i = 0; i < orderByConditionFields.length; i++) {
958                                    query.append(_ORDER_BY_ENTITY_ALIAS);
959                                    query.append(orderByConditionFields[i]);
960    
961                                    if ((i + 1) < orderByConditionFields.length) {
962                                            if (orderByComparator.isAscending() ^ previous) {
963                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
964                                            }
965                                            else {
966                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
967                                            }
968                                    }
969                                    else {
970                                            if (orderByComparator.isAscending() ^ previous) {
971                                                    query.append(WHERE_GREATER_THAN);
972                                            }
973                                            else {
974                                                    query.append(WHERE_LESSER_THAN);
975                                            }
976                                    }
977                            }
978    
979                            query.append(ORDER_BY_CLAUSE);
980    
981                            String[] orderByFields = orderByComparator.getOrderByFields();
982    
983                            for (int i = 0; i < orderByFields.length; i++) {
984                                    query.append(_ORDER_BY_ENTITY_ALIAS);
985                                    query.append(orderByFields[i]);
986    
987                                    if ((i + 1) < orderByFields.length) {
988                                            if (orderByComparator.isAscending() ^ previous) {
989                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
990                                            }
991                                            else {
992                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
993                                            }
994                                    }
995                                    else {
996                                            if (orderByComparator.isAscending() ^ previous) {
997                                                    query.append(ORDER_BY_ASC);
998                                            }
999                                            else {
1000                                                    query.append(ORDER_BY_DESC);
1001                                            }
1002                                    }
1003                            }
1004                    }
1005    
1006                    String sql = query.toString();
1007    
1008                    Query q = session.createQuery(sql);
1009    
1010                    q.setFirstResult(0);
1011                    q.setMaxResults(2);
1012    
1013                    QueryPos qPos = QueryPos.getInstance(q);
1014    
1015                    if (uuid != null) {
1016                            qPos.add(uuid);
1017                    }
1018    
1019                    if (orderByComparator != null) {
1020                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1021    
1022                            for (Object value : values) {
1023                                    qPos.add(value);
1024                            }
1025                    }
1026    
1027                    List<DLFileShortcut> list = q.list();
1028    
1029                    if (list.size() == 2) {
1030                            return list.get(1);
1031                    }
1032                    else {
1033                            return null;
1034                    }
1035            }
1036    
1037            /**
1038             * Returns the document library file shortcut where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileShortcutException} if it could not be found.
1039             *
1040             * @param uuid the uuid
1041             * @param groupId the group ID
1042             * @return the matching document library file shortcut
1043             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1044             * @throws SystemException if a system exception occurred
1045             */
1046            public DLFileShortcut findByUUID_G(String uuid, long groupId)
1047                    throws NoSuchFileShortcutException, SystemException {
1048                    DLFileShortcut dlFileShortcut = fetchByUUID_G(uuid, groupId);
1049    
1050                    if (dlFileShortcut == null) {
1051                            StringBundler msg = new StringBundler(6);
1052    
1053                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1054    
1055                            msg.append("uuid=");
1056                            msg.append(uuid);
1057    
1058                            msg.append(", groupId=");
1059                            msg.append(groupId);
1060    
1061                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1062    
1063                            if (_log.isWarnEnabled()) {
1064                                    _log.warn(msg.toString());
1065                            }
1066    
1067                            throw new NoSuchFileShortcutException(msg.toString());
1068                    }
1069    
1070                    return dlFileShortcut;
1071            }
1072    
1073            /**
1074             * 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.
1075             *
1076             * @param uuid the uuid
1077             * @param groupId the group ID
1078             * @return the matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1079             * @throws SystemException if a system exception occurred
1080             */
1081            public DLFileShortcut fetchByUUID_G(String uuid, long groupId)
1082                    throws SystemException {
1083                    return fetchByUUID_G(uuid, groupId, true);
1084            }
1085    
1086            /**
1087             * 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.
1088             *
1089             * @param uuid the uuid
1090             * @param groupId the group ID
1091             * @param retrieveFromCache whether to use the finder cache
1092             * @return the matching document library file shortcut, or <code>null</code> if a matching document library file shortcut could not be found
1093             * @throws SystemException if a system exception occurred
1094             */
1095            public DLFileShortcut fetchByUUID_G(String uuid, long groupId,
1096                    boolean retrieveFromCache) throws SystemException {
1097                    Object[] finderArgs = new Object[] { uuid, groupId };
1098    
1099                    Object result = null;
1100    
1101                    if (retrieveFromCache) {
1102                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1103                                            finderArgs, this);
1104                    }
1105    
1106                    if (result == null) {
1107                            StringBundler query = new StringBundler(3);
1108    
1109                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1110    
1111                            if (uuid == null) {
1112                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1113                            }
1114                            else {
1115                                    if (uuid.equals(StringPool.BLANK)) {
1116                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1117                                    }
1118                                    else {
1119                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1120                                    }
1121                            }
1122    
1123                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1124    
1125                            String sql = query.toString();
1126    
1127                            Session session = null;
1128    
1129                            try {
1130                                    session = openSession();
1131    
1132                                    Query q = session.createQuery(sql);
1133    
1134                                    QueryPos qPos = QueryPos.getInstance(q);
1135    
1136                                    if (uuid != null) {
1137                                            qPos.add(uuid);
1138                                    }
1139    
1140                                    qPos.add(groupId);
1141    
1142                                    List<DLFileShortcut> list = q.list();
1143    
1144                                    result = list;
1145    
1146                                    DLFileShortcut dlFileShortcut = null;
1147    
1148                                    if (list.isEmpty()) {
1149                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1150                                                    finderArgs, list);
1151                                    }
1152                                    else {
1153                                            dlFileShortcut = list.get(0);
1154    
1155                                            cacheResult(dlFileShortcut);
1156    
1157                                            if ((dlFileShortcut.getUuid() == null) ||
1158                                                            !dlFileShortcut.getUuid().equals(uuid) ||
1159                                                            (dlFileShortcut.getGroupId() != groupId)) {
1160                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1161                                                            finderArgs, dlFileShortcut);
1162                                            }
1163                                    }
1164    
1165                                    return dlFileShortcut;
1166                            }
1167                            catch (Exception e) {
1168                                    throw processException(e);
1169                            }
1170                            finally {
1171                                    if (result == null) {
1172                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1173                                                    finderArgs);
1174                                    }
1175    
1176                                    closeSession(session);
1177                            }
1178                    }
1179                    else {
1180                            if (result instanceof List<?>) {
1181                                    return null;
1182                            }
1183                            else {
1184                                    return (DLFileShortcut)result;
1185                            }
1186                    }
1187            }
1188    
1189            /**
1190             * Returns all the document library file shortcuts where toFileEntryId = &#63;.
1191             *
1192             * @param toFileEntryId the to file entry ID
1193             * @return the matching document library file shortcuts
1194             * @throws SystemException if a system exception occurred
1195             */
1196            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId)
1197                    throws SystemException {
1198                    return findByToFileEntryId(toFileEntryId, QueryUtil.ALL_POS,
1199                            QueryUtil.ALL_POS, null);
1200            }
1201    
1202            /**
1203             * Returns a range of all the document library file shortcuts where toFileEntryId = &#63;.
1204             *
1205             * <p>
1206             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1207             * </p>
1208             *
1209             * @param toFileEntryId the to file entry ID
1210             * @param start the lower bound of the range of document library file shortcuts
1211             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1212             * @return the range of matching document library file shortcuts
1213             * @throws SystemException if a system exception occurred
1214             */
1215            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
1216                    int start, int end) throws SystemException {
1217                    return findByToFileEntryId(toFileEntryId, start, end, null);
1218            }
1219    
1220            /**
1221             * Returns an ordered range of all the document library file shortcuts where toFileEntryId = &#63;.
1222             *
1223             * <p>
1224             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1225             * </p>
1226             *
1227             * @param toFileEntryId the to file entry ID
1228             * @param start the lower bound of the range of document library file shortcuts
1229             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1230             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1231             * @return the ordered range of matching document library file shortcuts
1232             * @throws SystemException if a system exception occurred
1233             */
1234            public List<DLFileShortcut> findByToFileEntryId(long toFileEntryId,
1235                    int start, int end, OrderByComparator orderByComparator)
1236                    throws SystemException {
1237                    FinderPath finderPath = null;
1238                    Object[] finderArgs = null;
1239    
1240                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1241                                    (orderByComparator == null)) {
1242                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TOFILEENTRYID;
1243                            finderArgs = new Object[] { toFileEntryId };
1244                    }
1245                    else {
1246                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TOFILEENTRYID;
1247                            finderArgs = new Object[] {
1248                                            toFileEntryId,
1249                                            
1250                                            start, end, orderByComparator
1251                                    };
1252                    }
1253    
1254                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
1255                                    finderArgs, this);
1256    
1257                    if (list == null) {
1258                            StringBundler query = null;
1259    
1260                            if (orderByComparator != null) {
1261                                    query = new StringBundler(3 +
1262                                                    (orderByComparator.getOrderByFields().length * 3));
1263                            }
1264                            else {
1265                                    query = new StringBundler(2);
1266                            }
1267    
1268                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1269    
1270                            query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
1271    
1272                            if (orderByComparator != null) {
1273                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1274                                            orderByComparator);
1275                            }
1276    
1277                            String sql = query.toString();
1278    
1279                            Session session = null;
1280    
1281                            try {
1282                                    session = openSession();
1283    
1284                                    Query q = session.createQuery(sql);
1285    
1286                                    QueryPos qPos = QueryPos.getInstance(q);
1287    
1288                                    qPos.add(toFileEntryId);
1289    
1290                                    list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
1291                                                    start, end);
1292                            }
1293                            catch (Exception e) {
1294                                    throw processException(e);
1295                            }
1296                            finally {
1297                                    if (list == null) {
1298                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1299                                    }
1300                                    else {
1301                                            cacheResult(list);
1302    
1303                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1304                                    }
1305    
1306                                    closeSession(session);
1307                            }
1308                    }
1309    
1310                    return list;
1311            }
1312    
1313            /**
1314             * Returns the first document library file shortcut in the ordered set where toFileEntryId = &#63;.
1315             *
1316             * <p>
1317             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1318             * </p>
1319             *
1320             * @param toFileEntryId the to file entry ID
1321             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1322             * @return the first matching document library file shortcut
1323             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1324             * @throws SystemException if a system exception occurred
1325             */
1326            public DLFileShortcut findByToFileEntryId_First(long toFileEntryId,
1327                    OrderByComparator orderByComparator)
1328                    throws NoSuchFileShortcutException, SystemException {
1329                    List<DLFileShortcut> list = findByToFileEntryId(toFileEntryId, 0, 1,
1330                                    orderByComparator);
1331    
1332                    if (list.isEmpty()) {
1333                            StringBundler msg = new StringBundler(4);
1334    
1335                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1336    
1337                            msg.append("toFileEntryId=");
1338                            msg.append(toFileEntryId);
1339    
1340                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1341    
1342                            throw new NoSuchFileShortcutException(msg.toString());
1343                    }
1344                    else {
1345                            return list.get(0);
1346                    }
1347            }
1348    
1349            /**
1350             * Returns the last document library file shortcut in the ordered set where toFileEntryId = &#63;.
1351             *
1352             * <p>
1353             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1354             * </p>
1355             *
1356             * @param toFileEntryId the to file entry ID
1357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1358             * @return the last matching document library file shortcut
1359             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1360             * @throws SystemException if a system exception occurred
1361             */
1362            public DLFileShortcut findByToFileEntryId_Last(long toFileEntryId,
1363                    OrderByComparator orderByComparator)
1364                    throws NoSuchFileShortcutException, SystemException {
1365                    int count = countByToFileEntryId(toFileEntryId);
1366    
1367                    List<DLFileShortcut> list = findByToFileEntryId(toFileEntryId,
1368                                    count - 1, count, orderByComparator);
1369    
1370                    if (list.isEmpty()) {
1371                            StringBundler msg = new StringBundler(4);
1372    
1373                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1374    
1375                            msg.append("toFileEntryId=");
1376                            msg.append(toFileEntryId);
1377    
1378                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1379    
1380                            throw new NoSuchFileShortcutException(msg.toString());
1381                    }
1382                    else {
1383                            return list.get(0);
1384                    }
1385            }
1386    
1387            /**
1388             * Returns the document library file shortcuts before and after the current document library file shortcut in the ordered set where toFileEntryId = &#63;.
1389             *
1390             * <p>
1391             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1392             * </p>
1393             *
1394             * @param fileShortcutId the primary key of the current document library file shortcut
1395             * @param toFileEntryId the to file entry ID
1396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1397             * @return the previous, current, and next document library file shortcut
1398             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
1399             * @throws SystemException if a system exception occurred
1400             */
1401            public DLFileShortcut[] findByToFileEntryId_PrevAndNext(
1402                    long fileShortcutId, long toFileEntryId,
1403                    OrderByComparator orderByComparator)
1404                    throws NoSuchFileShortcutException, SystemException {
1405                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1406    
1407                    Session session = null;
1408    
1409                    try {
1410                            session = openSession();
1411    
1412                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1413    
1414                            array[0] = getByToFileEntryId_PrevAndNext(session, dlFileShortcut,
1415                                            toFileEntryId, orderByComparator, true);
1416    
1417                            array[1] = dlFileShortcut;
1418    
1419                            array[2] = getByToFileEntryId_PrevAndNext(session, dlFileShortcut,
1420                                            toFileEntryId, orderByComparator, false);
1421    
1422                            return array;
1423                    }
1424                    catch (Exception e) {
1425                            throw processException(e);
1426                    }
1427                    finally {
1428                            closeSession(session);
1429                    }
1430            }
1431    
1432            protected DLFileShortcut getByToFileEntryId_PrevAndNext(Session session,
1433                    DLFileShortcut dlFileShortcut, long toFileEntryId,
1434                    OrderByComparator orderByComparator, boolean previous) {
1435                    StringBundler query = null;
1436    
1437                    if (orderByComparator != null) {
1438                            query = new StringBundler(6 +
1439                                            (orderByComparator.getOrderByFields().length * 6));
1440                    }
1441                    else {
1442                            query = new StringBundler(3);
1443                    }
1444    
1445                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1446    
1447                    query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
1448    
1449                    if (orderByComparator != null) {
1450                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1451    
1452                            if (orderByConditionFields.length > 0) {
1453                                    query.append(WHERE_AND);
1454                            }
1455    
1456                            for (int i = 0; i < orderByConditionFields.length; i++) {
1457                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1458                                    query.append(orderByConditionFields[i]);
1459    
1460                                    if ((i + 1) < orderByConditionFields.length) {
1461                                            if (orderByComparator.isAscending() ^ previous) {
1462                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1463                                            }
1464                                            else {
1465                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1466                                            }
1467                                    }
1468                                    else {
1469                                            if (orderByComparator.isAscending() ^ previous) {
1470                                                    query.append(WHERE_GREATER_THAN);
1471                                            }
1472                                            else {
1473                                                    query.append(WHERE_LESSER_THAN);
1474                                            }
1475                                    }
1476                            }
1477    
1478                            query.append(ORDER_BY_CLAUSE);
1479    
1480                            String[] orderByFields = orderByComparator.getOrderByFields();
1481    
1482                            for (int i = 0; i < orderByFields.length; i++) {
1483                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1484                                    query.append(orderByFields[i]);
1485    
1486                                    if ((i + 1) < orderByFields.length) {
1487                                            if (orderByComparator.isAscending() ^ previous) {
1488                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1489                                            }
1490                                            else {
1491                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1492                                            }
1493                                    }
1494                                    else {
1495                                            if (orderByComparator.isAscending() ^ previous) {
1496                                                    query.append(ORDER_BY_ASC);
1497                                            }
1498                                            else {
1499                                                    query.append(ORDER_BY_DESC);
1500                                            }
1501                                    }
1502                            }
1503                    }
1504    
1505                    String sql = query.toString();
1506    
1507                    Query q = session.createQuery(sql);
1508    
1509                    q.setFirstResult(0);
1510                    q.setMaxResults(2);
1511    
1512                    QueryPos qPos = QueryPos.getInstance(q);
1513    
1514                    qPos.add(toFileEntryId);
1515    
1516                    if (orderByComparator != null) {
1517                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1518    
1519                            for (Object value : values) {
1520                                    qPos.add(value);
1521                            }
1522                    }
1523    
1524                    List<DLFileShortcut> list = q.list();
1525    
1526                    if (list.size() == 2) {
1527                            return list.get(1);
1528                    }
1529                    else {
1530                            return null;
1531                    }
1532            }
1533    
1534            /**
1535             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1536             *
1537             * @param groupId the group ID
1538             * @param folderId the folder ID
1539             * @return the matching document library file shortcuts
1540             * @throws SystemException if a system exception occurred
1541             */
1542            public List<DLFileShortcut> findByG_F(long groupId, long folderId)
1543                    throws SystemException {
1544                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
1545                            QueryUtil.ALL_POS, null);
1546            }
1547    
1548            /**
1549             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1550             *
1551             * <p>
1552             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1553             * </p>
1554             *
1555             * @param groupId the group ID
1556             * @param folderId the folder ID
1557             * @param start the lower bound of the range of document library file shortcuts
1558             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1559             * @return the range of matching document library file shortcuts
1560             * @throws SystemException if a system exception occurred
1561             */
1562            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
1563                    int start, int end) throws SystemException {
1564                    return findByG_F(groupId, folderId, start, end, null);
1565            }
1566    
1567            /**
1568             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63;.
1569             *
1570             * <p>
1571             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1572             * </p>
1573             *
1574             * @param groupId the group ID
1575             * @param folderId the folder ID
1576             * @param start the lower bound of the range of document library file shortcuts
1577             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1578             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1579             * @return the ordered range of matching document library file shortcuts
1580             * @throws SystemException if a system exception occurred
1581             */
1582            public List<DLFileShortcut> findByG_F(long groupId, long folderId,
1583                    int start, int end, OrderByComparator orderByComparator)
1584                    throws SystemException {
1585                    FinderPath finderPath = null;
1586                    Object[] finderArgs = null;
1587    
1588                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1589                                    (orderByComparator == null)) {
1590                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
1591                            finderArgs = new Object[] { groupId, folderId };
1592                    }
1593                    else {
1594                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
1595                            finderArgs = new Object[] {
1596                                            groupId, folderId,
1597                                            
1598                                            start, end, orderByComparator
1599                                    };
1600                    }
1601    
1602                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
1603                                    finderArgs, this);
1604    
1605                    if (list == null) {
1606                            StringBundler query = null;
1607    
1608                            if (orderByComparator != null) {
1609                                    query = new StringBundler(4 +
1610                                                    (orderByComparator.getOrderByFields().length * 3));
1611                            }
1612                            else {
1613                                    query = new StringBundler(3);
1614                            }
1615    
1616                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1617    
1618                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1619    
1620                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1621    
1622                            if (orderByComparator != null) {
1623                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1624                                            orderByComparator);
1625                            }
1626    
1627                            String sql = query.toString();
1628    
1629                            Session session = null;
1630    
1631                            try {
1632                                    session = openSession();
1633    
1634                                    Query q = session.createQuery(sql);
1635    
1636                                    QueryPos qPos = QueryPos.getInstance(q);
1637    
1638                                    qPos.add(groupId);
1639    
1640                                    qPos.add(folderId);
1641    
1642                                    list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
1643                                                    start, end);
1644                            }
1645                            catch (Exception e) {
1646                                    throw processException(e);
1647                            }
1648                            finally {
1649                                    if (list == null) {
1650                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1651                                    }
1652                                    else {
1653                                            cacheResult(list);
1654    
1655                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1656                                    }
1657    
1658                                    closeSession(session);
1659                            }
1660                    }
1661    
1662                    return list;
1663            }
1664    
1665            /**
1666             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
1667             *
1668             * <p>
1669             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1670             * </p>
1671             *
1672             * @param groupId the group ID
1673             * @param folderId the folder ID
1674             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1675             * @return the first matching document library file shortcut
1676             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1677             * @throws SystemException if a system exception occurred
1678             */
1679            public DLFileShortcut findByG_F_First(long groupId, long folderId,
1680                    OrderByComparator orderByComparator)
1681                    throws NoSuchFileShortcutException, SystemException {
1682                    List<DLFileShortcut> list = findByG_F(groupId, folderId, 0, 1,
1683                                    orderByComparator);
1684    
1685                    if (list.isEmpty()) {
1686                            StringBundler msg = new StringBundler(6);
1687    
1688                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1689    
1690                            msg.append("groupId=");
1691                            msg.append(groupId);
1692    
1693                            msg.append(", folderId=");
1694                            msg.append(folderId);
1695    
1696                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1697    
1698                            throw new NoSuchFileShortcutException(msg.toString());
1699                    }
1700                    else {
1701                            return list.get(0);
1702                    }
1703            }
1704    
1705            /**
1706             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63;.
1707             *
1708             * <p>
1709             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1710             * </p>
1711             *
1712             * @param groupId the group ID
1713             * @param folderId the folder ID
1714             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1715             * @return the last matching document library file shortcut
1716             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
1717             * @throws SystemException if a system exception occurred
1718             */
1719            public DLFileShortcut findByG_F_Last(long groupId, long folderId,
1720                    OrderByComparator orderByComparator)
1721                    throws NoSuchFileShortcutException, SystemException {
1722                    int count = countByG_F(groupId, folderId);
1723    
1724                    List<DLFileShortcut> list = findByG_F(groupId, folderId, count - 1,
1725                                    count, orderByComparator);
1726    
1727                    if (list.isEmpty()) {
1728                            StringBundler msg = new StringBundler(6);
1729    
1730                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1731    
1732                            msg.append("groupId=");
1733                            msg.append(groupId);
1734    
1735                            msg.append(", folderId=");
1736                            msg.append(folderId);
1737    
1738                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1739    
1740                            throw new NoSuchFileShortcutException(msg.toString());
1741                    }
1742                    else {
1743                            return list.get(0);
1744                    }
1745            }
1746    
1747            /**
1748             * 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;.
1749             *
1750             * <p>
1751             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1752             * </p>
1753             *
1754             * @param fileShortcutId the primary key of the current document library file shortcut
1755             * @param groupId the group ID
1756             * @param folderId the folder ID
1757             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1758             * @return the previous, current, and next document library file shortcut
1759             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
1760             * @throws SystemException if a system exception occurred
1761             */
1762            public DLFileShortcut[] findByG_F_PrevAndNext(long fileShortcutId,
1763                    long groupId, long folderId, OrderByComparator orderByComparator)
1764                    throws NoSuchFileShortcutException, SystemException {
1765                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
1766    
1767                    Session session = null;
1768    
1769                    try {
1770                            session = openSession();
1771    
1772                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
1773    
1774                            array[0] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
1775                                            folderId, orderByComparator, true);
1776    
1777                            array[1] = dlFileShortcut;
1778    
1779                            array[2] = getByG_F_PrevAndNext(session, dlFileShortcut, groupId,
1780                                            folderId, orderByComparator, false);
1781    
1782                            return array;
1783                    }
1784                    catch (Exception e) {
1785                            throw processException(e);
1786                    }
1787                    finally {
1788                            closeSession(session);
1789                    }
1790            }
1791    
1792            protected DLFileShortcut getByG_F_PrevAndNext(Session session,
1793                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
1794                    OrderByComparator orderByComparator, boolean previous) {
1795                    StringBundler query = null;
1796    
1797                    if (orderByComparator != null) {
1798                            query = new StringBundler(6 +
1799                                            (orderByComparator.getOrderByFields().length * 6));
1800                    }
1801                    else {
1802                            query = new StringBundler(3);
1803                    }
1804    
1805                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
1806    
1807                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1808    
1809                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1810    
1811                    if (orderByComparator != null) {
1812                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1813    
1814                            if (orderByConditionFields.length > 0) {
1815                                    query.append(WHERE_AND);
1816                            }
1817    
1818                            for (int i = 0; i < orderByConditionFields.length; i++) {
1819                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1820                                    query.append(orderByConditionFields[i]);
1821    
1822                                    if ((i + 1) < orderByConditionFields.length) {
1823                                            if (orderByComparator.isAscending() ^ previous) {
1824                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1825                                            }
1826                                            else {
1827                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1828                                            }
1829                                    }
1830                                    else {
1831                                            if (orderByComparator.isAscending() ^ previous) {
1832                                                    query.append(WHERE_GREATER_THAN);
1833                                            }
1834                                            else {
1835                                                    query.append(WHERE_LESSER_THAN);
1836                                            }
1837                                    }
1838                            }
1839    
1840                            query.append(ORDER_BY_CLAUSE);
1841    
1842                            String[] orderByFields = orderByComparator.getOrderByFields();
1843    
1844                            for (int i = 0; i < orderByFields.length; i++) {
1845                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1846                                    query.append(orderByFields[i]);
1847    
1848                                    if ((i + 1) < orderByFields.length) {
1849                                            if (orderByComparator.isAscending() ^ previous) {
1850                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1851                                            }
1852                                            else {
1853                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1854                                            }
1855                                    }
1856                                    else {
1857                                            if (orderByComparator.isAscending() ^ previous) {
1858                                                    query.append(ORDER_BY_ASC);
1859                                            }
1860                                            else {
1861                                                    query.append(ORDER_BY_DESC);
1862                                            }
1863                                    }
1864                            }
1865                    }
1866    
1867                    String sql = query.toString();
1868    
1869                    Query q = session.createQuery(sql);
1870    
1871                    q.setFirstResult(0);
1872                    q.setMaxResults(2);
1873    
1874                    QueryPos qPos = QueryPos.getInstance(q);
1875    
1876                    qPos.add(groupId);
1877    
1878                    qPos.add(folderId);
1879    
1880                    if (orderByComparator != null) {
1881                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
1882    
1883                            for (Object value : values) {
1884                                    qPos.add(value);
1885                            }
1886                    }
1887    
1888                    List<DLFileShortcut> list = q.list();
1889    
1890                    if (list.size() == 2) {
1891                            return list.get(1);
1892                    }
1893                    else {
1894                            return null;
1895                    }
1896            }
1897    
1898            /**
1899             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
1900             *
1901             * @param groupId the group ID
1902             * @param folderId the folder ID
1903             * @return the matching document library file shortcuts that the user has permission to view
1904             * @throws SystemException if a system exception occurred
1905             */
1906            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId)
1907                    throws SystemException {
1908                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
1909                            QueryUtil.ALL_POS, null);
1910            }
1911    
1912            /**
1913             * Returns a range of all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
1914             *
1915             * <p>
1916             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1917             * </p>
1918             *
1919             * @param groupId the group ID
1920             * @param folderId the folder ID
1921             * @param start the lower bound of the range of document library file shortcuts
1922             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1923             * @return the range of matching document library file shortcuts that the user has permission to view
1924             * @throws SystemException if a system exception occurred
1925             */
1926            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
1927                    int start, int end) throws SystemException {
1928                    return filterFindByG_F(groupId, folderId, start, end, null);
1929            }
1930    
1931            /**
1932             * Returns an ordered range of all the document library file shortcuts that the user has permissions to view where groupId = &#63; and folderId = &#63;.
1933             *
1934             * <p>
1935             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1936             * </p>
1937             *
1938             * @param groupId the group ID
1939             * @param folderId the folder ID
1940             * @param start the lower bound of the range of document library file shortcuts
1941             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
1942             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1943             * @return the ordered range of matching document library file shortcuts that the user has permission to view
1944             * @throws SystemException if a system exception occurred
1945             */
1946            public List<DLFileShortcut> filterFindByG_F(long groupId, long folderId,
1947                    int start, int end, OrderByComparator orderByComparator)
1948                    throws SystemException {
1949                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1950                            return findByG_F(groupId, folderId, start, end, orderByComparator);
1951                    }
1952    
1953                    StringBundler query = null;
1954    
1955                    if (orderByComparator != null) {
1956                            query = new StringBundler(4 +
1957                                            (orderByComparator.getOrderByFields().length * 3));
1958                    }
1959                    else {
1960                            query = new StringBundler(3);
1961                    }
1962    
1963                    if (getDB().isSupportsInlineDistinct()) {
1964                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
1965                    }
1966                    else {
1967                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
1968                    }
1969    
1970                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
1971    
1972                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
1973    
1974                    if (!getDB().isSupportsInlineDistinct()) {
1975                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
1976                    }
1977    
1978                    if (orderByComparator != null) {
1979                            if (getDB().isSupportsInlineDistinct()) {
1980                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1981                                            orderByComparator);
1982                            }
1983                            else {
1984                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1985                                            orderByComparator);
1986                            }
1987                    }
1988    
1989                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1990                                    DLFileShortcut.class.getName(),
1991                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1992    
1993                    Session session = null;
1994    
1995                    try {
1996                            session = openSession();
1997    
1998                            SQLQuery q = session.createSQLQuery(sql);
1999    
2000                            if (getDB().isSupportsInlineDistinct()) {
2001                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2002                            }
2003                            else {
2004                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2005                            }
2006    
2007                            QueryPos qPos = QueryPos.getInstance(q);
2008    
2009                            qPos.add(groupId);
2010    
2011                            qPos.add(folderId);
2012    
2013                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
2014                                    end);
2015                    }
2016                    catch (Exception e) {
2017                            throw processException(e);
2018                    }
2019                    finally {
2020                            closeSession(session);
2021                    }
2022            }
2023    
2024            /**
2025             * 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;.
2026             *
2027             * @param fileShortcutId the primary key of the current document library file shortcut
2028             * @param groupId the group ID
2029             * @param folderId the folder ID
2030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2031             * @return the previous, current, and next document library file shortcut
2032             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2033             * @throws SystemException if a system exception occurred
2034             */
2035            public DLFileShortcut[] filterFindByG_F_PrevAndNext(long fileShortcutId,
2036                    long groupId, long folderId, OrderByComparator orderByComparator)
2037                    throws NoSuchFileShortcutException, SystemException {
2038                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2039                            return findByG_F_PrevAndNext(fileShortcutId, groupId, folderId,
2040                                    orderByComparator);
2041                    }
2042    
2043                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2044    
2045                    Session session = null;
2046    
2047                    try {
2048                            session = openSession();
2049    
2050                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2051    
2052                            array[0] = filterGetByG_F_PrevAndNext(session, dlFileShortcut,
2053                                            groupId, folderId, orderByComparator, true);
2054    
2055                            array[1] = dlFileShortcut;
2056    
2057                            array[2] = filterGetByG_F_PrevAndNext(session, dlFileShortcut,
2058                                            groupId, folderId, orderByComparator, false);
2059    
2060                            return array;
2061                    }
2062                    catch (Exception e) {
2063                            throw processException(e);
2064                    }
2065                    finally {
2066                            closeSession(session);
2067                    }
2068            }
2069    
2070            protected DLFileShortcut filterGetByG_F_PrevAndNext(Session session,
2071                    DLFileShortcut dlFileShortcut, long groupId, long folderId,
2072                    OrderByComparator orderByComparator, boolean previous) {
2073                    StringBundler query = null;
2074    
2075                    if (orderByComparator != null) {
2076                            query = new StringBundler(6 +
2077                                            (orderByComparator.getOrderByFields().length * 6));
2078                    }
2079                    else {
2080                            query = new StringBundler(3);
2081                    }
2082    
2083                    if (getDB().isSupportsInlineDistinct()) {
2084                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2085                    }
2086                    else {
2087                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
2088                    }
2089    
2090                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2091    
2092                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2093    
2094                    if (!getDB().isSupportsInlineDistinct()) {
2095                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
2096                    }
2097    
2098                    if (orderByComparator != null) {
2099                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2100    
2101                            if (orderByConditionFields.length > 0) {
2102                                    query.append(WHERE_AND);
2103                            }
2104    
2105                            for (int i = 0; i < orderByConditionFields.length; i++) {
2106                                    if (getDB().isSupportsInlineDistinct()) {
2107                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2108                                    }
2109                                    else {
2110                                            query.append(_ORDER_BY_ENTITY_TABLE);
2111                                    }
2112    
2113                                    query.append(orderByConditionFields[i]);
2114    
2115                                    if ((i + 1) < orderByConditionFields.length) {
2116                                            if (orderByComparator.isAscending() ^ previous) {
2117                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2118                                            }
2119                                            else {
2120                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2121                                            }
2122                                    }
2123                                    else {
2124                                            if (orderByComparator.isAscending() ^ previous) {
2125                                                    query.append(WHERE_GREATER_THAN);
2126                                            }
2127                                            else {
2128                                                    query.append(WHERE_LESSER_THAN);
2129                                            }
2130                                    }
2131                            }
2132    
2133                            query.append(ORDER_BY_CLAUSE);
2134    
2135                            String[] orderByFields = orderByComparator.getOrderByFields();
2136    
2137                            for (int i = 0; i < orderByFields.length; i++) {
2138                                    if (getDB().isSupportsInlineDistinct()) {
2139                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2140                                    }
2141                                    else {
2142                                            query.append(_ORDER_BY_ENTITY_TABLE);
2143                                    }
2144    
2145                                    query.append(orderByFields[i]);
2146    
2147                                    if ((i + 1) < orderByFields.length) {
2148                                            if (orderByComparator.isAscending() ^ previous) {
2149                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2150                                            }
2151                                            else {
2152                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2153                                            }
2154                                    }
2155                                    else {
2156                                            if (orderByComparator.isAscending() ^ previous) {
2157                                                    query.append(ORDER_BY_ASC);
2158                                            }
2159                                            else {
2160                                                    query.append(ORDER_BY_DESC);
2161                                            }
2162                                    }
2163                            }
2164                    }
2165    
2166                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2167                                    DLFileShortcut.class.getName(),
2168                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2169    
2170                    SQLQuery q = session.createSQLQuery(sql);
2171    
2172                    q.setFirstResult(0);
2173                    q.setMaxResults(2);
2174    
2175                    if (getDB().isSupportsInlineDistinct()) {
2176                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2177                    }
2178                    else {
2179                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2180                    }
2181    
2182                    QueryPos qPos = QueryPos.getInstance(q);
2183    
2184                    qPos.add(groupId);
2185    
2186                    qPos.add(folderId);
2187    
2188                    if (orderByComparator != null) {
2189                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2190    
2191                            for (Object value : values) {
2192                                    qPos.add(value);
2193                            }
2194                    }
2195    
2196                    List<DLFileShortcut> list = q.list();
2197    
2198                    if (list.size() == 2) {
2199                            return list.get(1);
2200                    }
2201                    else {
2202                            return null;
2203                    }
2204            }
2205    
2206            /**
2207             * Returns all the document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63;.
2208             *
2209             * @param groupId the group ID
2210             * @param folderId the folder ID
2211             * @param status the status
2212             * @return the matching document library file shortcuts
2213             * @throws SystemException if a system exception occurred
2214             */
2215            public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
2216                    int status) throws SystemException {
2217                    return findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
2218                            QueryUtil.ALL_POS, null);
2219            }
2220    
2221            /**
2222             * Returns a range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63;.
2223             *
2224             * <p>
2225             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2226             * </p>
2227             *
2228             * @param groupId the group ID
2229             * @param folderId the folder ID
2230             * @param status the status
2231             * @param start the lower bound of the range of document library file shortcuts
2232             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2233             * @return the range of matching document library file shortcuts
2234             * @throws SystemException if a system exception occurred
2235             */
2236            public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
2237                    int status, int start, int end) throws SystemException {
2238                    return findByG_F_S(groupId, folderId, status, start, end, null);
2239            }
2240    
2241            /**
2242             * Returns an ordered range of all the document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63;.
2243             *
2244             * <p>
2245             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2246             * </p>
2247             *
2248             * @param groupId the group ID
2249             * @param folderId the folder ID
2250             * @param status the status
2251             * @param start the lower bound of the range of document library file shortcuts
2252             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2253             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2254             * @return the ordered range of matching document library file shortcuts
2255             * @throws SystemException if a system exception occurred
2256             */
2257            public List<DLFileShortcut> findByG_F_S(long groupId, long folderId,
2258                    int status, int start, int end, OrderByComparator orderByComparator)
2259                    throws SystemException {
2260                    FinderPath finderPath = null;
2261                    Object[] finderArgs = null;
2262    
2263                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2264                                    (orderByComparator == null)) {
2265                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S;
2266                            finderArgs = new Object[] { groupId, folderId, status };
2267                    }
2268                    else {
2269                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S;
2270                            finderArgs = new Object[] {
2271                                            groupId, folderId, status,
2272                                            
2273                                            start, end, orderByComparator
2274                                    };
2275                    }
2276    
2277                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
2278                                    finderArgs, this);
2279    
2280                    if (list == null) {
2281                            StringBundler query = null;
2282    
2283                            if (orderByComparator != null) {
2284                                    query = new StringBundler(5 +
2285                                                    (orderByComparator.getOrderByFields().length * 3));
2286                            }
2287                            else {
2288                                    query = new StringBundler(4);
2289                            }
2290    
2291                            query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2292    
2293                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2294    
2295                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2296    
2297                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2298    
2299                            if (orderByComparator != null) {
2300                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2301                                            orderByComparator);
2302                            }
2303    
2304                            String sql = query.toString();
2305    
2306                            Session session = null;
2307    
2308                            try {
2309                                    session = openSession();
2310    
2311                                    Query q = session.createQuery(sql);
2312    
2313                                    QueryPos qPos = QueryPos.getInstance(q);
2314    
2315                                    qPos.add(groupId);
2316    
2317                                    qPos.add(folderId);
2318    
2319                                    qPos.add(status);
2320    
2321                                    list = (List<DLFileShortcut>)QueryUtil.list(q, getDialect(),
2322                                                    start, end);
2323                            }
2324                            catch (Exception e) {
2325                                    throw processException(e);
2326                            }
2327                            finally {
2328                                    if (list == null) {
2329                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2330                                    }
2331                                    else {
2332                                            cacheResult(list);
2333    
2334                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2335                                    }
2336    
2337                                    closeSession(session);
2338                            }
2339                    }
2340    
2341                    return list;
2342            }
2343    
2344            /**
2345             * Returns the first document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
2346             *
2347             * <p>
2348             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2349             * </p>
2350             *
2351             * @param groupId the group ID
2352             * @param folderId the folder ID
2353             * @param status the status
2354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2355             * @return the first matching document library file shortcut
2356             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
2357             * @throws SystemException if a system exception occurred
2358             */
2359            public DLFileShortcut findByG_F_S_First(long groupId, long folderId,
2360                    int status, OrderByComparator orderByComparator)
2361                    throws NoSuchFileShortcutException, SystemException {
2362                    List<DLFileShortcut> list = findByG_F_S(groupId, folderId, status, 0,
2363                                    1, orderByComparator);
2364    
2365                    if (list.isEmpty()) {
2366                            StringBundler msg = new StringBundler(8);
2367    
2368                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2369    
2370                            msg.append("groupId=");
2371                            msg.append(groupId);
2372    
2373                            msg.append(", folderId=");
2374                            msg.append(folderId);
2375    
2376                            msg.append(", status=");
2377                            msg.append(status);
2378    
2379                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2380    
2381                            throw new NoSuchFileShortcutException(msg.toString());
2382                    }
2383                    else {
2384                            return list.get(0);
2385                    }
2386            }
2387    
2388            /**
2389             * Returns the last document library file shortcut in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
2390             *
2391             * <p>
2392             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2393             * </p>
2394             *
2395             * @param groupId the group ID
2396             * @param folderId the folder ID
2397             * @param status the status
2398             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2399             * @return the last matching document library file shortcut
2400             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a matching document library file shortcut could not be found
2401             * @throws SystemException if a system exception occurred
2402             */
2403            public DLFileShortcut findByG_F_S_Last(long groupId, long folderId,
2404                    int status, OrderByComparator orderByComparator)
2405                    throws NoSuchFileShortcutException, SystemException {
2406                    int count = countByG_F_S(groupId, folderId, status);
2407    
2408                    List<DLFileShortcut> list = findByG_F_S(groupId, folderId, status,
2409                                    count - 1, count, orderByComparator);
2410    
2411                    if (list.isEmpty()) {
2412                            StringBundler msg = new StringBundler(8);
2413    
2414                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2415    
2416                            msg.append("groupId=");
2417                            msg.append(groupId);
2418    
2419                            msg.append(", folderId=");
2420                            msg.append(folderId);
2421    
2422                            msg.append(", status=");
2423                            msg.append(status);
2424    
2425                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2426    
2427                            throw new NoSuchFileShortcutException(msg.toString());
2428                    }
2429                    else {
2430                            return list.get(0);
2431                    }
2432            }
2433    
2434            /**
2435             * 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 status = &#63;.
2436             *
2437             * <p>
2438             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2439             * </p>
2440             *
2441             * @param fileShortcutId the primary key of the current document library file shortcut
2442             * @param groupId the group ID
2443             * @param folderId the folder ID
2444             * @param status the status
2445             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2446             * @return the previous, current, and next document library file shortcut
2447             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2448             * @throws SystemException if a system exception occurred
2449             */
2450            public DLFileShortcut[] findByG_F_S_PrevAndNext(long fileShortcutId,
2451                    long groupId, long folderId, int status,
2452                    OrderByComparator orderByComparator)
2453                    throws NoSuchFileShortcutException, SystemException {
2454                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2455    
2456                    Session session = null;
2457    
2458                    try {
2459                            session = openSession();
2460    
2461                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2462    
2463                            array[0] = getByG_F_S_PrevAndNext(session, dlFileShortcut, groupId,
2464                                            folderId, status, orderByComparator, true);
2465    
2466                            array[1] = dlFileShortcut;
2467    
2468                            array[2] = getByG_F_S_PrevAndNext(session, dlFileShortcut, groupId,
2469                                            folderId, status, orderByComparator, false);
2470    
2471                            return array;
2472                    }
2473                    catch (Exception e) {
2474                            throw processException(e);
2475                    }
2476                    finally {
2477                            closeSession(session);
2478                    }
2479            }
2480    
2481            protected DLFileShortcut getByG_F_S_PrevAndNext(Session session,
2482                    DLFileShortcut dlFileShortcut, long groupId, long folderId, int status,
2483                    OrderByComparator orderByComparator, boolean previous) {
2484                    StringBundler query = null;
2485    
2486                    if (orderByComparator != null) {
2487                            query = new StringBundler(6 +
2488                                            (orderByComparator.getOrderByFields().length * 6));
2489                    }
2490                    else {
2491                            query = new StringBundler(3);
2492                    }
2493    
2494                    query.append(_SQL_SELECT_DLFILESHORTCUT_WHERE);
2495    
2496                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2497    
2498                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2499    
2500                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2501    
2502                    if (orderByComparator != null) {
2503                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2504    
2505                            if (orderByConditionFields.length > 0) {
2506                                    query.append(WHERE_AND);
2507                            }
2508    
2509                            for (int i = 0; i < orderByConditionFields.length; i++) {
2510                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2511                                    query.append(orderByConditionFields[i]);
2512    
2513                                    if ((i + 1) < orderByConditionFields.length) {
2514                                            if (orderByComparator.isAscending() ^ previous) {
2515                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2516                                            }
2517                                            else {
2518                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2519                                            }
2520                                    }
2521                                    else {
2522                                            if (orderByComparator.isAscending() ^ previous) {
2523                                                    query.append(WHERE_GREATER_THAN);
2524                                            }
2525                                            else {
2526                                                    query.append(WHERE_LESSER_THAN);
2527                                            }
2528                                    }
2529                            }
2530    
2531                            query.append(ORDER_BY_CLAUSE);
2532    
2533                            String[] orderByFields = orderByComparator.getOrderByFields();
2534    
2535                            for (int i = 0; i < orderByFields.length; i++) {
2536                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2537                                    query.append(orderByFields[i]);
2538    
2539                                    if ((i + 1) < orderByFields.length) {
2540                                            if (orderByComparator.isAscending() ^ previous) {
2541                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2542                                            }
2543                                            else {
2544                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2545                                            }
2546                                    }
2547                                    else {
2548                                            if (orderByComparator.isAscending() ^ previous) {
2549                                                    query.append(ORDER_BY_ASC);
2550                                            }
2551                                            else {
2552                                                    query.append(ORDER_BY_DESC);
2553                                            }
2554                                    }
2555                            }
2556                    }
2557    
2558                    String sql = query.toString();
2559    
2560                    Query q = session.createQuery(sql);
2561    
2562                    q.setFirstResult(0);
2563                    q.setMaxResults(2);
2564    
2565                    QueryPos qPos = QueryPos.getInstance(q);
2566    
2567                    qPos.add(groupId);
2568    
2569                    qPos.add(folderId);
2570    
2571                    qPos.add(status);
2572    
2573                    if (orderByComparator != null) {
2574                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2575    
2576                            for (Object value : values) {
2577                                    qPos.add(value);
2578                            }
2579                    }
2580    
2581                    List<DLFileShortcut> list = q.list();
2582    
2583                    if (list.size() == 2) {
2584                            return list.get(1);
2585                    }
2586                    else {
2587                            return null;
2588                    }
2589            }
2590    
2591            /**
2592             * Returns all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
2593             *
2594             * @param groupId the group ID
2595             * @param folderId the folder ID
2596             * @param status the status
2597             * @return the matching document library file shortcuts that the user has permission to view
2598             * @throws SystemException if a system exception occurred
2599             */
2600            public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
2601                    int status) throws SystemException {
2602                    return filterFindByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
2603                            QueryUtil.ALL_POS, null);
2604            }
2605    
2606            /**
2607             * Returns a range of all the document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
2608             *
2609             * <p>
2610             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2611             * </p>
2612             *
2613             * @param groupId the group ID
2614             * @param folderId the folder ID
2615             * @param status the status
2616             * @param start the lower bound of the range of document library file shortcuts
2617             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2618             * @return the range of matching document library file shortcuts that the user has permission to view
2619             * @throws SystemException if a system exception occurred
2620             */
2621            public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
2622                    int status, int start, int end) throws SystemException {
2623                    return filterFindByG_F_S(groupId, folderId, status, start, end, null);
2624            }
2625    
2626            /**
2627             * 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 status = &#63;.
2628             *
2629             * <p>
2630             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2631             * </p>
2632             *
2633             * @param groupId the group ID
2634             * @param folderId the folder ID
2635             * @param status the status
2636             * @param start the lower bound of the range of document library file shortcuts
2637             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2638             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2639             * @return the ordered range of matching document library file shortcuts that the user has permission to view
2640             * @throws SystemException if a system exception occurred
2641             */
2642            public List<DLFileShortcut> filterFindByG_F_S(long groupId, long folderId,
2643                    int status, int start, int end, OrderByComparator orderByComparator)
2644                    throws SystemException {
2645                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2646                            return findByG_F_S(groupId, folderId, status, start, end,
2647                                    orderByComparator);
2648                    }
2649    
2650                    StringBundler query = null;
2651    
2652                    if (orderByComparator != null) {
2653                            query = new StringBundler(5 +
2654                                            (orderByComparator.getOrderByFields().length * 3));
2655                    }
2656                    else {
2657                            query = new StringBundler(4);
2658                    }
2659    
2660                    if (getDB().isSupportsInlineDistinct()) {
2661                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2662                    }
2663                    else {
2664                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
2665                    }
2666    
2667                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2668    
2669                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2670    
2671                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2672    
2673                    if (!getDB().isSupportsInlineDistinct()) {
2674                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
2675                    }
2676    
2677                    if (orderByComparator != null) {
2678                            if (getDB().isSupportsInlineDistinct()) {
2679                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2680                                            orderByComparator);
2681                            }
2682                            else {
2683                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2684                                            orderByComparator);
2685                            }
2686                    }
2687    
2688                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2689                                    DLFileShortcut.class.getName(),
2690                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2691    
2692                    Session session = null;
2693    
2694                    try {
2695                            session = openSession();
2696    
2697                            SQLQuery q = session.createSQLQuery(sql);
2698    
2699                            if (getDB().isSupportsInlineDistinct()) {
2700                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2701                            }
2702                            else {
2703                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2704                            }
2705    
2706                            QueryPos qPos = QueryPos.getInstance(q);
2707    
2708                            qPos.add(groupId);
2709    
2710                            qPos.add(folderId);
2711    
2712                            qPos.add(status);
2713    
2714                            return (List<DLFileShortcut>)QueryUtil.list(q, getDialect(), start,
2715                                    end);
2716                    }
2717                    catch (Exception e) {
2718                            throw processException(e);
2719                    }
2720                    finally {
2721                            closeSession(session);
2722                    }
2723            }
2724    
2725            /**
2726             * 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 status = &#63;.
2727             *
2728             * @param fileShortcutId the primary key of the current document library file shortcut
2729             * @param groupId the group ID
2730             * @param folderId the folder ID
2731             * @param status the status
2732             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2733             * @return the previous, current, and next document library file shortcut
2734             * @throws com.liferay.portlet.documentlibrary.NoSuchFileShortcutException if a document library file shortcut with the primary key could not be found
2735             * @throws SystemException if a system exception occurred
2736             */
2737            public DLFileShortcut[] filterFindByG_F_S_PrevAndNext(long fileShortcutId,
2738                    long groupId, long folderId, int status,
2739                    OrderByComparator orderByComparator)
2740                    throws NoSuchFileShortcutException, SystemException {
2741                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2742                            return findByG_F_S_PrevAndNext(fileShortcutId, groupId, folderId,
2743                                    status, orderByComparator);
2744                    }
2745    
2746                    DLFileShortcut dlFileShortcut = findByPrimaryKey(fileShortcutId);
2747    
2748                    Session session = null;
2749    
2750                    try {
2751                            session = openSession();
2752    
2753                            DLFileShortcut[] array = new DLFileShortcutImpl[3];
2754    
2755                            array[0] = filterGetByG_F_S_PrevAndNext(session, dlFileShortcut,
2756                                            groupId, folderId, status, orderByComparator, true);
2757    
2758                            array[1] = dlFileShortcut;
2759    
2760                            array[2] = filterGetByG_F_S_PrevAndNext(session, dlFileShortcut,
2761                                            groupId, folderId, status, orderByComparator, false);
2762    
2763                            return array;
2764                    }
2765                    catch (Exception e) {
2766                            throw processException(e);
2767                    }
2768                    finally {
2769                            closeSession(session);
2770                    }
2771            }
2772    
2773            protected DLFileShortcut filterGetByG_F_S_PrevAndNext(Session session,
2774                    DLFileShortcut dlFileShortcut, long groupId, long folderId, int status,
2775                    OrderByComparator orderByComparator, boolean previous) {
2776                    StringBundler query = null;
2777    
2778                    if (orderByComparator != null) {
2779                            query = new StringBundler(6 +
2780                                            (orderByComparator.getOrderByFields().length * 6));
2781                    }
2782                    else {
2783                            query = new StringBundler(3);
2784                    }
2785    
2786                    if (getDB().isSupportsInlineDistinct()) {
2787                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE);
2788                    }
2789                    else {
2790                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1);
2791                    }
2792    
2793                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2794    
2795                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2796    
2797                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2798    
2799                    if (!getDB().isSupportsInlineDistinct()) {
2800                            query.append(_FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2);
2801                    }
2802    
2803                    if (orderByComparator != null) {
2804                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2805    
2806                            if (orderByConditionFields.length > 0) {
2807                                    query.append(WHERE_AND);
2808                            }
2809    
2810                            for (int i = 0; i < orderByConditionFields.length; i++) {
2811                                    if (getDB().isSupportsInlineDistinct()) {
2812                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2813                                    }
2814                                    else {
2815                                            query.append(_ORDER_BY_ENTITY_TABLE);
2816                                    }
2817    
2818                                    query.append(orderByConditionFields[i]);
2819    
2820                                    if ((i + 1) < orderByConditionFields.length) {
2821                                            if (orderByComparator.isAscending() ^ previous) {
2822                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2823                                            }
2824                                            else {
2825                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2826                                            }
2827                                    }
2828                                    else {
2829                                            if (orderByComparator.isAscending() ^ previous) {
2830                                                    query.append(WHERE_GREATER_THAN);
2831                                            }
2832                                            else {
2833                                                    query.append(WHERE_LESSER_THAN);
2834                                            }
2835                                    }
2836                            }
2837    
2838                            query.append(ORDER_BY_CLAUSE);
2839    
2840                            String[] orderByFields = orderByComparator.getOrderByFields();
2841    
2842                            for (int i = 0; i < orderByFields.length; i++) {
2843                                    if (getDB().isSupportsInlineDistinct()) {
2844                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2845                                    }
2846                                    else {
2847                                            query.append(_ORDER_BY_ENTITY_TABLE);
2848                                    }
2849    
2850                                    query.append(orderByFields[i]);
2851    
2852                                    if ((i + 1) < orderByFields.length) {
2853                                            if (orderByComparator.isAscending() ^ previous) {
2854                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2855                                            }
2856                                            else {
2857                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2858                                            }
2859                                    }
2860                                    else {
2861                                            if (orderByComparator.isAscending() ^ previous) {
2862                                                    query.append(ORDER_BY_ASC);
2863                                            }
2864                                            else {
2865                                                    query.append(ORDER_BY_DESC);
2866                                            }
2867                                    }
2868                            }
2869                    }
2870    
2871                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2872                                    DLFileShortcut.class.getName(),
2873                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2874    
2875                    SQLQuery q = session.createSQLQuery(sql);
2876    
2877                    q.setFirstResult(0);
2878                    q.setMaxResults(2);
2879    
2880                    if (getDB().isSupportsInlineDistinct()) {
2881                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileShortcutImpl.class);
2882                    }
2883                    else {
2884                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileShortcutImpl.class);
2885                    }
2886    
2887                    QueryPos qPos = QueryPos.getInstance(q);
2888    
2889                    qPos.add(groupId);
2890    
2891                    qPos.add(folderId);
2892    
2893                    qPos.add(status);
2894    
2895                    if (orderByComparator != null) {
2896                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileShortcut);
2897    
2898                            for (Object value : values) {
2899                                    qPos.add(value);
2900                            }
2901                    }
2902    
2903                    List<DLFileShortcut> list = q.list();
2904    
2905                    if (list.size() == 2) {
2906                            return list.get(1);
2907                    }
2908                    else {
2909                            return null;
2910                    }
2911            }
2912    
2913            /**
2914             * Returns all the document library file shortcuts.
2915             *
2916             * @return the document library file shortcuts
2917             * @throws SystemException if a system exception occurred
2918             */
2919            public List<DLFileShortcut> findAll() throws SystemException {
2920                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2921            }
2922    
2923            /**
2924             * Returns a range of all the document library file shortcuts.
2925             *
2926             * <p>
2927             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2928             * </p>
2929             *
2930             * @param start the lower bound of the range of document library file shortcuts
2931             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2932             * @return the range of document library file shortcuts
2933             * @throws SystemException if a system exception occurred
2934             */
2935            public List<DLFileShortcut> findAll(int start, int end)
2936                    throws SystemException {
2937                    return findAll(start, end, null);
2938            }
2939    
2940            /**
2941             * Returns an ordered range of all the document library file shortcuts.
2942             *
2943             * <p>
2944             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2945             * </p>
2946             *
2947             * @param start the lower bound of the range of document library file shortcuts
2948             * @param end the upper bound of the range of document library file shortcuts (not inclusive)
2949             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2950             * @return the ordered range of document library file shortcuts
2951             * @throws SystemException if a system exception occurred
2952             */
2953            public List<DLFileShortcut> findAll(int start, int end,
2954                    OrderByComparator orderByComparator) throws SystemException {
2955                    FinderPath finderPath = null;
2956                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2957    
2958                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2959                                    (orderByComparator == null)) {
2960                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2961                            finderArgs = FINDER_ARGS_EMPTY;
2962                    }
2963                    else {
2964                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2965                            finderArgs = new Object[] { start, end, orderByComparator };
2966                    }
2967    
2968                    List<DLFileShortcut> list = (List<DLFileShortcut>)FinderCacheUtil.getResult(finderPath,
2969                                    finderArgs, this);
2970    
2971                    if (list == null) {
2972                            StringBundler query = null;
2973                            String sql = null;
2974    
2975                            if (orderByComparator != null) {
2976                                    query = new StringBundler(2 +
2977                                                    (orderByComparator.getOrderByFields().length * 3));
2978    
2979                                    query.append(_SQL_SELECT_DLFILESHORTCUT);
2980    
2981                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2982                                            orderByComparator);
2983    
2984                                    sql = query.toString();
2985                            }
2986                            else {
2987                                    sql = _SQL_SELECT_DLFILESHORTCUT;
2988                            }
2989    
2990                            Session session = null;
2991    
2992                            try {
2993                                    session = openSession();
2994    
2995                                    Query q = session.createQuery(sql);
2996    
2997                                    if (orderByComparator == null) {
2998                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
2999                                                            getDialect(), start, end, false);
3000    
3001                                            Collections.sort(list);
3002                                    }
3003                                    else {
3004                                            list = (List<DLFileShortcut>)QueryUtil.list(q,
3005                                                            getDialect(), start, end);
3006                                    }
3007                            }
3008                            catch (Exception e) {
3009                                    throw processException(e);
3010                            }
3011                            finally {
3012                                    if (list == null) {
3013                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3014                                    }
3015                                    else {
3016                                            cacheResult(list);
3017    
3018                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3019                                    }
3020    
3021                                    closeSession(session);
3022                            }
3023                    }
3024    
3025                    return list;
3026            }
3027    
3028            /**
3029             * Removes all the document library file shortcuts where uuid = &#63; from the database.
3030             *
3031             * @param uuid the uuid
3032             * @throws SystemException if a system exception occurred
3033             */
3034            public void removeByUuid(String uuid) throws SystemException {
3035                    for (DLFileShortcut dlFileShortcut : findByUuid(uuid)) {
3036                            remove(dlFileShortcut);
3037                    }
3038            }
3039    
3040            /**
3041             * Removes the document library file shortcut where uuid = &#63; and groupId = &#63; from the database.
3042             *
3043             * @param uuid the uuid
3044             * @param groupId the group ID
3045             * @throws SystemException if a system exception occurred
3046             */
3047            public void removeByUUID_G(String uuid, long groupId)
3048                    throws NoSuchFileShortcutException, SystemException {
3049                    DLFileShortcut dlFileShortcut = findByUUID_G(uuid, groupId);
3050    
3051                    remove(dlFileShortcut);
3052            }
3053    
3054            /**
3055             * Removes all the document library file shortcuts where toFileEntryId = &#63; from the database.
3056             *
3057             * @param toFileEntryId the to file entry ID
3058             * @throws SystemException if a system exception occurred
3059             */
3060            public void removeByToFileEntryId(long toFileEntryId)
3061                    throws SystemException {
3062                    for (DLFileShortcut dlFileShortcut : findByToFileEntryId(toFileEntryId)) {
3063                            remove(dlFileShortcut);
3064                    }
3065            }
3066    
3067            /**
3068             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; from the database.
3069             *
3070             * @param groupId the group ID
3071             * @param folderId the folder ID
3072             * @throws SystemException if a system exception occurred
3073             */
3074            public void removeByG_F(long groupId, long folderId)
3075                    throws SystemException {
3076                    for (DLFileShortcut dlFileShortcut : findByG_F(groupId, folderId)) {
3077                            remove(dlFileShortcut);
3078                    }
3079            }
3080    
3081            /**
3082             * Removes all the document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
3083             *
3084             * @param groupId the group ID
3085             * @param folderId the folder ID
3086             * @param status the status
3087             * @throws SystemException if a system exception occurred
3088             */
3089            public void removeByG_F_S(long groupId, long folderId, int status)
3090                    throws SystemException {
3091                    for (DLFileShortcut dlFileShortcut : findByG_F_S(groupId, folderId,
3092                                    status)) {
3093                            remove(dlFileShortcut);
3094                    }
3095            }
3096    
3097            /**
3098             * Removes all the document library file shortcuts from the database.
3099             *
3100             * @throws SystemException if a system exception occurred
3101             */
3102            public void removeAll() throws SystemException {
3103                    for (DLFileShortcut dlFileShortcut : findAll()) {
3104                            remove(dlFileShortcut);
3105                    }
3106            }
3107    
3108            /**
3109             * Returns the number of document library file shortcuts where uuid = &#63;.
3110             *
3111             * @param uuid the uuid
3112             * @return the number of matching document library file shortcuts
3113             * @throws SystemException if a system exception occurred
3114             */
3115            public int countByUuid(String uuid) throws SystemException {
3116                    Object[] finderArgs = new Object[] { uuid };
3117    
3118                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3119                                    finderArgs, this);
3120    
3121                    if (count == null) {
3122                            StringBundler query = new StringBundler(2);
3123    
3124                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3125    
3126                            if (uuid == null) {
3127                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
3128                            }
3129                            else {
3130                                    if (uuid.equals(StringPool.BLANK)) {
3131                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
3132                                    }
3133                                    else {
3134                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
3135                                    }
3136                            }
3137    
3138                            String sql = query.toString();
3139    
3140                            Session session = null;
3141    
3142                            try {
3143                                    session = openSession();
3144    
3145                                    Query q = session.createQuery(sql);
3146    
3147                                    QueryPos qPos = QueryPos.getInstance(q);
3148    
3149                                    if (uuid != null) {
3150                                            qPos.add(uuid);
3151                                    }
3152    
3153                                    count = (Long)q.uniqueResult();
3154                            }
3155                            catch (Exception e) {
3156                                    throw processException(e);
3157                            }
3158                            finally {
3159                                    if (count == null) {
3160                                            count = Long.valueOf(0);
3161                                    }
3162    
3163                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3164                                            finderArgs, count);
3165    
3166                                    closeSession(session);
3167                            }
3168                    }
3169    
3170                    return count.intValue();
3171            }
3172    
3173            /**
3174             * Returns the number of document library file shortcuts where uuid = &#63; and groupId = &#63;.
3175             *
3176             * @param uuid the uuid
3177             * @param groupId the group ID
3178             * @return the number of matching document library file shortcuts
3179             * @throws SystemException if a system exception occurred
3180             */
3181            public int countByUUID_G(String uuid, long groupId)
3182                    throws SystemException {
3183                    Object[] finderArgs = new Object[] { uuid, groupId };
3184    
3185                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3186                                    finderArgs, this);
3187    
3188                    if (count == null) {
3189                            StringBundler query = new StringBundler(3);
3190    
3191                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3192    
3193                            if (uuid == null) {
3194                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3195                            }
3196                            else {
3197                                    if (uuid.equals(StringPool.BLANK)) {
3198                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3199                                    }
3200                                    else {
3201                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3202                                    }
3203                            }
3204    
3205                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3206    
3207                            String sql = query.toString();
3208    
3209                            Session session = null;
3210    
3211                            try {
3212                                    session = openSession();
3213    
3214                                    Query q = session.createQuery(sql);
3215    
3216                                    QueryPos qPos = QueryPos.getInstance(q);
3217    
3218                                    if (uuid != null) {
3219                                            qPos.add(uuid);
3220                                    }
3221    
3222                                    qPos.add(groupId);
3223    
3224                                    count = (Long)q.uniqueResult();
3225                            }
3226                            catch (Exception e) {
3227                                    throw processException(e);
3228                            }
3229                            finally {
3230                                    if (count == null) {
3231                                            count = Long.valueOf(0);
3232                                    }
3233    
3234                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3235                                            finderArgs, count);
3236    
3237                                    closeSession(session);
3238                            }
3239                    }
3240    
3241                    return count.intValue();
3242            }
3243    
3244            /**
3245             * Returns the number of document library file shortcuts where toFileEntryId = &#63;.
3246             *
3247             * @param toFileEntryId the to file entry ID
3248             * @return the number of matching document library file shortcuts
3249             * @throws SystemException if a system exception occurred
3250             */
3251            public int countByToFileEntryId(long toFileEntryId)
3252                    throws SystemException {
3253                    Object[] finderArgs = new Object[] { toFileEntryId };
3254    
3255                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
3256                                    finderArgs, this);
3257    
3258                    if (count == null) {
3259                            StringBundler query = new StringBundler(2);
3260    
3261                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3262    
3263                            query.append(_FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2);
3264    
3265                            String sql = query.toString();
3266    
3267                            Session session = null;
3268    
3269                            try {
3270                                    session = openSession();
3271    
3272                                    Query q = session.createQuery(sql);
3273    
3274                                    QueryPos qPos = QueryPos.getInstance(q);
3275    
3276                                    qPos.add(toFileEntryId);
3277    
3278                                    count = (Long)q.uniqueResult();
3279                            }
3280                            catch (Exception e) {
3281                                    throw processException(e);
3282                            }
3283                            finally {
3284                                    if (count == null) {
3285                                            count = Long.valueOf(0);
3286                                    }
3287    
3288                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TOFILEENTRYID,
3289                                            finderArgs, count);
3290    
3291                                    closeSession(session);
3292                            }
3293                    }
3294    
3295                    return count.intValue();
3296            }
3297    
3298            /**
3299             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63;.
3300             *
3301             * @param groupId the group ID
3302             * @param folderId the folder ID
3303             * @return the number of matching document library file shortcuts
3304             * @throws SystemException if a system exception occurred
3305             */
3306            public int countByG_F(long groupId, long folderId)
3307                    throws SystemException {
3308                    Object[] finderArgs = new Object[] { groupId, folderId };
3309    
3310                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
3311                                    finderArgs, this);
3312    
3313                    if (count == null) {
3314                            StringBundler query = new StringBundler(3);
3315    
3316                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3317    
3318                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3319    
3320                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3321    
3322                            String sql = query.toString();
3323    
3324                            Session session = null;
3325    
3326                            try {
3327                                    session = openSession();
3328    
3329                                    Query q = session.createQuery(sql);
3330    
3331                                    QueryPos qPos = QueryPos.getInstance(q);
3332    
3333                                    qPos.add(groupId);
3334    
3335                                    qPos.add(folderId);
3336    
3337                                    count = (Long)q.uniqueResult();
3338                            }
3339                            catch (Exception e) {
3340                                    throw processException(e);
3341                            }
3342                            finally {
3343                                    if (count == null) {
3344                                            count = Long.valueOf(0);
3345                                    }
3346    
3347                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
3348                                            count);
3349    
3350                                    closeSession(session);
3351                            }
3352                    }
3353    
3354                    return count.intValue();
3355            }
3356    
3357            /**
3358             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63;.
3359             *
3360             * @param groupId the group ID
3361             * @param folderId the folder ID
3362             * @return the number of matching document library file shortcuts that the user has permission to view
3363             * @throws SystemException if a system exception occurred
3364             */
3365            public int filterCountByG_F(long groupId, long folderId)
3366                    throws SystemException {
3367                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3368                            return countByG_F(groupId, folderId);
3369                    }
3370    
3371                    StringBundler query = new StringBundler(3);
3372    
3373                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3374    
3375                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3376    
3377                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3378    
3379                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3380                                    DLFileShortcut.class.getName(),
3381                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3382    
3383                    Session session = null;
3384    
3385                    try {
3386                            session = openSession();
3387    
3388                            SQLQuery q = session.createSQLQuery(sql);
3389    
3390                            q.addScalar(COUNT_COLUMN_NAME,
3391                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3392    
3393                            QueryPos qPos = QueryPos.getInstance(q);
3394    
3395                            qPos.add(groupId);
3396    
3397                            qPos.add(folderId);
3398    
3399                            Long count = (Long)q.uniqueResult();
3400    
3401                            return count.intValue();
3402                    }
3403                    catch (Exception e) {
3404                            throw processException(e);
3405                    }
3406                    finally {
3407                            closeSession(session);
3408                    }
3409            }
3410    
3411            /**
3412             * Returns the number of document library file shortcuts where groupId = &#63; and folderId = &#63; and status = &#63;.
3413             *
3414             * @param groupId the group ID
3415             * @param folderId the folder ID
3416             * @param status the status
3417             * @return the number of matching document library file shortcuts
3418             * @throws SystemException if a system exception occurred
3419             */
3420            public int countByG_F_S(long groupId, long folderId, int status)
3421                    throws SystemException {
3422                    Object[] finderArgs = new Object[] { groupId, folderId, status };
3423    
3424                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_S,
3425                                    finderArgs, this);
3426    
3427                    if (count == null) {
3428                            StringBundler query = new StringBundler(4);
3429    
3430                            query.append(_SQL_COUNT_DLFILESHORTCUT_WHERE);
3431    
3432                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
3433    
3434                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
3435    
3436                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
3437    
3438                            String sql = query.toString();
3439    
3440                            Session session = null;
3441    
3442                            try {
3443                                    session = openSession();
3444    
3445                                    Query q = session.createQuery(sql);
3446    
3447                                    QueryPos qPos = QueryPos.getInstance(q);
3448    
3449                                    qPos.add(groupId);
3450    
3451                                    qPos.add(folderId);
3452    
3453                                    qPos.add(status);
3454    
3455                                    count = (Long)q.uniqueResult();
3456                            }
3457                            catch (Exception e) {
3458                                    throw processException(e);
3459                            }
3460                            finally {
3461                                    if (count == null) {
3462                                            count = Long.valueOf(0);
3463                                    }
3464    
3465                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_S,
3466                                            finderArgs, count);
3467    
3468                                    closeSession(session);
3469                            }
3470                    }
3471    
3472                    return count.intValue();
3473            }
3474    
3475            /**
3476             * Returns the number of document library file shortcuts that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
3477             *
3478             * @param groupId the group ID
3479             * @param folderId the folder ID
3480             * @param status the status
3481             * @return the number of matching document library file shortcuts that the user has permission to view
3482             * @throws SystemException if a system exception occurred
3483             */
3484            public int filterCountByG_F_S(long groupId, long folderId, int status)
3485                    throws SystemException {
3486                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3487                            return countByG_F_S(groupId, folderId, status);
3488                    }
3489    
3490                    StringBundler query = new StringBundler(4);
3491    
3492                    query.append(_FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE);
3493    
3494                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
3495    
3496                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
3497    
3498                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
3499    
3500                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3501                                    DLFileShortcut.class.getName(),
3502                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3503    
3504                    Session session = null;
3505    
3506                    try {
3507                            session = openSession();
3508    
3509                            SQLQuery q = session.createSQLQuery(sql);
3510    
3511                            q.addScalar(COUNT_COLUMN_NAME,
3512                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3513    
3514                            QueryPos qPos = QueryPos.getInstance(q);
3515    
3516                            qPos.add(groupId);
3517    
3518                            qPos.add(folderId);
3519    
3520                            qPos.add(status);
3521    
3522                            Long count = (Long)q.uniqueResult();
3523    
3524                            return count.intValue();
3525                    }
3526                    catch (Exception e) {
3527                            throw processException(e);
3528                    }
3529                    finally {
3530                            closeSession(session);
3531                    }
3532            }
3533    
3534            /**
3535             * Returns the number of document library file shortcuts.
3536             *
3537             * @return the number of document library file shortcuts
3538             * @throws SystemException if a system exception occurred
3539             */
3540            public int countAll() throws SystemException {
3541                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3542                                    FINDER_ARGS_EMPTY, this);
3543    
3544                    if (count == null) {
3545                            Session session = null;
3546    
3547                            try {
3548                                    session = openSession();
3549    
3550                                    Query q = session.createQuery(_SQL_COUNT_DLFILESHORTCUT);
3551    
3552                                    count = (Long)q.uniqueResult();
3553                            }
3554                            catch (Exception e) {
3555                                    throw processException(e);
3556                            }
3557                            finally {
3558                                    if (count == null) {
3559                                            count = Long.valueOf(0);
3560                                    }
3561    
3562                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3563                                            FINDER_ARGS_EMPTY, count);
3564    
3565                                    closeSession(session);
3566                            }
3567                    }
3568    
3569                    return count.intValue();
3570            }
3571    
3572            /**
3573             * Initializes the document library file shortcut persistence.
3574             */
3575            public void afterPropertiesSet() {
3576                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3577                                            com.liferay.portal.util.PropsUtil.get(
3578                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileShortcut")));
3579    
3580                    if (listenerClassNames.length > 0) {
3581                            try {
3582                                    List<ModelListener<DLFileShortcut>> listenersList = new ArrayList<ModelListener<DLFileShortcut>>();
3583    
3584                                    for (String listenerClassName : listenerClassNames) {
3585                                            listenersList.add((ModelListener<DLFileShortcut>)InstanceFactory.newInstance(
3586                                                            listenerClassName));
3587                                    }
3588    
3589                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3590                            }
3591                            catch (Exception e) {
3592                                    _log.error(e);
3593                            }
3594                    }
3595            }
3596    
3597            public void destroy() {
3598                    EntityCacheUtil.removeCache(DLFileShortcutImpl.class.getName());
3599                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3600                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3601            }
3602    
3603            @BeanReference(type = DLContentPersistence.class)
3604            protected DLContentPersistence dlContentPersistence;
3605            @BeanReference(type = DLFileEntryPersistence.class)
3606            protected DLFileEntryPersistence dlFileEntryPersistence;
3607            @BeanReference(type = DLFileEntryMetadataPersistence.class)
3608            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
3609            @BeanReference(type = DLFileEntryTypePersistence.class)
3610            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
3611            @BeanReference(type = DLFileRankPersistence.class)
3612            protected DLFileRankPersistence dlFileRankPersistence;
3613            @BeanReference(type = DLFileShortcutPersistence.class)
3614            protected DLFileShortcutPersistence dlFileShortcutPersistence;
3615            @BeanReference(type = DLFileVersionPersistence.class)
3616            protected DLFileVersionPersistence dlFileVersionPersistence;
3617            @BeanReference(type = DLFolderPersistence.class)
3618            protected DLFolderPersistence dlFolderPersistence;
3619            @BeanReference(type = DLSyncPersistence.class)
3620            protected DLSyncPersistence dlSyncPersistence;
3621            @BeanReference(type = ResourcePersistence.class)
3622            protected ResourcePersistence resourcePersistence;
3623            @BeanReference(type = UserPersistence.class)
3624            protected UserPersistence userPersistence;
3625            @BeanReference(type = AssetEntryPersistence.class)
3626            protected AssetEntryPersistence assetEntryPersistence;
3627            @BeanReference(type = AssetTagPersistence.class)
3628            protected AssetTagPersistence assetTagPersistence;
3629            private static final String _SQL_SELECT_DLFILESHORTCUT = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut";
3630            private static final String _SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT dlFileShortcut FROM DLFileShortcut dlFileShortcut WHERE ";
3631            private static final String _SQL_COUNT_DLFILESHORTCUT = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut";
3632            private static final String _SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(dlFileShortcut) FROM DLFileShortcut dlFileShortcut WHERE ";
3633            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileShortcut.uuid IS NULL";
3634            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileShortcut.uuid = ?";
3635            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = ?)";
3636            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileShortcut.uuid IS NULL AND ";
3637            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileShortcut.uuid = ? AND ";
3638            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileShortcut.uuid IS NULL OR dlFileShortcut.uuid = ?) AND ";
3639            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileShortcut.groupId = ?";
3640            private static final String _FINDER_COLUMN_TOFILEENTRYID_TOFILEENTRYID_2 = "dlFileShortcut.toFileEntryId = ?";
3641            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
3642            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileShortcut.folderId = ?";
3643            private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "dlFileShortcut.groupId = ? AND ";
3644            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "dlFileShortcut.folderId = ? AND ";
3645            private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "dlFileShortcut.status = ?";
3646            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileShortcut.fileShortcutId";
3647            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_WHERE = "SELECT DISTINCT {dlFileShortcut.*} FROM DLFileShortcut dlFileShortcut WHERE ";
3648            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_1 =
3649                    "SELECT {DLFileShortcut.*} FROM (SELECT DISTINCT dlFileShortcut.fileShortcutId FROM DLFileShortcut dlFileShortcut WHERE ";
3650            private static final String _FILTER_SQL_SELECT_DLFILESHORTCUT_NO_INLINE_DISTINCT_WHERE_2 =
3651                    ") TEMP_TABLE INNER JOIN DLFileShortcut ON TEMP_TABLE.fileShortcutId = DLFileShortcut.fileShortcutId";
3652            private static final String _FILTER_SQL_COUNT_DLFILESHORTCUT_WHERE = "SELECT COUNT(DISTINCT dlFileShortcut.fileShortcutId) AS COUNT_VALUE FROM DLFileShortcut dlFileShortcut WHERE ";
3653            private static final String _FILTER_ENTITY_ALIAS = "dlFileShortcut";
3654            private static final String _FILTER_ENTITY_TABLE = "DLFileShortcut";
3655            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileShortcut.";
3656            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileShortcut.";
3657            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileShortcut exists with the primary key ";
3658            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileShortcut exists with the key {";
3659            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3660            private static Log _log = LogFactoryUtil.getLog(DLFileShortcutPersistenceImpl.class);
3661            private static DLFileShortcut _nullDLFileShortcut = new DLFileShortcutImpl() {
3662                            @Override
3663                            public Object clone() {
3664                                    return this;
3665                            }
3666    
3667                            @Override
3668                            public CacheModel<DLFileShortcut> toCacheModel() {
3669                                    return _nullDLFileShortcutCacheModel;
3670                            }
3671                    };
3672    
3673            private static CacheModel<DLFileShortcut> _nullDLFileShortcutCacheModel = new CacheModel<DLFileShortcut>() {
3674                            public DLFileShortcut toEntityModel() {
3675                                    return _nullDLFileShortcut;
3676                            }
3677                    };
3678    }