001    /**
002     * Copyright (c) 2000-2011 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.ImagePersistence;
044    import com.liferay.portal.service.persistence.LockPersistence;
045    import com.liferay.portal.service.persistence.ResourcePersistence;
046    import com.liferay.portal.service.persistence.UserPersistence;
047    import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
048    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
049    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050    
051    import com.liferay.portlet.asset.service.persistence.AssetCategoryPersistence;
052    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
053    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
054    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
055    import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
056    import com.liferay.portlet.documentlibrary.model.DLFileEntry;
057    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
058    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryModelImpl;
059    import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructurePersistence;
060    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
061    
062    import java.io.Serializable;
063    
064    import java.util.ArrayList;
065    import java.util.Collections;
066    import java.util.List;
067    
068    /**
069     * The persistence implementation for the document library file entry service.
070     *
071     * <p>
072     * Caching information and settings can be found in <code>portal.properties</code>
073     * </p>
074     *
075     * @author Brian Wing Shun Chan
076     * @see DLFileEntryPersistence
077     * @see DLFileEntryUtil
078     * @generated
079     */
080    public class DLFileEntryPersistenceImpl extends BasePersistenceImpl<DLFileEntry>
081            implements DLFileEntryPersistence {
082            /*
083             * NOTE FOR DEVELOPERS:
084             *
085             * Never modify or reference this class directly. Always use {@link DLFileEntryUtil} to access the document library file entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
086             */
087            public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryImpl.class.getName();
088            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089                    ".List1";
090            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091                    ".List2";
092            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
093                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
094                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
095                            new String[] {
096                                    String.class.getName(),
097                                    
098                            "java.lang.Integer", "java.lang.Integer",
099                                    "com.liferay.portal.kernel.util.OrderByComparator"
100                            });
101            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
102                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
104                            new String[] { String.class.getName() },
105                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK);
106            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
107                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
109                            new String[] { String.class.getName() });
110            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
111                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
112                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
113                            new String[] { String.class.getName(), Long.class.getName() },
114                            DLFileEntryModelImpl.UUID_COLUMN_BITMASK |
115                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK);
116            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
117                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
118                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
119                            new String[] { String.class.getName(), Long.class.getName() });
120            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
121                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
122                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
123                            new String[] {
124                                    Long.class.getName(),
125                                    
126                            "java.lang.Integer", "java.lang.Integer",
127                                    "com.liferay.portal.kernel.util.OrderByComparator"
128                            });
129            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
130                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
131                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
132                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
133                            new String[] { Long.class.getName() },
134                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK);
135            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
136                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
137                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
138                            new String[] { Long.class.getName() });
139            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
140                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
141                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
142                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
143                            new String[] {
144                                    Long.class.getName(),
145                                    
146                            "java.lang.Integer", "java.lang.Integer",
147                                    "com.liferay.portal.kernel.util.OrderByComparator"
148                            });
149            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
150                    new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
151                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
152                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
153                            new String[] { Long.class.getName() },
154                            DLFileEntryModelImpl.COMPANYID_COLUMN_BITMASK);
155            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
156                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
157                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
158                            new String[] { Long.class.getName() });
159            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
160                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
161                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U",
162                            new String[] {
163                                    Long.class.getName(), Long.class.getName(),
164                                    
165                            "java.lang.Integer", "java.lang.Integer",
166                                    "com.liferay.portal.kernel.util.OrderByComparator"
167                            });
168            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
169                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
170                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
171                            new String[] { Long.class.getName(), Long.class.getName() },
172                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
173                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK);
174            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
175                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
176                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
177                            new String[] { Long.class.getName(), Long.class.getName() });
178            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
179                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
180                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F",
181                            new String[] {
182                                    Long.class.getName(), Long.class.getName(),
183                                    
184                            "java.lang.Integer", "java.lang.Integer",
185                                    "com.liferay.portal.kernel.util.OrderByComparator"
186                            });
187            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
188                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
189                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
190                            new String[] { Long.class.getName(), Long.class.getName() },
191                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
192                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK);
193            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
194                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
195                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
196                            new String[] { Long.class.getName(), Long.class.getName() });
197            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
198                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
199                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_F",
200                            new String[] {
201                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
202                                    
203                            "java.lang.Integer", "java.lang.Integer",
204                                    "com.liferay.portal.kernel.util.OrderByComparator"
205                            });
206            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
207                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
208                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F",
209                            new String[] {
210                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
211                            },
212                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
213                            DLFileEntryModelImpl.USERID_COLUMN_BITMASK |
214                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK);
215            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
216                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
217                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F",
218                            new String[] {
219                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
220                            });
221            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
222                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
223                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_N",
224                            new String[] {
225                                    Long.class.getName(), Long.class.getName(),
226                                    String.class.getName()
227                            },
228                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
229                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
230                            DLFileEntryModelImpl.NAME_COLUMN_BITMASK);
231            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
232                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
233                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_N",
234                            new String[] {
235                                    Long.class.getName(), Long.class.getName(),
236                                    String.class.getName()
237                            });
238            public static final FinderPath FINDER_PATH_FETCH_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
239                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
240                            FINDER_CLASS_NAME_ENTITY, "fetchByG_F_T",
241                            new String[] {
242                                    Long.class.getName(), Long.class.getName(),
243                                    String.class.getName()
244                            },
245                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
246                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
247                            DLFileEntryModelImpl.TITLE_COLUMN_BITMASK);
248            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
249                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
250                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_T",
251                            new String[] {
252                                    Long.class.getName(), Long.class.getName(),
253                                    String.class.getName()
254                            });
255            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
256                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
257                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_F_F",
258                            new String[] {
259                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
260                                    
261                            "java.lang.Integer", "java.lang.Integer",
262                                    "com.liferay.portal.kernel.util.OrderByComparator"
263                            });
264            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
265                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
266                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_F",
267                            new String[] {
268                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
269                            },
270                            DLFileEntryModelImpl.GROUPID_COLUMN_BITMASK |
271                            DLFileEntryModelImpl.FOLDERID_COLUMN_BITMASK |
272                            DLFileEntryModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK);
273            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_F = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
274                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
275                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_F",
276                            new String[] {
277                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
278                            });
279            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
280                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
281                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
282            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
283                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, DLFileEntryImpl.class,
284                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
285            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
286                            DLFileEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
287                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
288    
289            /**
290             * Caches the document library file entry in the entity cache if it is enabled.
291             *
292             * @param dlFileEntry the document library file entry
293             */
294            public void cacheResult(DLFileEntry dlFileEntry) {
295                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
296                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
297    
298                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
299                            new Object[] {
300                                    dlFileEntry.getUuid(), Long.valueOf(dlFileEntry.getGroupId())
301                            }, dlFileEntry);
302    
303                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
304                            new Object[] {
305                                    Long.valueOf(dlFileEntry.getGroupId()),
306                                    Long.valueOf(dlFileEntry.getFolderId()),
307                                    
308                            dlFileEntry.getName()
309                            }, dlFileEntry);
310    
311                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
312                            new Object[] {
313                                    Long.valueOf(dlFileEntry.getGroupId()),
314                                    Long.valueOf(dlFileEntry.getFolderId()),
315                                    
316                            dlFileEntry.getTitle()
317                            }, dlFileEntry);
318    
319                    dlFileEntry.resetOriginalValues();
320            }
321    
322            /**
323             * Caches the document library file entries in the entity cache if it is enabled.
324             *
325             * @param dlFileEntries the document library file entries
326             */
327            public void cacheResult(List<DLFileEntry> dlFileEntries) {
328                    for (DLFileEntry dlFileEntry : dlFileEntries) {
329                            if (EntityCacheUtil.getResult(
330                                                    DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
331                                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey()) == null) {
332                                    cacheResult(dlFileEntry);
333                            }
334                            else {
335                                    dlFileEntry.resetOriginalValues();
336                            }
337                    }
338            }
339    
340            /**
341             * Clears the cache for all document library file entries.
342             *
343             * <p>
344             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
345             * </p>
346             */
347            @Override
348            public void clearCache() {
349                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
350                            CacheRegistryUtil.clear(DLFileEntryImpl.class.getName());
351                    }
352    
353                    EntityCacheUtil.clearCache(DLFileEntryImpl.class.getName());
354    
355                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
356                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
357                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
358            }
359    
360            /**
361             * Clears the cache for the document library file entry.
362             *
363             * <p>
364             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
365             * </p>
366             */
367            @Override
368            public void clearCache(DLFileEntry dlFileEntry) {
369                    EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
370                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
371    
372                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
373                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
374    
375                    clearUniqueFindersCache(dlFileEntry);
376            }
377    
378            @Override
379            public void clearCache(List<DLFileEntry> dlFileEntries) {
380                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
381                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
382    
383                    for (DLFileEntry dlFileEntry : dlFileEntries) {
384                            EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
385                                    DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
386    
387                            clearUniqueFindersCache(dlFileEntry);
388                    }
389            }
390    
391            protected void clearUniqueFindersCache(DLFileEntry dlFileEntry) {
392                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
393                            new Object[] {
394                                    dlFileEntry.getUuid(), Long.valueOf(dlFileEntry.getGroupId())
395                            });
396    
397                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
398                            new Object[] {
399                                    Long.valueOf(dlFileEntry.getGroupId()),
400                                    Long.valueOf(dlFileEntry.getFolderId()),
401                                    
402                            dlFileEntry.getName()
403                            });
404    
405                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
406                            new Object[] {
407                                    Long.valueOf(dlFileEntry.getGroupId()),
408                                    Long.valueOf(dlFileEntry.getFolderId()),
409                                    
410                            dlFileEntry.getTitle()
411                            });
412            }
413    
414            /**
415             * Creates a new document library file entry with the primary key. Does not add the document library file entry to the database.
416             *
417             * @param fileEntryId the primary key for the new document library file entry
418             * @return the new document library file entry
419             */
420            public DLFileEntry create(long fileEntryId) {
421                    DLFileEntry dlFileEntry = new DLFileEntryImpl();
422    
423                    dlFileEntry.setNew(true);
424                    dlFileEntry.setPrimaryKey(fileEntryId);
425    
426                    String uuid = PortalUUIDUtil.generate();
427    
428                    dlFileEntry.setUuid(uuid);
429    
430                    return dlFileEntry;
431            }
432    
433            /**
434             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
435             *
436             * @param fileEntryId the primary key of the document library file entry
437             * @return the document library file entry that was removed
438             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
439             * @throws SystemException if a system exception occurred
440             */
441            public DLFileEntry remove(long fileEntryId)
442                    throws NoSuchFileEntryException, SystemException {
443                    return remove(Long.valueOf(fileEntryId));
444            }
445    
446            /**
447             * Removes the document library file entry with the primary key from the database. Also notifies the appropriate model listeners.
448             *
449             * @param primaryKey the primary key of the document library file entry
450             * @return the document library file entry that was removed
451             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
452             * @throws SystemException if a system exception occurred
453             */
454            @Override
455            public DLFileEntry remove(Serializable primaryKey)
456                    throws NoSuchFileEntryException, SystemException {
457                    Session session = null;
458    
459                    try {
460                            session = openSession();
461    
462                            DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
463                                            primaryKey);
464    
465                            if (dlFileEntry == null) {
466                                    if (_log.isWarnEnabled()) {
467                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
468                                    }
469    
470                                    throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
471                                            primaryKey);
472                            }
473    
474                            return remove(dlFileEntry);
475                    }
476                    catch (NoSuchFileEntryException nsee) {
477                            throw nsee;
478                    }
479                    catch (Exception e) {
480                            throw processException(e);
481                    }
482                    finally {
483                            closeSession(session);
484                    }
485            }
486    
487            @Override
488            protected DLFileEntry removeImpl(DLFileEntry dlFileEntry)
489                    throws SystemException {
490                    dlFileEntry = toUnwrappedModel(dlFileEntry);
491    
492                    Session session = null;
493    
494                    try {
495                            session = openSession();
496    
497                            BatchSessionUtil.delete(session, dlFileEntry);
498                    }
499                    catch (Exception e) {
500                            throw processException(e);
501                    }
502                    finally {
503                            closeSession(session);
504                    }
505    
506                    clearCache(dlFileEntry);
507    
508                    return dlFileEntry;
509            }
510    
511            @Override
512            public DLFileEntry updateImpl(
513                    com.liferay.portlet.documentlibrary.model.DLFileEntry dlFileEntry,
514                    boolean merge) throws SystemException {
515                    dlFileEntry = toUnwrappedModel(dlFileEntry);
516    
517                    boolean isNew = dlFileEntry.isNew();
518    
519                    DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
520    
521                    if (Validator.isNull(dlFileEntry.getUuid())) {
522                            String uuid = PortalUUIDUtil.generate();
523    
524                            dlFileEntry.setUuid(uuid);
525                    }
526    
527                    Session session = null;
528    
529                    try {
530                            session = openSession();
531    
532                            BatchSessionUtil.update(session, dlFileEntry, merge);
533    
534                            dlFileEntry.setNew(false);
535                    }
536                    catch (Exception e) {
537                            throw processException(e);
538                    }
539                    finally {
540                            closeSession(session);
541                    }
542    
543                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
544    
545                    if (isNew || !DLFileEntryModelImpl.COLUMN_BITMASK_ENABLED) {
546                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
547                    }
548    
549                    else {
550                            if ((dlFileEntryModelImpl.getColumnBitmask() &
551                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
552                                    Object[] args = new Object[] {
553                                                    dlFileEntryModelImpl.getOriginalUuid()
554                                            };
555    
556                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
557                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
558                                            args);
559    
560                                    args = new Object[] { dlFileEntryModelImpl.getUuid() };
561    
562                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
563                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
564                                            args);
565                            }
566    
567                            if ((dlFileEntryModelImpl.getColumnBitmask() &
568                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
569                                    Object[] args = new Object[] {
570                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId())
571                                            };
572    
573                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
574                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
575                                            args);
576    
577                                    args = new Object[] {
578                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId())
579                                            };
580    
581                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
582                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
583                                            args);
584                            }
585    
586                            if ((dlFileEntryModelImpl.getColumnBitmask() &
587                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
588                                    Object[] args = new Object[] {
589                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalCompanyId())
590                                            };
591    
592                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
593                                            args);
594                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
595                                            args);
596    
597                                    args = new Object[] {
598                                                    Long.valueOf(dlFileEntryModelImpl.getCompanyId())
599                                            };
600    
601                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
602                                            args);
603                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
604                                            args);
605                            }
606    
607                            if ((dlFileEntryModelImpl.getColumnBitmask() &
608                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
609                                    Object[] args = new Object[] {
610                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
611                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalUserId())
612                                            };
613    
614                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
615                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
616                                            args);
617    
618                                    args = new Object[] {
619                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
620                                                    Long.valueOf(dlFileEntryModelImpl.getUserId())
621                                            };
622    
623                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
624                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
625                                            args);
626                            }
627    
628                            if ((dlFileEntryModelImpl.getColumnBitmask() &
629                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
630                                    Object[] args = new Object[] {
631                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
632                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId())
633                                            };
634    
635                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
636                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
637                                            args);
638    
639                                    args = new Object[] {
640                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
641                                                    Long.valueOf(dlFileEntryModelImpl.getFolderId())
642                                            };
643    
644                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
645                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
646                                            args);
647                            }
648    
649                            if ((dlFileEntryModelImpl.getColumnBitmask() &
650                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F.getColumnBitmask()) != 0) {
651                                    Object[] args = new Object[] {
652                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
653                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalUserId()),
654                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId())
655                                            };
656    
657                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
658                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
659                                            args);
660    
661                                    args = new Object[] {
662                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
663                                                    Long.valueOf(dlFileEntryModelImpl.getUserId()),
664                                                    Long.valueOf(dlFileEntryModelImpl.getFolderId())
665                                            };
666    
667                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F, args);
668                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F,
669                                            args);
670                            }
671    
672                            if ((dlFileEntryModelImpl.getColumnBitmask() &
673                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F.getColumnBitmask()) != 0) {
674                                    Object[] args = new Object[] {
675                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
676                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId()),
677                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFileEntryTypeId())
678                                            };
679    
680                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
681                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
682                                            args);
683    
684                                    args = new Object[] {
685                                                    Long.valueOf(dlFileEntryModelImpl.getGroupId()),
686                                                    Long.valueOf(dlFileEntryModelImpl.getFolderId()),
687                                                    Long.valueOf(dlFileEntryModelImpl.getFileEntryTypeId())
688                                            };
689    
690                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_F, args);
691                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F,
692                                            args);
693                            }
694                    }
695    
696                    EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
697                            DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
698    
699                    if (isNew) {
700                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
701                                    new Object[] {
702                                            dlFileEntry.getUuid(),
703                                            Long.valueOf(dlFileEntry.getGroupId())
704                                    }, dlFileEntry);
705    
706                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
707                                    new Object[] {
708                                            Long.valueOf(dlFileEntry.getGroupId()),
709                                            Long.valueOf(dlFileEntry.getFolderId()),
710                                            
711                                    dlFileEntry.getName()
712                                    }, dlFileEntry);
713    
714                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
715                                    new Object[] {
716                                            Long.valueOf(dlFileEntry.getGroupId()),
717                                            Long.valueOf(dlFileEntry.getFolderId()),
718                                            
719                                    dlFileEntry.getTitle()
720                                    }, dlFileEntry);
721                    }
722                    else {
723                            if ((dlFileEntryModelImpl.getColumnBitmask() &
724                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
725                                    Object[] args = new Object[] {
726                                                    dlFileEntryModelImpl.getOriginalUuid(),
727                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId())
728                                            };
729    
730                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
731                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
732    
733                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
734                                            new Object[] {
735                                                    dlFileEntry.getUuid(),
736                                                    Long.valueOf(dlFileEntry.getGroupId())
737                                            }, dlFileEntry);
738                            }
739    
740                            if ((dlFileEntryModelImpl.getColumnBitmask() &
741                                            FINDER_PATH_FETCH_BY_G_F_N.getColumnBitmask()) != 0) {
742                                    Object[] args = new Object[] {
743                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
744                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId()),
745                                                    
746                                                    dlFileEntryModelImpl.getOriginalName()
747                                            };
748    
749                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_N, args);
750                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N, args);
751    
752                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
753                                            new Object[] {
754                                                    Long.valueOf(dlFileEntry.getGroupId()),
755                                                    Long.valueOf(dlFileEntry.getFolderId()),
756                                                    
757                                            dlFileEntry.getName()
758                                            }, dlFileEntry);
759                            }
760    
761                            if ((dlFileEntryModelImpl.getColumnBitmask() &
762                                            FINDER_PATH_FETCH_BY_G_F_T.getColumnBitmask()) != 0) {
763                                    Object[] args = new Object[] {
764                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalGroupId()),
765                                                    Long.valueOf(dlFileEntryModelImpl.getOriginalFolderId()),
766                                                    
767                                                    dlFileEntryModelImpl.getOriginalTitle()
768                                            };
769    
770                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_T, args);
771                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T, args);
772    
773                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
774                                            new Object[] {
775                                                    Long.valueOf(dlFileEntry.getGroupId()),
776                                                    Long.valueOf(dlFileEntry.getFolderId()),
777                                                    
778                                            dlFileEntry.getTitle()
779                                            }, dlFileEntry);
780                            }
781                    }
782    
783                    return dlFileEntry;
784            }
785    
786            protected DLFileEntry toUnwrappedModel(DLFileEntry dlFileEntry) {
787                    if (dlFileEntry instanceof DLFileEntryImpl) {
788                            return dlFileEntry;
789                    }
790    
791                    DLFileEntryImpl dlFileEntryImpl = new DLFileEntryImpl();
792    
793                    dlFileEntryImpl.setNew(dlFileEntry.isNew());
794                    dlFileEntryImpl.setPrimaryKey(dlFileEntry.getPrimaryKey());
795    
796                    dlFileEntryImpl.setUuid(dlFileEntry.getUuid());
797                    dlFileEntryImpl.setFileEntryId(dlFileEntry.getFileEntryId());
798                    dlFileEntryImpl.setGroupId(dlFileEntry.getGroupId());
799                    dlFileEntryImpl.setCompanyId(dlFileEntry.getCompanyId());
800                    dlFileEntryImpl.setUserId(dlFileEntry.getUserId());
801                    dlFileEntryImpl.setUserName(dlFileEntry.getUserName());
802                    dlFileEntryImpl.setVersionUserId(dlFileEntry.getVersionUserId());
803                    dlFileEntryImpl.setVersionUserName(dlFileEntry.getVersionUserName());
804                    dlFileEntryImpl.setCreateDate(dlFileEntry.getCreateDate());
805                    dlFileEntryImpl.setModifiedDate(dlFileEntry.getModifiedDate());
806                    dlFileEntryImpl.setRepositoryId(dlFileEntry.getRepositoryId());
807                    dlFileEntryImpl.setFolderId(dlFileEntry.getFolderId());
808                    dlFileEntryImpl.setName(dlFileEntry.getName());
809                    dlFileEntryImpl.setExtension(dlFileEntry.getExtension());
810                    dlFileEntryImpl.setMimeType(dlFileEntry.getMimeType());
811                    dlFileEntryImpl.setTitle(dlFileEntry.getTitle());
812                    dlFileEntryImpl.setDescription(dlFileEntry.getDescription());
813                    dlFileEntryImpl.setExtraSettings(dlFileEntry.getExtraSettings());
814                    dlFileEntryImpl.setFileEntryTypeId(dlFileEntry.getFileEntryTypeId());
815                    dlFileEntryImpl.setVersion(dlFileEntry.getVersion());
816                    dlFileEntryImpl.setSize(dlFileEntry.getSize());
817                    dlFileEntryImpl.setReadCount(dlFileEntry.getReadCount());
818                    dlFileEntryImpl.setSmallImageId(dlFileEntry.getSmallImageId());
819                    dlFileEntryImpl.setLargeImageId(dlFileEntry.getLargeImageId());
820                    dlFileEntryImpl.setCustom1ImageId(dlFileEntry.getCustom1ImageId());
821                    dlFileEntryImpl.setCustom2ImageId(dlFileEntry.getCustom2ImageId());
822    
823                    return dlFileEntryImpl;
824            }
825    
826            /**
827             * Returns the document library file entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
828             *
829             * @param primaryKey the primary key of the document library file entry
830             * @return the document library file entry
831             * @throws com.liferay.portal.NoSuchModelException if a document library file entry with the primary key could not be found
832             * @throws SystemException if a system exception occurred
833             */
834            @Override
835            public DLFileEntry findByPrimaryKey(Serializable primaryKey)
836                    throws NoSuchModelException, SystemException {
837                    return findByPrimaryKey(((Long)primaryKey).longValue());
838            }
839    
840            /**
841             * Returns the document library file entry with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryException} if it could not be found.
842             *
843             * @param fileEntryId the primary key of the document library file entry
844             * @return the document library file entry
845             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
846             * @throws SystemException if a system exception occurred
847             */
848            public DLFileEntry findByPrimaryKey(long fileEntryId)
849                    throws NoSuchFileEntryException, SystemException {
850                    DLFileEntry dlFileEntry = fetchByPrimaryKey(fileEntryId);
851    
852                    if (dlFileEntry == null) {
853                            if (_log.isWarnEnabled()) {
854                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileEntryId);
855                            }
856    
857                            throw new NoSuchFileEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
858                                    fileEntryId);
859                    }
860    
861                    return dlFileEntry;
862            }
863    
864            /**
865             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
866             *
867             * @param primaryKey the primary key of the document library file entry
868             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
869             * @throws SystemException if a system exception occurred
870             */
871            @Override
872            public DLFileEntry fetchByPrimaryKey(Serializable primaryKey)
873                    throws SystemException {
874                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
875            }
876    
877            /**
878             * Returns the document library file entry with the primary key or returns <code>null</code> if it could not be found.
879             *
880             * @param fileEntryId the primary key of the document library file entry
881             * @return the document library file entry, or <code>null</code> if a document library file entry with the primary key could not be found
882             * @throws SystemException if a system exception occurred
883             */
884            public DLFileEntry fetchByPrimaryKey(long fileEntryId)
885                    throws SystemException {
886                    DLFileEntry dlFileEntry = (DLFileEntry)EntityCacheUtil.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
887                                    DLFileEntryImpl.class, fileEntryId);
888    
889                    if (dlFileEntry == _nullDLFileEntry) {
890                            return null;
891                    }
892    
893                    if (dlFileEntry == null) {
894                            Session session = null;
895    
896                            boolean hasException = false;
897    
898                            try {
899                                    session = openSession();
900    
901                                    dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
902                                                    Long.valueOf(fileEntryId));
903                            }
904                            catch (Exception e) {
905                                    hasException = true;
906    
907                                    throw processException(e);
908                            }
909                            finally {
910                                    if (dlFileEntry != null) {
911                                            cacheResult(dlFileEntry);
912                                    }
913                                    else if (!hasException) {
914                                            EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
915                                                    DLFileEntryImpl.class, fileEntryId, _nullDLFileEntry);
916                                    }
917    
918                                    closeSession(session);
919                            }
920                    }
921    
922                    return dlFileEntry;
923            }
924    
925            /**
926             * Returns all the document library file entries where uuid = &#63;.
927             *
928             * @param uuid the uuid
929             * @return the matching document library file entries
930             * @throws SystemException if a system exception occurred
931             */
932            public List<DLFileEntry> findByUuid(String uuid) throws SystemException {
933                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
934            }
935    
936            /**
937             * Returns a range of all the document library file entries where uuid = &#63;.
938             *
939             * <p>
940             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
941             * </p>
942             *
943             * @param uuid the uuid
944             * @param start the lower bound of the range of document library file entries
945             * @param end the upper bound of the range of document library file entries (not inclusive)
946             * @return the range of matching document library file entries
947             * @throws SystemException if a system exception occurred
948             */
949            public List<DLFileEntry> findByUuid(String uuid, int start, int end)
950                    throws SystemException {
951                    return findByUuid(uuid, start, end, null);
952            }
953    
954            /**
955             * Returns an ordered range of all the document library file entries where uuid = &#63;.
956             *
957             * <p>
958             * 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.
959             * </p>
960             *
961             * @param uuid the uuid
962             * @param start the lower bound of the range of document library file entries
963             * @param end the upper bound of the range of document library file entries (not inclusive)
964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
965             * @return the ordered range of matching document library file entries
966             * @throws SystemException if a system exception occurred
967             */
968            public List<DLFileEntry> findByUuid(String uuid, int start, int end,
969                    OrderByComparator orderByComparator) throws SystemException {
970                    FinderPath finderPath = null;
971                    Object[] finderArgs = null;
972    
973                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
974                                    (orderByComparator == null)) {
975                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
976                            finderArgs = new Object[] { uuid };
977                    }
978                    else {
979                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
980                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
981                    }
982    
983                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
984                                    finderArgs, this);
985    
986                    if (list == null) {
987                            StringBundler query = null;
988    
989                            if (orderByComparator != null) {
990                                    query = new StringBundler(3 +
991                                                    (orderByComparator.getOrderByFields().length * 3));
992                            }
993                            else {
994                                    query = new StringBundler(3);
995                            }
996    
997                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
998    
999                            if (uuid == null) {
1000                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1001                            }
1002                            else {
1003                                    if (uuid.equals(StringPool.BLANK)) {
1004                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1005                                    }
1006                                    else {
1007                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1008                                    }
1009                            }
1010    
1011                            if (orderByComparator != null) {
1012                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1013                                            orderByComparator);
1014                            }
1015    
1016                            else {
1017                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1018                            }
1019    
1020                            String sql = query.toString();
1021    
1022                            Session session = null;
1023    
1024                            try {
1025                                    session = openSession();
1026    
1027                                    Query q = session.createQuery(sql);
1028    
1029                                    QueryPos qPos = QueryPos.getInstance(q);
1030    
1031                                    if (uuid != null) {
1032                                            qPos.add(uuid);
1033                                    }
1034    
1035                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1036                                                    start, end);
1037                            }
1038                            catch (Exception e) {
1039                                    throw processException(e);
1040                            }
1041                            finally {
1042                                    if (list == null) {
1043                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1044                                    }
1045                                    else {
1046                                            cacheResult(list);
1047    
1048                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1049                                    }
1050    
1051                                    closeSession(session);
1052                            }
1053                    }
1054    
1055                    return list;
1056            }
1057    
1058            /**
1059             * Returns the first document library file entry in the ordered set where uuid = &#63;.
1060             *
1061             * <p>
1062             * 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.
1063             * </p>
1064             *
1065             * @param uuid the uuid
1066             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1067             * @return the first matching document library file entry
1068             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1069             * @throws SystemException if a system exception occurred
1070             */
1071            public DLFileEntry findByUuid_First(String uuid,
1072                    OrderByComparator orderByComparator)
1073                    throws NoSuchFileEntryException, SystemException {
1074                    List<DLFileEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
1075    
1076                    if (list.isEmpty()) {
1077                            StringBundler msg = new StringBundler(4);
1078    
1079                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1080    
1081                            msg.append("uuid=");
1082                            msg.append(uuid);
1083    
1084                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1085    
1086                            throw new NoSuchFileEntryException(msg.toString());
1087                    }
1088                    else {
1089                            return list.get(0);
1090                    }
1091            }
1092    
1093            /**
1094             * Returns the last document library file entry in the ordered set where uuid = &#63;.
1095             *
1096             * <p>
1097             * 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.
1098             * </p>
1099             *
1100             * @param uuid the uuid
1101             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1102             * @return the last matching document library file entry
1103             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1104             * @throws SystemException if a system exception occurred
1105             */
1106            public DLFileEntry findByUuid_Last(String uuid,
1107                    OrderByComparator orderByComparator)
1108                    throws NoSuchFileEntryException, SystemException {
1109                    int count = countByUuid(uuid);
1110    
1111                    List<DLFileEntry> list = findByUuid(uuid, count - 1, count,
1112                                    orderByComparator);
1113    
1114                    if (list.isEmpty()) {
1115                            StringBundler msg = new StringBundler(4);
1116    
1117                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1118    
1119                            msg.append("uuid=");
1120                            msg.append(uuid);
1121    
1122                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1123    
1124                            throw new NoSuchFileEntryException(msg.toString());
1125                    }
1126                    else {
1127                            return list.get(0);
1128                    }
1129            }
1130    
1131            /**
1132             * Returns the document library file entries before and after the current document library file entry in the ordered set where uuid = &#63;.
1133             *
1134             * <p>
1135             * 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.
1136             * </p>
1137             *
1138             * @param fileEntryId the primary key of the current document library file entry
1139             * @param uuid the uuid
1140             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1141             * @return the previous, current, and next document library file entry
1142             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
1143             * @throws SystemException if a system exception occurred
1144             */
1145            public DLFileEntry[] findByUuid_PrevAndNext(long fileEntryId, String uuid,
1146                    OrderByComparator orderByComparator)
1147                    throws NoSuchFileEntryException, SystemException {
1148                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1149    
1150                    Session session = null;
1151    
1152                    try {
1153                            session = openSession();
1154    
1155                            DLFileEntry[] array = new DLFileEntryImpl[3];
1156    
1157                            array[0] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
1158                                            orderByComparator, true);
1159    
1160                            array[1] = dlFileEntry;
1161    
1162                            array[2] = getByUuid_PrevAndNext(session, dlFileEntry, uuid,
1163                                            orderByComparator, false);
1164    
1165                            return array;
1166                    }
1167                    catch (Exception e) {
1168                            throw processException(e);
1169                    }
1170                    finally {
1171                            closeSession(session);
1172                    }
1173            }
1174    
1175            protected DLFileEntry getByUuid_PrevAndNext(Session session,
1176                    DLFileEntry dlFileEntry, String uuid,
1177                    OrderByComparator orderByComparator, boolean previous) {
1178                    StringBundler query = null;
1179    
1180                    if (orderByComparator != null) {
1181                            query = new StringBundler(6 +
1182                                            (orderByComparator.getOrderByFields().length * 6));
1183                    }
1184                    else {
1185                            query = new StringBundler(3);
1186                    }
1187    
1188                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1189    
1190                    if (uuid == null) {
1191                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1192                    }
1193                    else {
1194                            if (uuid.equals(StringPool.BLANK)) {
1195                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1196                            }
1197                            else {
1198                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1199                            }
1200                    }
1201    
1202                    if (orderByComparator != null) {
1203                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1204    
1205                            if (orderByConditionFields.length > 0) {
1206                                    query.append(WHERE_AND);
1207                            }
1208    
1209                            for (int i = 0; i < orderByConditionFields.length; i++) {
1210                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1211                                    query.append(orderByConditionFields[i]);
1212    
1213                                    if ((i + 1) < orderByConditionFields.length) {
1214                                            if (orderByComparator.isAscending() ^ previous) {
1215                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1216                                            }
1217                                            else {
1218                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1219                                            }
1220                                    }
1221                                    else {
1222                                            if (orderByComparator.isAscending() ^ previous) {
1223                                                    query.append(WHERE_GREATER_THAN);
1224                                            }
1225                                            else {
1226                                                    query.append(WHERE_LESSER_THAN);
1227                                            }
1228                                    }
1229                            }
1230    
1231                            query.append(ORDER_BY_CLAUSE);
1232    
1233                            String[] orderByFields = orderByComparator.getOrderByFields();
1234    
1235                            for (int i = 0; i < orderByFields.length; i++) {
1236                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1237                                    query.append(orderByFields[i]);
1238    
1239                                    if ((i + 1) < orderByFields.length) {
1240                                            if (orderByComparator.isAscending() ^ previous) {
1241                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1242                                            }
1243                                            else {
1244                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1245                                            }
1246                                    }
1247                                    else {
1248                                            if (orderByComparator.isAscending() ^ previous) {
1249                                                    query.append(ORDER_BY_ASC);
1250                                            }
1251                                            else {
1252                                                    query.append(ORDER_BY_DESC);
1253                                            }
1254                                    }
1255                            }
1256                    }
1257    
1258                    else {
1259                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1260                    }
1261    
1262                    String sql = query.toString();
1263    
1264                    Query q = session.createQuery(sql);
1265    
1266                    q.setFirstResult(0);
1267                    q.setMaxResults(2);
1268    
1269                    QueryPos qPos = QueryPos.getInstance(q);
1270    
1271                    if (uuid != null) {
1272                            qPos.add(uuid);
1273                    }
1274    
1275                    if (orderByComparator != null) {
1276                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
1277    
1278                            for (Object value : values) {
1279                                    qPos.add(value);
1280                            }
1281                    }
1282    
1283                    List<DLFileEntry> list = q.list();
1284    
1285                    if (list.size() == 2) {
1286                            return list.get(1);
1287                    }
1288                    else {
1289                            return null;
1290                    }
1291            }
1292    
1293            /**
1294             * Returns the document library file entry where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryException} if it could not be found.
1295             *
1296             * @param uuid the uuid
1297             * @param groupId the group ID
1298             * @return the matching document library file entry
1299             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1300             * @throws SystemException if a system exception occurred
1301             */
1302            public DLFileEntry findByUUID_G(String uuid, long groupId)
1303                    throws NoSuchFileEntryException, SystemException {
1304                    DLFileEntry dlFileEntry = fetchByUUID_G(uuid, groupId);
1305    
1306                    if (dlFileEntry == null) {
1307                            StringBundler msg = new StringBundler(6);
1308    
1309                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1310    
1311                            msg.append("uuid=");
1312                            msg.append(uuid);
1313    
1314                            msg.append(", groupId=");
1315                            msg.append(groupId);
1316    
1317                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1318    
1319                            if (_log.isWarnEnabled()) {
1320                                    _log.warn(msg.toString());
1321                            }
1322    
1323                            throw new NoSuchFileEntryException(msg.toString());
1324                    }
1325    
1326                    return dlFileEntry;
1327            }
1328    
1329            /**
1330             * Returns the document library file entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1331             *
1332             * @param uuid the uuid
1333             * @param groupId the group ID
1334             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1335             * @throws SystemException if a system exception occurred
1336             */
1337            public DLFileEntry fetchByUUID_G(String uuid, long groupId)
1338                    throws SystemException {
1339                    return fetchByUUID_G(uuid, groupId, true);
1340            }
1341    
1342            /**
1343             * Returns the document library file entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1344             *
1345             * @param uuid the uuid
1346             * @param groupId the group ID
1347             * @param retrieveFromCache whether to use the finder cache
1348             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
1349             * @throws SystemException if a system exception occurred
1350             */
1351            public DLFileEntry fetchByUUID_G(String uuid, long groupId,
1352                    boolean retrieveFromCache) throws SystemException {
1353                    Object[] finderArgs = new Object[] { uuid, groupId };
1354    
1355                    Object result = null;
1356    
1357                    if (retrieveFromCache) {
1358                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1359                                            finderArgs, this);
1360                    }
1361    
1362                    if (result == null) {
1363                            StringBundler query = new StringBundler(4);
1364    
1365                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1366    
1367                            if (uuid == null) {
1368                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1369                            }
1370                            else {
1371                                    if (uuid.equals(StringPool.BLANK)) {
1372                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1373                                    }
1374                                    else {
1375                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1376                                    }
1377                            }
1378    
1379                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1380    
1381                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1382    
1383                            String sql = query.toString();
1384    
1385                            Session session = null;
1386    
1387                            try {
1388                                    session = openSession();
1389    
1390                                    Query q = session.createQuery(sql);
1391    
1392                                    QueryPos qPos = QueryPos.getInstance(q);
1393    
1394                                    if (uuid != null) {
1395                                            qPos.add(uuid);
1396                                    }
1397    
1398                                    qPos.add(groupId);
1399    
1400                                    List<DLFileEntry> list = q.list();
1401    
1402                                    result = list;
1403    
1404                                    DLFileEntry dlFileEntry = null;
1405    
1406                                    if (list.isEmpty()) {
1407                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1408                                                    finderArgs, list);
1409                                    }
1410                                    else {
1411                                            dlFileEntry = list.get(0);
1412    
1413                                            cacheResult(dlFileEntry);
1414    
1415                                            if ((dlFileEntry.getUuid() == null) ||
1416                                                            !dlFileEntry.getUuid().equals(uuid) ||
1417                                                            (dlFileEntry.getGroupId() != groupId)) {
1418                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1419                                                            finderArgs, dlFileEntry);
1420                                            }
1421                                    }
1422    
1423                                    return dlFileEntry;
1424                            }
1425                            catch (Exception e) {
1426                                    throw processException(e);
1427                            }
1428                            finally {
1429                                    if (result == null) {
1430                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1431                                                    finderArgs);
1432                                    }
1433    
1434                                    closeSession(session);
1435                            }
1436                    }
1437                    else {
1438                            if (result instanceof List<?>) {
1439                                    return null;
1440                            }
1441                            else {
1442                                    return (DLFileEntry)result;
1443                            }
1444                    }
1445            }
1446    
1447            /**
1448             * Returns all the document library file entries where groupId = &#63;.
1449             *
1450             * @param groupId the group ID
1451             * @return the matching document library file entries
1452             * @throws SystemException if a system exception occurred
1453             */
1454            public List<DLFileEntry> findByGroupId(long groupId)
1455                    throws SystemException {
1456                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1457            }
1458    
1459            /**
1460             * Returns a range of all the document library file entries where groupId = &#63;.
1461             *
1462             * <p>
1463             * 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.
1464             * </p>
1465             *
1466             * @param groupId the group ID
1467             * @param start the lower bound of the range of document library file entries
1468             * @param end the upper bound of the range of document library file entries (not inclusive)
1469             * @return the range of matching document library file entries
1470             * @throws SystemException if a system exception occurred
1471             */
1472            public List<DLFileEntry> findByGroupId(long groupId, int start, int end)
1473                    throws SystemException {
1474                    return findByGroupId(groupId, start, end, null);
1475            }
1476    
1477            /**
1478             * Returns an ordered range of all the document library file entries where groupId = &#63;.
1479             *
1480             * <p>
1481             * 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.
1482             * </p>
1483             *
1484             * @param groupId the group ID
1485             * @param start the lower bound of the range of document library file entries
1486             * @param end the upper bound of the range of document library file entries (not inclusive)
1487             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1488             * @return the ordered range of matching document library file entries
1489             * @throws SystemException if a system exception occurred
1490             */
1491            public List<DLFileEntry> findByGroupId(long groupId, int start, int end,
1492                    OrderByComparator orderByComparator) throws SystemException {
1493                    FinderPath finderPath = null;
1494                    Object[] finderArgs = null;
1495    
1496                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1497                                    (orderByComparator == null)) {
1498                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1499                            finderArgs = new Object[] { groupId };
1500                    }
1501                    else {
1502                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1503                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1504                    }
1505    
1506                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
1507                                    finderArgs, this);
1508    
1509                    if (list == null) {
1510                            StringBundler query = null;
1511    
1512                            if (orderByComparator != null) {
1513                                    query = new StringBundler(3 +
1514                                                    (orderByComparator.getOrderByFields().length * 3));
1515                            }
1516                            else {
1517                                    query = new StringBundler(3);
1518                            }
1519    
1520                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1521    
1522                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1523    
1524                            if (orderByComparator != null) {
1525                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1526                                            orderByComparator);
1527                            }
1528    
1529                            else {
1530                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1531                            }
1532    
1533                            String sql = query.toString();
1534    
1535                            Session session = null;
1536    
1537                            try {
1538                                    session = openSession();
1539    
1540                                    Query q = session.createQuery(sql);
1541    
1542                                    QueryPos qPos = QueryPos.getInstance(q);
1543    
1544                                    qPos.add(groupId);
1545    
1546                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1547                                                    start, end);
1548                            }
1549                            catch (Exception e) {
1550                                    throw processException(e);
1551                            }
1552                            finally {
1553                                    if (list == null) {
1554                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1555                                    }
1556                                    else {
1557                                            cacheResult(list);
1558    
1559                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1560                                    }
1561    
1562                                    closeSession(session);
1563                            }
1564                    }
1565    
1566                    return list;
1567            }
1568    
1569            /**
1570             * Returns the first document library file entry in the ordered set where groupId = &#63;.
1571             *
1572             * <p>
1573             * 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.
1574             * </p>
1575             *
1576             * @param groupId the group ID
1577             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1578             * @return the first matching document library file entry
1579             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1580             * @throws SystemException if a system exception occurred
1581             */
1582            public DLFileEntry findByGroupId_First(long groupId,
1583                    OrderByComparator orderByComparator)
1584                    throws NoSuchFileEntryException, SystemException {
1585                    List<DLFileEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1586    
1587                    if (list.isEmpty()) {
1588                            StringBundler msg = new StringBundler(4);
1589    
1590                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1591    
1592                            msg.append("groupId=");
1593                            msg.append(groupId);
1594    
1595                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1596    
1597                            throw new NoSuchFileEntryException(msg.toString());
1598                    }
1599                    else {
1600                            return list.get(0);
1601                    }
1602            }
1603    
1604            /**
1605             * Returns the last document library file entry in the ordered set where groupId = &#63;.
1606             *
1607             * <p>
1608             * 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.
1609             * </p>
1610             *
1611             * @param groupId the group ID
1612             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1613             * @return the last matching document library file entry
1614             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
1615             * @throws SystemException if a system exception occurred
1616             */
1617            public DLFileEntry findByGroupId_Last(long groupId,
1618                    OrderByComparator orderByComparator)
1619                    throws NoSuchFileEntryException, SystemException {
1620                    int count = countByGroupId(groupId);
1621    
1622                    List<DLFileEntry> list = findByGroupId(groupId, count - 1, count,
1623                                    orderByComparator);
1624    
1625                    if (list.isEmpty()) {
1626                            StringBundler msg = new StringBundler(4);
1627    
1628                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1629    
1630                            msg.append("groupId=");
1631                            msg.append(groupId);
1632    
1633                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1634    
1635                            throw new NoSuchFileEntryException(msg.toString());
1636                    }
1637                    else {
1638                            return list.get(0);
1639                    }
1640            }
1641    
1642            /**
1643             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63;.
1644             *
1645             * <p>
1646             * 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.
1647             * </p>
1648             *
1649             * @param fileEntryId the primary key of the current document library file entry
1650             * @param groupId the group ID
1651             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1652             * @return the previous, current, and next document library file entry
1653             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
1654             * @throws SystemException if a system exception occurred
1655             */
1656            public DLFileEntry[] findByGroupId_PrevAndNext(long fileEntryId,
1657                    long groupId, OrderByComparator orderByComparator)
1658                    throws NoSuchFileEntryException, SystemException {
1659                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1660    
1661                    Session session = null;
1662    
1663                    try {
1664                            session = openSession();
1665    
1666                            DLFileEntry[] array = new DLFileEntryImpl[3];
1667    
1668                            array[0] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1669                                            orderByComparator, true);
1670    
1671                            array[1] = dlFileEntry;
1672    
1673                            array[2] = getByGroupId_PrevAndNext(session, dlFileEntry, groupId,
1674                                            orderByComparator, false);
1675    
1676                            return array;
1677                    }
1678                    catch (Exception e) {
1679                            throw processException(e);
1680                    }
1681                    finally {
1682                            closeSession(session);
1683                    }
1684            }
1685    
1686            protected DLFileEntry getByGroupId_PrevAndNext(Session session,
1687                    DLFileEntry dlFileEntry, long groupId,
1688                    OrderByComparator orderByComparator, boolean previous) {
1689                    StringBundler query = null;
1690    
1691                    if (orderByComparator != null) {
1692                            query = new StringBundler(6 +
1693                                            (orderByComparator.getOrderByFields().length * 6));
1694                    }
1695                    else {
1696                            query = new StringBundler(3);
1697                    }
1698    
1699                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
1700    
1701                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1702    
1703                    if (orderByComparator != null) {
1704                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1705    
1706                            if (orderByConditionFields.length > 0) {
1707                                    query.append(WHERE_AND);
1708                            }
1709    
1710                            for (int i = 0; i < orderByConditionFields.length; i++) {
1711                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1712                                    query.append(orderByConditionFields[i]);
1713    
1714                                    if ((i + 1) < orderByConditionFields.length) {
1715                                            if (orderByComparator.isAscending() ^ previous) {
1716                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1717                                            }
1718                                            else {
1719                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1720                                            }
1721                                    }
1722                                    else {
1723                                            if (orderByComparator.isAscending() ^ previous) {
1724                                                    query.append(WHERE_GREATER_THAN);
1725                                            }
1726                                            else {
1727                                                    query.append(WHERE_LESSER_THAN);
1728                                            }
1729                                    }
1730                            }
1731    
1732                            query.append(ORDER_BY_CLAUSE);
1733    
1734                            String[] orderByFields = orderByComparator.getOrderByFields();
1735    
1736                            for (int i = 0; i < orderByFields.length; i++) {
1737                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1738                                    query.append(orderByFields[i]);
1739    
1740                                    if ((i + 1) < orderByFields.length) {
1741                                            if (orderByComparator.isAscending() ^ previous) {
1742                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1743                                            }
1744                                            else {
1745                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1746                                            }
1747                                    }
1748                                    else {
1749                                            if (orderByComparator.isAscending() ^ previous) {
1750                                                    query.append(ORDER_BY_ASC);
1751                                            }
1752                                            else {
1753                                                    query.append(ORDER_BY_DESC);
1754                                            }
1755                                    }
1756                            }
1757                    }
1758    
1759                    else {
1760                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1761                    }
1762    
1763                    String sql = query.toString();
1764    
1765                    Query q = session.createQuery(sql);
1766    
1767                    q.setFirstResult(0);
1768                    q.setMaxResults(2);
1769    
1770                    QueryPos qPos = QueryPos.getInstance(q);
1771    
1772                    qPos.add(groupId);
1773    
1774                    if (orderByComparator != null) {
1775                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
1776    
1777                            for (Object value : values) {
1778                                    qPos.add(value);
1779                            }
1780                    }
1781    
1782                    List<DLFileEntry> list = q.list();
1783    
1784                    if (list.size() == 2) {
1785                            return list.get(1);
1786                    }
1787                    else {
1788                            return null;
1789                    }
1790            }
1791    
1792            /**
1793             * Returns all the document library file entries that the user has permission to view where groupId = &#63;.
1794             *
1795             * @param groupId the group ID
1796             * @return the matching document library file entries that the user has permission to view
1797             * @throws SystemException if a system exception occurred
1798             */
1799            public List<DLFileEntry> filterFindByGroupId(long groupId)
1800                    throws SystemException {
1801                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1802                            QueryUtil.ALL_POS, null);
1803            }
1804    
1805            /**
1806             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63;.
1807             *
1808             * <p>
1809             * 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.
1810             * </p>
1811             *
1812             * @param groupId the group ID
1813             * @param start the lower bound of the range of document library file entries
1814             * @param end the upper bound of the range of document library file entries (not inclusive)
1815             * @return the range of matching document library file entries that the user has permission to view
1816             * @throws SystemException if a system exception occurred
1817             */
1818            public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1819                    int end) throws SystemException {
1820                    return filterFindByGroupId(groupId, start, end, null);
1821            }
1822    
1823            /**
1824             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63;.
1825             *
1826             * <p>
1827             * 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.
1828             * </p>
1829             *
1830             * @param groupId the group ID
1831             * @param start the lower bound of the range of document library file entries
1832             * @param end the upper bound of the range of document library file entries (not inclusive)
1833             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1834             * @return the ordered range of matching document library file entries that the user has permission to view
1835             * @throws SystemException if a system exception occurred
1836             */
1837            public List<DLFileEntry> filterFindByGroupId(long groupId, int start,
1838                    int end, OrderByComparator orderByComparator) throws SystemException {
1839                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1840                            return findByGroupId(groupId, start, end, orderByComparator);
1841                    }
1842    
1843                    StringBundler query = null;
1844    
1845                    if (orderByComparator != null) {
1846                            query = new StringBundler(3 +
1847                                            (orderByComparator.getOrderByFields().length * 3));
1848                    }
1849                    else {
1850                            query = new StringBundler(3);
1851                    }
1852    
1853                    if (getDB().isSupportsInlineDistinct()) {
1854                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
1855                    }
1856                    else {
1857                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
1858                    }
1859    
1860                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1861    
1862                    if (!getDB().isSupportsInlineDistinct()) {
1863                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
1864                    }
1865    
1866                    if (orderByComparator != null) {
1867                            if (getDB().isSupportsInlineDistinct()) {
1868                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1869                                            orderByComparator);
1870                            }
1871                            else {
1872                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1873                                            orderByComparator);
1874                            }
1875                    }
1876    
1877                    else {
1878                            if (getDB().isSupportsInlineDistinct()) {
1879                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
1880                            }
1881                            else {
1882                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
1883                            }
1884                    }
1885    
1886                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1887                                    DLFileEntry.class.getName(),
1888                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1889    
1890                    Session session = null;
1891    
1892                    try {
1893                            session = openSession();
1894    
1895                            SQLQuery q = session.createSQLQuery(sql);
1896    
1897                            if (getDB().isSupportsInlineDistinct()) {
1898                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
1899                            }
1900                            else {
1901                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
1902                            }
1903    
1904                            QueryPos qPos = QueryPos.getInstance(q);
1905    
1906                            qPos.add(groupId);
1907    
1908                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
1909                    }
1910                    catch (Exception e) {
1911                            throw processException(e);
1912                    }
1913                    finally {
1914                            closeSession(session);
1915                    }
1916            }
1917    
1918            /**
1919             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63;.
1920             *
1921             * @param fileEntryId the primary key of the current document library file entry
1922             * @param groupId the group ID
1923             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1924             * @return the previous, current, and next document library file entry
1925             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
1926             * @throws SystemException if a system exception occurred
1927             */
1928            public DLFileEntry[] filterFindByGroupId_PrevAndNext(long fileEntryId,
1929                    long groupId, OrderByComparator orderByComparator)
1930                    throws NoSuchFileEntryException, SystemException {
1931                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1932                            return findByGroupId_PrevAndNext(fileEntryId, groupId,
1933                                    orderByComparator);
1934                    }
1935    
1936                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1937    
1938                    Session session = null;
1939    
1940                    try {
1941                            session = openSession();
1942    
1943                            DLFileEntry[] array = new DLFileEntryImpl[3];
1944    
1945                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFileEntry,
1946                                            groupId, orderByComparator, true);
1947    
1948                            array[1] = dlFileEntry;
1949    
1950                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFileEntry,
1951                                            groupId, orderByComparator, false);
1952    
1953                            return array;
1954                    }
1955                    catch (Exception e) {
1956                            throw processException(e);
1957                    }
1958                    finally {
1959                            closeSession(session);
1960                    }
1961            }
1962    
1963            protected DLFileEntry filterGetByGroupId_PrevAndNext(Session session,
1964                    DLFileEntry dlFileEntry, long groupId,
1965                    OrderByComparator orderByComparator, boolean previous) {
1966                    StringBundler query = null;
1967    
1968                    if (orderByComparator != null) {
1969                            query = new StringBundler(6 +
1970                                            (orderByComparator.getOrderByFields().length * 6));
1971                    }
1972                    else {
1973                            query = new StringBundler(3);
1974                    }
1975    
1976                    if (getDB().isSupportsInlineDistinct()) {
1977                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
1978                    }
1979                    else {
1980                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
1981                    }
1982    
1983                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1984    
1985                    if (!getDB().isSupportsInlineDistinct()) {
1986                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
1987                    }
1988    
1989                    if (orderByComparator != null) {
1990                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1991    
1992                            if (orderByConditionFields.length > 0) {
1993                                    query.append(WHERE_AND);
1994                            }
1995    
1996                            for (int i = 0; i < orderByConditionFields.length; i++) {
1997                                    if (getDB().isSupportsInlineDistinct()) {
1998                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1999                                    }
2000                                    else {
2001                                            query.append(_ORDER_BY_ENTITY_TABLE);
2002                                    }
2003    
2004                                    query.append(orderByConditionFields[i]);
2005    
2006                                    if ((i + 1) < orderByConditionFields.length) {
2007                                            if (orderByComparator.isAscending() ^ previous) {
2008                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2009                                            }
2010                                            else {
2011                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2012                                            }
2013                                    }
2014                                    else {
2015                                            if (orderByComparator.isAscending() ^ previous) {
2016                                                    query.append(WHERE_GREATER_THAN);
2017                                            }
2018                                            else {
2019                                                    query.append(WHERE_LESSER_THAN);
2020                                            }
2021                                    }
2022                            }
2023    
2024                            query.append(ORDER_BY_CLAUSE);
2025    
2026                            String[] orderByFields = orderByComparator.getOrderByFields();
2027    
2028                            for (int i = 0; i < orderByFields.length; i++) {
2029                                    if (getDB().isSupportsInlineDistinct()) {
2030                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2031                                    }
2032                                    else {
2033                                            query.append(_ORDER_BY_ENTITY_TABLE);
2034                                    }
2035    
2036                                    query.append(orderByFields[i]);
2037    
2038                                    if ((i + 1) < orderByFields.length) {
2039                                            if (orderByComparator.isAscending() ^ previous) {
2040                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2041                                            }
2042                                            else {
2043                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2044                                            }
2045                                    }
2046                                    else {
2047                                            if (orderByComparator.isAscending() ^ previous) {
2048                                                    query.append(ORDER_BY_ASC);
2049                                            }
2050                                            else {
2051                                                    query.append(ORDER_BY_DESC);
2052                                            }
2053                                    }
2054                            }
2055                    }
2056    
2057                    else {
2058                            if (getDB().isSupportsInlineDistinct()) {
2059                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2060                            }
2061                            else {
2062                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
2063                            }
2064                    }
2065    
2066                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2067                                    DLFileEntry.class.getName(),
2068                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2069    
2070                    SQLQuery q = session.createSQLQuery(sql);
2071    
2072                    q.setFirstResult(0);
2073                    q.setMaxResults(2);
2074    
2075                    if (getDB().isSupportsInlineDistinct()) {
2076                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
2077                    }
2078                    else {
2079                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
2080                    }
2081    
2082                    QueryPos qPos = QueryPos.getInstance(q);
2083    
2084                    qPos.add(groupId);
2085    
2086                    if (orderByComparator != null) {
2087                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2088    
2089                            for (Object value : values) {
2090                                    qPos.add(value);
2091                            }
2092                    }
2093    
2094                    List<DLFileEntry> list = q.list();
2095    
2096                    if (list.size() == 2) {
2097                            return list.get(1);
2098                    }
2099                    else {
2100                            return null;
2101                    }
2102            }
2103    
2104            /**
2105             * Returns all the document library file entries where companyId = &#63;.
2106             *
2107             * @param companyId the company ID
2108             * @return the matching document library file entries
2109             * @throws SystemException if a system exception occurred
2110             */
2111            public List<DLFileEntry> findByCompanyId(long companyId)
2112                    throws SystemException {
2113                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2114                            null);
2115            }
2116    
2117            /**
2118             * Returns a range of all the document library file entries where companyId = &#63;.
2119             *
2120             * <p>
2121             * 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.
2122             * </p>
2123             *
2124             * @param companyId the company ID
2125             * @param start the lower bound of the range of document library file entries
2126             * @param end the upper bound of the range of document library file entries (not inclusive)
2127             * @return the range of matching document library file entries
2128             * @throws SystemException if a system exception occurred
2129             */
2130            public List<DLFileEntry> findByCompanyId(long companyId, int start, int end)
2131                    throws SystemException {
2132                    return findByCompanyId(companyId, start, end, null);
2133            }
2134    
2135            /**
2136             * Returns an ordered range of all the document library file entries where companyId = &#63;.
2137             *
2138             * <p>
2139             * 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.
2140             * </p>
2141             *
2142             * @param companyId the company ID
2143             * @param start the lower bound of the range of document library file entries
2144             * @param end the upper bound of the range of document library file entries (not inclusive)
2145             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2146             * @return the ordered range of matching document library file entries
2147             * @throws SystemException if a system exception occurred
2148             */
2149            public List<DLFileEntry> findByCompanyId(long companyId, int start,
2150                    int end, OrderByComparator orderByComparator) throws SystemException {
2151                    FinderPath finderPath = null;
2152                    Object[] finderArgs = null;
2153    
2154                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2155                                    (orderByComparator == null)) {
2156                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2157                            finderArgs = new Object[] { companyId };
2158                    }
2159                    else {
2160                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2161                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2162                    }
2163    
2164                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
2165                                    finderArgs, this);
2166    
2167                    if (list == null) {
2168                            StringBundler query = null;
2169    
2170                            if (orderByComparator != null) {
2171                                    query = new StringBundler(3 +
2172                                                    (orderByComparator.getOrderByFields().length * 3));
2173                            }
2174                            else {
2175                                    query = new StringBundler(3);
2176                            }
2177    
2178                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2179    
2180                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2181    
2182                            if (orderByComparator != null) {
2183                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2184                                            orderByComparator);
2185                            }
2186    
2187                            else {
2188                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2189                            }
2190    
2191                            String sql = query.toString();
2192    
2193                            Session session = null;
2194    
2195                            try {
2196                                    session = openSession();
2197    
2198                                    Query q = session.createQuery(sql);
2199    
2200                                    QueryPos qPos = QueryPos.getInstance(q);
2201    
2202                                    qPos.add(companyId);
2203    
2204                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2205                                                    start, end);
2206                            }
2207                            catch (Exception e) {
2208                                    throw processException(e);
2209                            }
2210                            finally {
2211                                    if (list == null) {
2212                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2213                                    }
2214                                    else {
2215                                            cacheResult(list);
2216    
2217                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2218                                    }
2219    
2220                                    closeSession(session);
2221                            }
2222                    }
2223    
2224                    return list;
2225            }
2226    
2227            /**
2228             * Returns the first document library file entry in the ordered set where companyId = &#63;.
2229             *
2230             * <p>
2231             * 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.
2232             * </p>
2233             *
2234             * @param companyId the company ID
2235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2236             * @return the first matching document library file entry
2237             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
2238             * @throws SystemException if a system exception occurred
2239             */
2240            public DLFileEntry findByCompanyId_First(long companyId,
2241                    OrderByComparator orderByComparator)
2242                    throws NoSuchFileEntryException, SystemException {
2243                    List<DLFileEntry> list = findByCompanyId(companyId, 0, 1,
2244                                    orderByComparator);
2245    
2246                    if (list.isEmpty()) {
2247                            StringBundler msg = new StringBundler(4);
2248    
2249                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2250    
2251                            msg.append("companyId=");
2252                            msg.append(companyId);
2253    
2254                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2255    
2256                            throw new NoSuchFileEntryException(msg.toString());
2257                    }
2258                    else {
2259                            return list.get(0);
2260                    }
2261            }
2262    
2263            /**
2264             * Returns the last document library file entry in the ordered set where companyId = &#63;.
2265             *
2266             * <p>
2267             * 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.
2268             * </p>
2269             *
2270             * @param companyId the company ID
2271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2272             * @return the last matching document library file entry
2273             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
2274             * @throws SystemException if a system exception occurred
2275             */
2276            public DLFileEntry findByCompanyId_Last(long companyId,
2277                    OrderByComparator orderByComparator)
2278                    throws NoSuchFileEntryException, SystemException {
2279                    int count = countByCompanyId(companyId);
2280    
2281                    List<DLFileEntry> list = findByCompanyId(companyId, count - 1, count,
2282                                    orderByComparator);
2283    
2284                    if (list.isEmpty()) {
2285                            StringBundler msg = new StringBundler(4);
2286    
2287                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2288    
2289                            msg.append("companyId=");
2290                            msg.append(companyId);
2291    
2292                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2293    
2294                            throw new NoSuchFileEntryException(msg.toString());
2295                    }
2296                    else {
2297                            return list.get(0);
2298                    }
2299            }
2300    
2301            /**
2302             * Returns the document library file entries before and after the current document library file entry in the ordered set where companyId = &#63;.
2303             *
2304             * <p>
2305             * 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.
2306             * </p>
2307             *
2308             * @param fileEntryId the primary key of the current document library file entry
2309             * @param companyId the company ID
2310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2311             * @return the previous, current, and next document library file entry
2312             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
2313             * @throws SystemException if a system exception occurred
2314             */
2315            public DLFileEntry[] findByCompanyId_PrevAndNext(long fileEntryId,
2316                    long companyId, OrderByComparator orderByComparator)
2317                    throws NoSuchFileEntryException, SystemException {
2318                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2319    
2320                    Session session = null;
2321    
2322                    try {
2323                            session = openSession();
2324    
2325                            DLFileEntry[] array = new DLFileEntryImpl[3];
2326    
2327                            array[0] = getByCompanyId_PrevAndNext(session, dlFileEntry,
2328                                            companyId, orderByComparator, true);
2329    
2330                            array[1] = dlFileEntry;
2331    
2332                            array[2] = getByCompanyId_PrevAndNext(session, dlFileEntry,
2333                                            companyId, orderByComparator, false);
2334    
2335                            return array;
2336                    }
2337                    catch (Exception e) {
2338                            throw processException(e);
2339                    }
2340                    finally {
2341                            closeSession(session);
2342                    }
2343            }
2344    
2345            protected DLFileEntry getByCompanyId_PrevAndNext(Session session,
2346                    DLFileEntry dlFileEntry, long companyId,
2347                    OrderByComparator orderByComparator, boolean previous) {
2348                    StringBundler query = null;
2349    
2350                    if (orderByComparator != null) {
2351                            query = new StringBundler(6 +
2352                                            (orderByComparator.getOrderByFields().length * 6));
2353                    }
2354                    else {
2355                            query = new StringBundler(3);
2356                    }
2357    
2358                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2359    
2360                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2361    
2362                    if (orderByComparator != null) {
2363                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2364    
2365                            if (orderByConditionFields.length > 0) {
2366                                    query.append(WHERE_AND);
2367                            }
2368    
2369                            for (int i = 0; i < orderByConditionFields.length; i++) {
2370                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2371                                    query.append(orderByConditionFields[i]);
2372    
2373                                    if ((i + 1) < orderByConditionFields.length) {
2374                                            if (orderByComparator.isAscending() ^ previous) {
2375                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2376                                            }
2377                                            else {
2378                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2379                                            }
2380                                    }
2381                                    else {
2382                                            if (orderByComparator.isAscending() ^ previous) {
2383                                                    query.append(WHERE_GREATER_THAN);
2384                                            }
2385                                            else {
2386                                                    query.append(WHERE_LESSER_THAN);
2387                                            }
2388                                    }
2389                            }
2390    
2391                            query.append(ORDER_BY_CLAUSE);
2392    
2393                            String[] orderByFields = orderByComparator.getOrderByFields();
2394    
2395                            for (int i = 0; i < orderByFields.length; i++) {
2396                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2397                                    query.append(orderByFields[i]);
2398    
2399                                    if ((i + 1) < orderByFields.length) {
2400                                            if (orderByComparator.isAscending() ^ previous) {
2401                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2402                                            }
2403                                            else {
2404                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2405                                            }
2406                                    }
2407                                    else {
2408                                            if (orderByComparator.isAscending() ^ previous) {
2409                                                    query.append(ORDER_BY_ASC);
2410                                            }
2411                                            else {
2412                                                    query.append(ORDER_BY_DESC);
2413                                            }
2414                                    }
2415                            }
2416                    }
2417    
2418                    else {
2419                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2420                    }
2421    
2422                    String sql = query.toString();
2423    
2424                    Query q = session.createQuery(sql);
2425    
2426                    q.setFirstResult(0);
2427                    q.setMaxResults(2);
2428    
2429                    QueryPos qPos = QueryPos.getInstance(q);
2430    
2431                    qPos.add(companyId);
2432    
2433                    if (orderByComparator != null) {
2434                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2435    
2436                            for (Object value : values) {
2437                                    qPos.add(value);
2438                            }
2439                    }
2440    
2441                    List<DLFileEntry> list = q.list();
2442    
2443                    if (list.size() == 2) {
2444                            return list.get(1);
2445                    }
2446                    else {
2447                            return null;
2448                    }
2449            }
2450    
2451            /**
2452             * Returns all the document library file entries where groupId = &#63; and userId = &#63;.
2453             *
2454             * @param groupId the group ID
2455             * @param userId the user ID
2456             * @return the matching document library file entries
2457             * @throws SystemException if a system exception occurred
2458             */
2459            public List<DLFileEntry> findByG_U(long groupId, long userId)
2460                    throws SystemException {
2461                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2462                            null);
2463            }
2464    
2465            /**
2466             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63;.
2467             *
2468             * <p>
2469             * 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.
2470             * </p>
2471             *
2472             * @param groupId the group ID
2473             * @param userId the user ID
2474             * @param start the lower bound of the range of document library file entries
2475             * @param end the upper bound of the range of document library file entries (not inclusive)
2476             * @return the range of matching document library file entries
2477             * @throws SystemException if a system exception occurred
2478             */
2479            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
2480                    int end) throws SystemException {
2481                    return findByG_U(groupId, userId, start, end, null);
2482            }
2483    
2484            /**
2485             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63;.
2486             *
2487             * <p>
2488             * 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.
2489             * </p>
2490             *
2491             * @param groupId the group ID
2492             * @param userId the user ID
2493             * @param start the lower bound of the range of document library file entries
2494             * @param end the upper bound of the range of document library file entries (not inclusive)
2495             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2496             * @return the ordered range of matching document library file entries
2497             * @throws SystemException if a system exception occurred
2498             */
2499            public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
2500                    int end, OrderByComparator orderByComparator) throws SystemException {
2501                    FinderPath finderPath = null;
2502                    Object[] finderArgs = null;
2503    
2504                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2505                                    (orderByComparator == null)) {
2506                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
2507                            finderArgs = new Object[] { groupId, userId };
2508                    }
2509                    else {
2510                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
2511                            finderArgs = new Object[] {
2512                                            groupId, userId,
2513                                            
2514                                            start, end, orderByComparator
2515                                    };
2516                    }
2517    
2518                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
2519                                    finderArgs, this);
2520    
2521                    if (list == null) {
2522                            StringBundler query = null;
2523    
2524                            if (orderByComparator != null) {
2525                                    query = new StringBundler(4 +
2526                                                    (orderByComparator.getOrderByFields().length * 3));
2527                            }
2528                            else {
2529                                    query = new StringBundler(4);
2530                            }
2531    
2532                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2533    
2534                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2535    
2536                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2537    
2538                            if (orderByComparator != null) {
2539                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2540                                            orderByComparator);
2541                            }
2542    
2543                            else {
2544                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2545                            }
2546    
2547                            String sql = query.toString();
2548    
2549                            Session session = null;
2550    
2551                            try {
2552                                    session = openSession();
2553    
2554                                    Query q = session.createQuery(sql);
2555    
2556                                    QueryPos qPos = QueryPos.getInstance(q);
2557    
2558                                    qPos.add(groupId);
2559    
2560                                    qPos.add(userId);
2561    
2562                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2563                                                    start, end);
2564                            }
2565                            catch (Exception e) {
2566                                    throw processException(e);
2567                            }
2568                            finally {
2569                                    if (list == null) {
2570                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2571                                    }
2572                                    else {
2573                                            cacheResult(list);
2574    
2575                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2576                                    }
2577    
2578                                    closeSession(session);
2579                            }
2580                    }
2581    
2582                    return list;
2583            }
2584    
2585            /**
2586             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
2587             *
2588             * <p>
2589             * 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.
2590             * </p>
2591             *
2592             * @param groupId the group ID
2593             * @param userId the user ID
2594             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2595             * @return the first matching document library file entry
2596             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
2597             * @throws SystemException if a system exception occurred
2598             */
2599            public DLFileEntry findByG_U_First(long groupId, long userId,
2600                    OrderByComparator orderByComparator)
2601                    throws NoSuchFileEntryException, SystemException {
2602                    List<DLFileEntry> list = findByG_U(groupId, userId, 0, 1,
2603                                    orderByComparator);
2604    
2605                    if (list.isEmpty()) {
2606                            StringBundler msg = new StringBundler(6);
2607    
2608                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2609    
2610                            msg.append("groupId=");
2611                            msg.append(groupId);
2612    
2613                            msg.append(", userId=");
2614                            msg.append(userId);
2615    
2616                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2617    
2618                            throw new NoSuchFileEntryException(msg.toString());
2619                    }
2620                    else {
2621                            return list.get(0);
2622                    }
2623            }
2624    
2625            /**
2626             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
2627             *
2628             * <p>
2629             * 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.
2630             * </p>
2631             *
2632             * @param groupId the group ID
2633             * @param userId the user ID
2634             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2635             * @return the last matching document library file entry
2636             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
2637             * @throws SystemException if a system exception occurred
2638             */
2639            public DLFileEntry findByG_U_Last(long groupId, long userId,
2640                    OrderByComparator orderByComparator)
2641                    throws NoSuchFileEntryException, SystemException {
2642                    int count = countByG_U(groupId, userId);
2643    
2644                    List<DLFileEntry> list = findByG_U(groupId, userId, count - 1, count,
2645                                    orderByComparator);
2646    
2647                    if (list.isEmpty()) {
2648                            StringBundler msg = new StringBundler(6);
2649    
2650                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2651    
2652                            msg.append("groupId=");
2653                            msg.append(groupId);
2654    
2655                            msg.append(", userId=");
2656                            msg.append(userId);
2657    
2658                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2659    
2660                            throw new NoSuchFileEntryException(msg.toString());
2661                    }
2662                    else {
2663                            return list.get(0);
2664                    }
2665            }
2666    
2667            /**
2668             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63; and userId = &#63;.
2669             *
2670             * <p>
2671             * 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.
2672             * </p>
2673             *
2674             * @param fileEntryId the primary key of the current document library file entry
2675             * @param groupId the group ID
2676             * @param userId the user ID
2677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2678             * @return the previous, current, and next document library file entry
2679             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
2680             * @throws SystemException if a system exception occurred
2681             */
2682            public DLFileEntry[] findByG_U_PrevAndNext(long fileEntryId, long groupId,
2683                    long userId, OrderByComparator orderByComparator)
2684                    throws NoSuchFileEntryException, SystemException {
2685                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2686    
2687                    Session session = null;
2688    
2689                    try {
2690                            session = openSession();
2691    
2692                            DLFileEntry[] array = new DLFileEntryImpl[3];
2693    
2694                            array[0] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
2695                                            userId, orderByComparator, true);
2696    
2697                            array[1] = dlFileEntry;
2698    
2699                            array[2] = getByG_U_PrevAndNext(session, dlFileEntry, groupId,
2700                                            userId, orderByComparator, false);
2701    
2702                            return array;
2703                    }
2704                    catch (Exception e) {
2705                            throw processException(e);
2706                    }
2707                    finally {
2708                            closeSession(session);
2709                    }
2710            }
2711    
2712            protected DLFileEntry getByG_U_PrevAndNext(Session session,
2713                    DLFileEntry dlFileEntry, long groupId, long userId,
2714                    OrderByComparator orderByComparator, boolean previous) {
2715                    StringBundler query = null;
2716    
2717                    if (orderByComparator != null) {
2718                            query = new StringBundler(6 +
2719                                            (orderByComparator.getOrderByFields().length * 6));
2720                    }
2721                    else {
2722                            query = new StringBundler(3);
2723                    }
2724    
2725                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
2726    
2727                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2728    
2729                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2730    
2731                    if (orderByComparator != null) {
2732                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2733    
2734                            if (orderByConditionFields.length > 0) {
2735                                    query.append(WHERE_AND);
2736                            }
2737    
2738                            for (int i = 0; i < orderByConditionFields.length; i++) {
2739                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2740                                    query.append(orderByConditionFields[i]);
2741    
2742                                    if ((i + 1) < orderByConditionFields.length) {
2743                                            if (orderByComparator.isAscending() ^ previous) {
2744                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2745                                            }
2746                                            else {
2747                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2748                                            }
2749                                    }
2750                                    else {
2751                                            if (orderByComparator.isAscending() ^ previous) {
2752                                                    query.append(WHERE_GREATER_THAN);
2753                                            }
2754                                            else {
2755                                                    query.append(WHERE_LESSER_THAN);
2756                                            }
2757                                    }
2758                            }
2759    
2760                            query.append(ORDER_BY_CLAUSE);
2761    
2762                            String[] orderByFields = orderByComparator.getOrderByFields();
2763    
2764                            for (int i = 0; i < orderByFields.length; i++) {
2765                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2766                                    query.append(orderByFields[i]);
2767    
2768                                    if ((i + 1) < orderByFields.length) {
2769                                            if (orderByComparator.isAscending() ^ previous) {
2770                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2771                                            }
2772                                            else {
2773                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2774                                            }
2775                                    }
2776                                    else {
2777                                            if (orderByComparator.isAscending() ^ previous) {
2778                                                    query.append(ORDER_BY_ASC);
2779                                            }
2780                                            else {
2781                                                    query.append(ORDER_BY_DESC);
2782                                            }
2783                                    }
2784                            }
2785                    }
2786    
2787                    else {
2788                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2789                    }
2790    
2791                    String sql = query.toString();
2792    
2793                    Query q = session.createQuery(sql);
2794    
2795                    q.setFirstResult(0);
2796                    q.setMaxResults(2);
2797    
2798                    QueryPos qPos = QueryPos.getInstance(q);
2799    
2800                    qPos.add(groupId);
2801    
2802                    qPos.add(userId);
2803    
2804                    if (orderByComparator != null) {
2805                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
2806    
2807                            for (Object value : values) {
2808                                    qPos.add(value);
2809                            }
2810                    }
2811    
2812                    List<DLFileEntry> list = q.list();
2813    
2814                    if (list.size() == 2) {
2815                            return list.get(1);
2816                    }
2817                    else {
2818                            return null;
2819                    }
2820            }
2821    
2822            /**
2823             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2824             *
2825             * @param groupId the group ID
2826             * @param userId the user ID
2827             * @return the matching document library file entries that the user has permission to view
2828             * @throws SystemException if a system exception occurred
2829             */
2830            public List<DLFileEntry> filterFindByG_U(long groupId, long userId)
2831                    throws SystemException {
2832                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
2833                            QueryUtil.ALL_POS, null);
2834            }
2835    
2836            /**
2837             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2838             *
2839             * <p>
2840             * 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.
2841             * </p>
2842             *
2843             * @param groupId the group ID
2844             * @param userId the user ID
2845             * @param start the lower bound of the range of document library file entries
2846             * @param end the upper bound of the range of document library file entries (not inclusive)
2847             * @return the range of matching document library file entries that the user has permission to view
2848             * @throws SystemException if a system exception occurred
2849             */
2850            public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
2851                    int start, int end) throws SystemException {
2852                    return filterFindByG_U(groupId, userId, start, end, null);
2853            }
2854    
2855            /**
2856             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and userId = &#63;.
2857             *
2858             * <p>
2859             * 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.
2860             * </p>
2861             *
2862             * @param groupId the group ID
2863             * @param userId the user ID
2864             * @param start the lower bound of the range of document library file entries
2865             * @param end the upper bound of the range of document library file entries (not inclusive)
2866             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2867             * @return the ordered range of matching document library file entries that the user has permission to view
2868             * @throws SystemException if a system exception occurred
2869             */
2870            public List<DLFileEntry> filterFindByG_U(long groupId, long userId,
2871                    int start, int end, OrderByComparator orderByComparator)
2872                    throws SystemException {
2873                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2874                            return findByG_U(groupId, userId, start, end, orderByComparator);
2875                    }
2876    
2877                    StringBundler query = null;
2878    
2879                    if (orderByComparator != null) {
2880                            query = new StringBundler(4 +
2881                                            (orderByComparator.getOrderByFields().length * 3));
2882                    }
2883                    else {
2884                            query = new StringBundler(4);
2885                    }
2886    
2887                    if (getDB().isSupportsInlineDistinct()) {
2888                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
2889                    }
2890                    else {
2891                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
2892                    }
2893    
2894                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2895    
2896                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2897    
2898                    if (!getDB().isSupportsInlineDistinct()) {
2899                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
2900                    }
2901    
2902                    if (orderByComparator != null) {
2903                            if (getDB().isSupportsInlineDistinct()) {
2904                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2905                                            orderByComparator);
2906                            }
2907                            else {
2908                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2909                                            orderByComparator);
2910                            }
2911                    }
2912    
2913                    else {
2914                            if (getDB().isSupportsInlineDistinct()) {
2915                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
2916                            }
2917                            else {
2918                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
2919                            }
2920                    }
2921    
2922                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2923                                    DLFileEntry.class.getName(),
2924                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2925    
2926                    Session session = null;
2927    
2928                    try {
2929                            session = openSession();
2930    
2931                            SQLQuery q = session.createSQLQuery(sql);
2932    
2933                            if (getDB().isSupportsInlineDistinct()) {
2934                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
2935                            }
2936                            else {
2937                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
2938                            }
2939    
2940                            QueryPos qPos = QueryPos.getInstance(q);
2941    
2942                            qPos.add(groupId);
2943    
2944                            qPos.add(userId);
2945    
2946                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
2947                    }
2948                    catch (Exception e) {
2949                            throw processException(e);
2950                    }
2951                    finally {
2952                            closeSession(session);
2953                    }
2954            }
2955    
2956            /**
2957             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2958             *
2959             * @param fileEntryId the primary key of the current document library file entry
2960             * @param groupId the group ID
2961             * @param userId the user ID
2962             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2963             * @return the previous, current, and next document library file entry
2964             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
2965             * @throws SystemException if a system exception occurred
2966             */
2967            public DLFileEntry[] filterFindByG_U_PrevAndNext(long fileEntryId,
2968                    long groupId, long userId, OrderByComparator orderByComparator)
2969                    throws NoSuchFileEntryException, SystemException {
2970                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2971                            return findByG_U_PrevAndNext(fileEntryId, groupId, userId,
2972                                    orderByComparator);
2973                    }
2974    
2975                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2976    
2977                    Session session = null;
2978    
2979                    try {
2980                            session = openSession();
2981    
2982                            DLFileEntry[] array = new DLFileEntryImpl[3];
2983    
2984                            array[0] = filterGetByG_U_PrevAndNext(session, dlFileEntry,
2985                                            groupId, userId, orderByComparator, true);
2986    
2987                            array[1] = dlFileEntry;
2988    
2989                            array[2] = filterGetByG_U_PrevAndNext(session, dlFileEntry,
2990                                            groupId, userId, orderByComparator, false);
2991    
2992                            return array;
2993                    }
2994                    catch (Exception e) {
2995                            throw processException(e);
2996                    }
2997                    finally {
2998                            closeSession(session);
2999                    }
3000            }
3001    
3002            protected DLFileEntry filterGetByG_U_PrevAndNext(Session session,
3003                    DLFileEntry dlFileEntry, long groupId, long userId,
3004                    OrderByComparator orderByComparator, boolean previous) {
3005                    StringBundler query = null;
3006    
3007                    if (orderByComparator != null) {
3008                            query = new StringBundler(6 +
3009                                            (orderByComparator.getOrderByFields().length * 6));
3010                    }
3011                    else {
3012                            query = new StringBundler(3);
3013                    }
3014    
3015                    if (getDB().isSupportsInlineDistinct()) {
3016                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3017                    }
3018                    else {
3019                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
3020                    }
3021    
3022                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
3023    
3024                    query.append(_FINDER_COLUMN_G_U_USERID_2);
3025    
3026                    if (!getDB().isSupportsInlineDistinct()) {
3027                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
3028                    }
3029    
3030                    if (orderByComparator != null) {
3031                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3032    
3033                            if (orderByConditionFields.length > 0) {
3034                                    query.append(WHERE_AND);
3035                            }
3036    
3037                            for (int i = 0; i < orderByConditionFields.length; i++) {
3038                                    if (getDB().isSupportsInlineDistinct()) {
3039                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3040                                    }
3041                                    else {
3042                                            query.append(_ORDER_BY_ENTITY_TABLE);
3043                                    }
3044    
3045                                    query.append(orderByConditionFields[i]);
3046    
3047                                    if ((i + 1) < orderByConditionFields.length) {
3048                                            if (orderByComparator.isAscending() ^ previous) {
3049                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3050                                            }
3051                                            else {
3052                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3053                                            }
3054                                    }
3055                                    else {
3056                                            if (orderByComparator.isAscending() ^ previous) {
3057                                                    query.append(WHERE_GREATER_THAN);
3058                                            }
3059                                            else {
3060                                                    query.append(WHERE_LESSER_THAN);
3061                                            }
3062                                    }
3063                            }
3064    
3065                            query.append(ORDER_BY_CLAUSE);
3066    
3067                            String[] orderByFields = orderByComparator.getOrderByFields();
3068    
3069                            for (int i = 0; i < orderByFields.length; i++) {
3070                                    if (getDB().isSupportsInlineDistinct()) {
3071                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3072                                    }
3073                                    else {
3074                                            query.append(_ORDER_BY_ENTITY_TABLE);
3075                                    }
3076    
3077                                    query.append(orderByFields[i]);
3078    
3079                                    if ((i + 1) < orderByFields.length) {
3080                                            if (orderByComparator.isAscending() ^ previous) {
3081                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3082                                            }
3083                                            else {
3084                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3085                                            }
3086                                    }
3087                                    else {
3088                                            if (orderByComparator.isAscending() ^ previous) {
3089                                                    query.append(ORDER_BY_ASC);
3090                                            }
3091                                            else {
3092                                                    query.append(ORDER_BY_DESC);
3093                                            }
3094                                    }
3095                            }
3096                    }
3097    
3098                    else {
3099                            if (getDB().isSupportsInlineDistinct()) {
3100                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3101                            }
3102                            else {
3103                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
3104                            }
3105                    }
3106    
3107                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3108                                    DLFileEntry.class.getName(),
3109                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3110    
3111                    SQLQuery q = session.createSQLQuery(sql);
3112    
3113                    q.setFirstResult(0);
3114                    q.setMaxResults(2);
3115    
3116                    if (getDB().isSupportsInlineDistinct()) {
3117                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3118                    }
3119                    else {
3120                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
3121                    }
3122    
3123                    QueryPos qPos = QueryPos.getInstance(q);
3124    
3125                    qPos.add(groupId);
3126    
3127                    qPos.add(userId);
3128    
3129                    if (orderByComparator != null) {
3130                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3131    
3132                            for (Object value : values) {
3133                                    qPos.add(value);
3134                            }
3135                    }
3136    
3137                    List<DLFileEntry> list = q.list();
3138    
3139                    if (list.size() == 2) {
3140                            return list.get(1);
3141                    }
3142                    else {
3143                            return null;
3144                    }
3145            }
3146    
3147            /**
3148             * Returns all the document library file entries where groupId = &#63; and folderId = &#63;.
3149             *
3150             * @param groupId the group ID
3151             * @param folderId the folder ID
3152             * @return the matching document library file entries
3153             * @throws SystemException if a system exception occurred
3154             */
3155            public List<DLFileEntry> findByG_F(long groupId, long folderId)
3156                    throws SystemException {
3157                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
3158                            QueryUtil.ALL_POS, null);
3159            }
3160    
3161            /**
3162             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63;.
3163             *
3164             * <p>
3165             * 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.
3166             * </p>
3167             *
3168             * @param groupId the group ID
3169             * @param folderId the folder ID
3170             * @param start the lower bound of the range of document library file entries
3171             * @param end the upper bound of the range of document library file entries (not inclusive)
3172             * @return the range of matching document library file entries
3173             * @throws SystemException if a system exception occurred
3174             */
3175            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
3176                    int end) throws SystemException {
3177                    return findByG_F(groupId, folderId, start, end, null);
3178            }
3179    
3180            /**
3181             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63;.
3182             *
3183             * <p>
3184             * 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.
3185             * </p>
3186             *
3187             * @param groupId the group ID
3188             * @param folderId the folder ID
3189             * @param start the lower bound of the range of document library file entries
3190             * @param end the upper bound of the range of document library file entries (not inclusive)
3191             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3192             * @return the ordered range of matching document library file entries
3193             * @throws SystemException if a system exception occurred
3194             */
3195            public List<DLFileEntry> findByG_F(long groupId, long folderId, int start,
3196                    int end, OrderByComparator orderByComparator) throws SystemException {
3197                    FinderPath finderPath = null;
3198                    Object[] finderArgs = null;
3199    
3200                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3201                                    (orderByComparator == null)) {
3202                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
3203                            finderArgs = new Object[] { groupId, folderId };
3204                    }
3205                    else {
3206                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
3207                            finderArgs = new Object[] {
3208                                            groupId, folderId,
3209                                            
3210                                            start, end, orderByComparator
3211                                    };
3212                    }
3213    
3214                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
3215                                    finderArgs, this);
3216    
3217                    if (list == null) {
3218                            StringBundler query = null;
3219    
3220                            if (orderByComparator != null) {
3221                                    query = new StringBundler(4 +
3222                                                    (orderByComparator.getOrderByFields().length * 3));
3223                            }
3224                            else {
3225                                    query = new StringBundler(4);
3226                            }
3227    
3228                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3229    
3230                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3231    
3232                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3233    
3234                            if (orderByComparator != null) {
3235                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3236                                            orderByComparator);
3237                            }
3238    
3239                            else {
3240                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3241                            }
3242    
3243                            String sql = query.toString();
3244    
3245                            Session session = null;
3246    
3247                            try {
3248                                    session = openSession();
3249    
3250                                    Query q = session.createQuery(sql);
3251    
3252                                    QueryPos qPos = QueryPos.getInstance(q);
3253    
3254                                    qPos.add(groupId);
3255    
3256                                    qPos.add(folderId);
3257    
3258                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3259                                                    start, end);
3260                            }
3261                            catch (Exception e) {
3262                                    throw processException(e);
3263                            }
3264                            finally {
3265                                    if (list == null) {
3266                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3267                                    }
3268                                    else {
3269                                            cacheResult(list);
3270    
3271                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3272                                    }
3273    
3274                                    closeSession(session);
3275                            }
3276                    }
3277    
3278                    return list;
3279            }
3280    
3281            /**
3282             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
3283             *
3284             * <p>
3285             * 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.
3286             * </p>
3287             *
3288             * @param groupId the group ID
3289             * @param folderId the folder ID
3290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3291             * @return the first matching document library file entry
3292             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
3293             * @throws SystemException if a system exception occurred
3294             */
3295            public DLFileEntry findByG_F_First(long groupId, long folderId,
3296                    OrderByComparator orderByComparator)
3297                    throws NoSuchFileEntryException, SystemException {
3298                    List<DLFileEntry> list = findByG_F(groupId, folderId, 0, 1,
3299                                    orderByComparator);
3300    
3301                    if (list.isEmpty()) {
3302                            StringBundler msg = new StringBundler(6);
3303    
3304                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3305    
3306                            msg.append("groupId=");
3307                            msg.append(groupId);
3308    
3309                            msg.append(", folderId=");
3310                            msg.append(folderId);
3311    
3312                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3313    
3314                            throw new NoSuchFileEntryException(msg.toString());
3315                    }
3316                    else {
3317                            return list.get(0);
3318                    }
3319            }
3320    
3321            /**
3322             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
3323             *
3324             * <p>
3325             * 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.
3326             * </p>
3327             *
3328             * @param groupId the group ID
3329             * @param folderId the folder ID
3330             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3331             * @return the last matching document library file entry
3332             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
3333             * @throws SystemException if a system exception occurred
3334             */
3335            public DLFileEntry findByG_F_Last(long groupId, long folderId,
3336                    OrderByComparator orderByComparator)
3337                    throws NoSuchFileEntryException, SystemException {
3338                    int count = countByG_F(groupId, folderId);
3339    
3340                    List<DLFileEntry> list = findByG_F(groupId, folderId, count - 1, count,
3341                                    orderByComparator);
3342    
3343                    if (list.isEmpty()) {
3344                            StringBundler msg = new StringBundler(6);
3345    
3346                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3347    
3348                            msg.append("groupId=");
3349                            msg.append(groupId);
3350    
3351                            msg.append(", folderId=");
3352                            msg.append(folderId);
3353    
3354                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3355    
3356                            throw new NoSuchFileEntryException(msg.toString());
3357                    }
3358                    else {
3359                            return list.get(0);
3360                    }
3361            }
3362    
3363            /**
3364             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63; and folderId = &#63;.
3365             *
3366             * <p>
3367             * 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.
3368             * </p>
3369             *
3370             * @param fileEntryId the primary key of the current document library file entry
3371             * @param groupId the group ID
3372             * @param folderId the folder ID
3373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3374             * @return the previous, current, and next document library file entry
3375             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
3376             * @throws SystemException if a system exception occurred
3377             */
3378            public DLFileEntry[] findByG_F_PrevAndNext(long fileEntryId, long groupId,
3379                    long folderId, OrderByComparator orderByComparator)
3380                    throws NoSuchFileEntryException, SystemException {
3381                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3382    
3383                    Session session = null;
3384    
3385                    try {
3386                            session = openSession();
3387    
3388                            DLFileEntry[] array = new DLFileEntryImpl[3];
3389    
3390                            array[0] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
3391                                            folderId, orderByComparator, true);
3392    
3393                            array[1] = dlFileEntry;
3394    
3395                            array[2] = getByG_F_PrevAndNext(session, dlFileEntry, groupId,
3396                                            folderId, orderByComparator, false);
3397    
3398                            return array;
3399                    }
3400                    catch (Exception e) {
3401                            throw processException(e);
3402                    }
3403                    finally {
3404                            closeSession(session);
3405                    }
3406            }
3407    
3408            protected DLFileEntry getByG_F_PrevAndNext(Session session,
3409                    DLFileEntry dlFileEntry, long groupId, long folderId,
3410                    OrderByComparator orderByComparator, boolean previous) {
3411                    StringBundler query = null;
3412    
3413                    if (orderByComparator != null) {
3414                            query = new StringBundler(6 +
3415                                            (orderByComparator.getOrderByFields().length * 6));
3416                    }
3417                    else {
3418                            query = new StringBundler(3);
3419                    }
3420    
3421                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3422    
3423                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3424    
3425                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3426    
3427                    if (orderByComparator != null) {
3428                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3429    
3430                            if (orderByConditionFields.length > 0) {
3431                                    query.append(WHERE_AND);
3432                            }
3433    
3434                            for (int i = 0; i < orderByConditionFields.length; i++) {
3435                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3436                                    query.append(orderByConditionFields[i]);
3437    
3438                                    if ((i + 1) < orderByConditionFields.length) {
3439                                            if (orderByComparator.isAscending() ^ previous) {
3440                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3441                                            }
3442                                            else {
3443                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3444                                            }
3445                                    }
3446                                    else {
3447                                            if (orderByComparator.isAscending() ^ previous) {
3448                                                    query.append(WHERE_GREATER_THAN);
3449                                            }
3450                                            else {
3451                                                    query.append(WHERE_LESSER_THAN);
3452                                            }
3453                                    }
3454                            }
3455    
3456                            query.append(ORDER_BY_CLAUSE);
3457    
3458                            String[] orderByFields = orderByComparator.getOrderByFields();
3459    
3460                            for (int i = 0; i < orderByFields.length; i++) {
3461                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3462                                    query.append(orderByFields[i]);
3463    
3464                                    if ((i + 1) < orderByFields.length) {
3465                                            if (orderByComparator.isAscending() ^ previous) {
3466                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3467                                            }
3468                                            else {
3469                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3470                                            }
3471                                    }
3472                                    else {
3473                                            if (orderByComparator.isAscending() ^ previous) {
3474                                                    query.append(ORDER_BY_ASC);
3475                                            }
3476                                            else {
3477                                                    query.append(ORDER_BY_DESC);
3478                                            }
3479                                    }
3480                            }
3481                    }
3482    
3483                    else {
3484                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3485                    }
3486    
3487                    String sql = query.toString();
3488    
3489                    Query q = session.createQuery(sql);
3490    
3491                    q.setFirstResult(0);
3492                    q.setMaxResults(2);
3493    
3494                    QueryPos qPos = QueryPos.getInstance(q);
3495    
3496                    qPos.add(groupId);
3497    
3498                    qPos.add(folderId);
3499    
3500                    if (orderByComparator != null) {
3501                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3502    
3503                            for (Object value : values) {
3504                                    qPos.add(value);
3505                            }
3506                    }
3507    
3508                    List<DLFileEntry> list = q.list();
3509    
3510                    if (list.size() == 2) {
3511                            return list.get(1);
3512                    }
3513                    else {
3514                            return null;
3515                    }
3516            }
3517    
3518            /**
3519             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63;.
3520             *
3521             * <p>
3522             * 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.
3523             * </p>
3524             *
3525             * @param groupId the group ID
3526             * @param folderIds the folder IDs
3527             * @return the matching document library file entries
3528             * @throws SystemException if a system exception occurred
3529             */
3530            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds)
3531                    throws SystemException {
3532                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3533                            QueryUtil.ALL_POS, null);
3534            }
3535    
3536            /**
3537             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63;.
3538             *
3539             * <p>
3540             * 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.
3541             * </p>
3542             *
3543             * @param groupId the group ID
3544             * @param folderIds the folder IDs
3545             * @param start the lower bound of the range of document library file entries
3546             * @param end the upper bound of the range of document library file entries (not inclusive)
3547             * @return the range of matching document library file entries
3548             * @throws SystemException if a system exception occurred
3549             */
3550            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
3551                    int start, int end) throws SystemException {
3552                    return findByG_F(groupId, folderIds, start, end, null);
3553            }
3554    
3555            /**
3556             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63;.
3557             *
3558             * <p>
3559             * 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.
3560             * </p>
3561             *
3562             * @param groupId the group ID
3563             * @param folderIds the folder IDs
3564             * @param start the lower bound of the range of document library file entries
3565             * @param end the upper bound of the range of document library file entries (not inclusive)
3566             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3567             * @return the ordered range of matching document library file entries
3568             * @throws SystemException if a system exception occurred
3569             */
3570            public List<DLFileEntry> findByG_F(long groupId, long[] folderIds,
3571                    int start, int end, OrderByComparator orderByComparator)
3572                    throws SystemException {
3573                    FinderPath finderPath = null;
3574                    Object[] finderArgs = null;
3575    
3576                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3577                                    (orderByComparator == null)) {
3578                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
3579                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
3580                    }
3581                    else {
3582                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
3583                            finderArgs = new Object[] {
3584                                            groupId, StringUtil.merge(folderIds),
3585                                            
3586                                            start, end, orderByComparator
3587                                    };
3588                    }
3589    
3590                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
3591                                    finderArgs, this);
3592    
3593                    if (list == null) {
3594                            StringBundler query = new StringBundler();
3595    
3596                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
3597    
3598                            boolean conjunctionable = false;
3599    
3600                            if (conjunctionable) {
3601                                    query.append(WHERE_AND);
3602                            }
3603    
3604                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3605    
3606                            conjunctionable = true;
3607    
3608                            if ((folderIds == null) || (folderIds.length > 0)) {
3609                                    if (conjunctionable) {
3610                                            query.append(WHERE_AND);
3611                                    }
3612    
3613                                    query.append(StringPool.OPEN_PARENTHESIS);
3614    
3615                                    for (int i = 0; i < folderIds.length; i++) {
3616                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3617    
3618                                            if ((i + 1) < folderIds.length) {
3619                                                    query.append(WHERE_OR);
3620                                            }
3621                                    }
3622    
3623                                    query.append(StringPool.CLOSE_PARENTHESIS);
3624    
3625                                    conjunctionable = true;
3626                            }
3627    
3628                            if (orderByComparator != null) {
3629                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3630                                            orderByComparator);
3631                            }
3632    
3633                            else {
3634                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3635                            }
3636    
3637                            String sql = query.toString();
3638    
3639                            Session session = null;
3640    
3641                            try {
3642                                    session = openSession();
3643    
3644                                    Query q = session.createQuery(sql);
3645    
3646                                    QueryPos qPos = QueryPos.getInstance(q);
3647    
3648                                    qPos.add(groupId);
3649    
3650                                    if (folderIds != null) {
3651                                            qPos.add(folderIds);
3652                                    }
3653    
3654                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
3655                                                    start, end);
3656                            }
3657                            catch (Exception e) {
3658                                    throw processException(e);
3659                            }
3660                            finally {
3661                                    if (list == null) {
3662                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3663                                    }
3664                                    else {
3665                                            cacheResult(list);
3666    
3667                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3668                                    }
3669    
3670                                    closeSession(session);
3671                            }
3672                    }
3673    
3674                    return list;
3675            }
3676    
3677            /**
3678             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3679             *
3680             * @param groupId the group ID
3681             * @param folderId the folder ID
3682             * @return the matching document library file entries that the user has permission to view
3683             * @throws SystemException if a system exception occurred
3684             */
3685            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId)
3686                    throws SystemException {
3687                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
3688                            QueryUtil.ALL_POS, null);
3689            }
3690    
3691            /**
3692             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3693             *
3694             * <p>
3695             * 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.
3696             * </p>
3697             *
3698             * @param groupId the group ID
3699             * @param folderId the folder ID
3700             * @param start the lower bound of the range of document library file entries
3701             * @param end the upper bound of the range of document library file entries (not inclusive)
3702             * @return the range of matching document library file entries that the user has permission to view
3703             * @throws SystemException if a system exception occurred
3704             */
3705            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
3706                    int start, int end) throws SystemException {
3707                    return filterFindByG_F(groupId, folderId, start, end, null);
3708            }
3709    
3710            /**
3711             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and folderId = &#63;.
3712             *
3713             * <p>
3714             * 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.
3715             * </p>
3716             *
3717             * @param groupId the group ID
3718             * @param folderId the folder ID
3719             * @param start the lower bound of the range of document library file entries
3720             * @param end the upper bound of the range of document library file entries (not inclusive)
3721             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3722             * @return the ordered range of matching document library file entries that the user has permission to view
3723             * @throws SystemException if a system exception occurred
3724             */
3725            public List<DLFileEntry> filterFindByG_F(long groupId, long folderId,
3726                    int start, int end, OrderByComparator orderByComparator)
3727                    throws SystemException {
3728                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3729                            return findByG_F(groupId, folderId, start, end, orderByComparator);
3730                    }
3731    
3732                    StringBundler query = null;
3733    
3734                    if (orderByComparator != null) {
3735                            query = new StringBundler(4 +
3736                                            (orderByComparator.getOrderByFields().length * 3));
3737                    }
3738                    else {
3739                            query = new StringBundler(4);
3740                    }
3741    
3742                    if (getDB().isSupportsInlineDistinct()) {
3743                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3744                    }
3745                    else {
3746                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
3747                    }
3748    
3749                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3750    
3751                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3752    
3753                    if (!getDB().isSupportsInlineDistinct()) {
3754                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
3755                    }
3756    
3757                    if (orderByComparator != null) {
3758                            if (getDB().isSupportsInlineDistinct()) {
3759                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3760                                            orderByComparator);
3761                            }
3762                            else {
3763                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3764                                            orderByComparator);
3765                            }
3766                    }
3767    
3768                    else {
3769                            if (getDB().isSupportsInlineDistinct()) {
3770                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3771                            }
3772                            else {
3773                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
3774                            }
3775                    }
3776    
3777                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3778                                    DLFileEntry.class.getName(),
3779                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3780    
3781                    Session session = null;
3782    
3783                    try {
3784                            session = openSession();
3785    
3786                            SQLQuery q = session.createSQLQuery(sql);
3787    
3788                            if (getDB().isSupportsInlineDistinct()) {
3789                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3790                            }
3791                            else {
3792                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
3793                            }
3794    
3795                            QueryPos qPos = QueryPos.getInstance(q);
3796    
3797                            qPos.add(groupId);
3798    
3799                            qPos.add(folderId);
3800    
3801                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
3802                    }
3803                    catch (Exception e) {
3804                            throw processException(e);
3805                    }
3806                    finally {
3807                            closeSession(session);
3808                    }
3809            }
3810    
3811            /**
3812             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3813             *
3814             * @param fileEntryId the primary key of the current document library file entry
3815             * @param groupId the group ID
3816             * @param folderId the folder ID
3817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3818             * @return the previous, current, and next document library file entry
3819             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
3820             * @throws SystemException if a system exception occurred
3821             */
3822            public DLFileEntry[] filterFindByG_F_PrevAndNext(long fileEntryId,
3823                    long groupId, long folderId, OrderByComparator orderByComparator)
3824                    throws NoSuchFileEntryException, SystemException {
3825                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3826                            return findByG_F_PrevAndNext(fileEntryId, groupId, folderId,
3827                                    orderByComparator);
3828                    }
3829    
3830                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
3831    
3832                    Session session = null;
3833    
3834                    try {
3835                            session = openSession();
3836    
3837                            DLFileEntry[] array = new DLFileEntryImpl[3];
3838    
3839                            array[0] = filterGetByG_F_PrevAndNext(session, dlFileEntry,
3840                                            groupId, folderId, orderByComparator, true);
3841    
3842                            array[1] = dlFileEntry;
3843    
3844                            array[2] = filterGetByG_F_PrevAndNext(session, dlFileEntry,
3845                                            groupId, folderId, orderByComparator, false);
3846    
3847                            return array;
3848                    }
3849                    catch (Exception e) {
3850                            throw processException(e);
3851                    }
3852                    finally {
3853                            closeSession(session);
3854                    }
3855            }
3856    
3857            protected DLFileEntry filterGetByG_F_PrevAndNext(Session session,
3858                    DLFileEntry dlFileEntry, long groupId, long folderId,
3859                    OrderByComparator orderByComparator, boolean previous) {
3860                    StringBundler query = null;
3861    
3862                    if (orderByComparator != null) {
3863                            query = new StringBundler(6 +
3864                                            (orderByComparator.getOrderByFields().length * 6));
3865                    }
3866                    else {
3867                            query = new StringBundler(3);
3868                    }
3869    
3870                    if (getDB().isSupportsInlineDistinct()) {
3871                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
3872                    }
3873                    else {
3874                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
3875                    }
3876    
3877                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3878    
3879                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3880    
3881                    if (!getDB().isSupportsInlineDistinct()) {
3882                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
3883                    }
3884    
3885                    if (orderByComparator != null) {
3886                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3887    
3888                            if (orderByConditionFields.length > 0) {
3889                                    query.append(WHERE_AND);
3890                            }
3891    
3892                            for (int i = 0; i < orderByConditionFields.length; i++) {
3893                                    if (getDB().isSupportsInlineDistinct()) {
3894                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3895                                    }
3896                                    else {
3897                                            query.append(_ORDER_BY_ENTITY_TABLE);
3898                                    }
3899    
3900                                    query.append(orderByConditionFields[i]);
3901    
3902                                    if ((i + 1) < orderByConditionFields.length) {
3903                                            if (orderByComparator.isAscending() ^ previous) {
3904                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3905                                            }
3906                                            else {
3907                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3908                                            }
3909                                    }
3910                                    else {
3911                                            if (orderByComparator.isAscending() ^ previous) {
3912                                                    query.append(WHERE_GREATER_THAN);
3913                                            }
3914                                            else {
3915                                                    query.append(WHERE_LESSER_THAN);
3916                                            }
3917                                    }
3918                            }
3919    
3920                            query.append(ORDER_BY_CLAUSE);
3921    
3922                            String[] orderByFields = orderByComparator.getOrderByFields();
3923    
3924                            for (int i = 0; i < orderByFields.length; i++) {
3925                                    if (getDB().isSupportsInlineDistinct()) {
3926                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3927                                    }
3928                                    else {
3929                                            query.append(_ORDER_BY_ENTITY_TABLE);
3930                                    }
3931    
3932                                    query.append(orderByFields[i]);
3933    
3934                                    if ((i + 1) < orderByFields.length) {
3935                                            if (orderByComparator.isAscending() ^ previous) {
3936                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3937                                            }
3938                                            else {
3939                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3940                                            }
3941                                    }
3942                                    else {
3943                                            if (orderByComparator.isAscending() ^ previous) {
3944                                                    query.append(ORDER_BY_ASC);
3945                                            }
3946                                            else {
3947                                                    query.append(ORDER_BY_DESC);
3948                                            }
3949                                    }
3950                            }
3951                    }
3952    
3953                    else {
3954                            if (getDB().isSupportsInlineDistinct()) {
3955                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
3956                            }
3957                            else {
3958                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
3959                            }
3960                    }
3961    
3962                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3963                                    DLFileEntry.class.getName(),
3964                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3965    
3966                    SQLQuery q = session.createSQLQuery(sql);
3967    
3968                    q.setFirstResult(0);
3969                    q.setMaxResults(2);
3970    
3971                    if (getDB().isSupportsInlineDistinct()) {
3972                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
3973                    }
3974                    else {
3975                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
3976                    }
3977    
3978                    QueryPos qPos = QueryPos.getInstance(q);
3979    
3980                    qPos.add(groupId);
3981    
3982                    qPos.add(folderId);
3983    
3984                    if (orderByComparator != null) {
3985                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
3986    
3987                            for (Object value : values) {
3988                                    qPos.add(value);
3989                            }
3990                    }
3991    
3992                    List<DLFileEntry> list = q.list();
3993    
3994                    if (list.size() == 2) {
3995                            return list.get(1);
3996                    }
3997                    else {
3998                            return null;
3999                    }
4000            }
4001    
4002            /**
4003             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
4004             *
4005             * @param groupId the group ID
4006             * @param folderIds the folder IDs
4007             * @return the matching document library file entries that the user has permission to view
4008             * @throws SystemException if a system exception occurred
4009             */
4010            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds)
4011                    throws SystemException {
4012                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
4013                            QueryUtil.ALL_POS, null);
4014            }
4015    
4016            /**
4017             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
4018             *
4019             * <p>
4020             * 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.
4021             * </p>
4022             *
4023             * @param groupId the group ID
4024             * @param folderIds the folder IDs
4025             * @param start the lower bound of the range of document library file entries
4026             * @param end the upper bound of the range of document library file entries (not inclusive)
4027             * @return the range of matching document library file entries that the user has permission to view
4028             * @throws SystemException if a system exception occurred
4029             */
4030            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
4031                    int start, int end) throws SystemException {
4032                    return filterFindByG_F(groupId, folderIds, start, end, null);
4033            }
4034    
4035            /**
4036             * Returns an ordered range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
4037             *
4038             * <p>
4039             * 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.
4040             * </p>
4041             *
4042             * @param groupId the group ID
4043             * @param folderIds the folder IDs
4044             * @param start the lower bound of the range of document library file entries
4045             * @param end the upper bound of the range of document library file entries (not inclusive)
4046             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4047             * @return the ordered range of matching document library file entries that the user has permission to view
4048             * @throws SystemException if a system exception occurred
4049             */
4050            public List<DLFileEntry> filterFindByG_F(long groupId, long[] folderIds,
4051                    int start, int end, OrderByComparator orderByComparator)
4052                    throws SystemException {
4053                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4054                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
4055                    }
4056    
4057                    StringBundler query = new StringBundler();
4058    
4059                    if (getDB().isSupportsInlineDistinct()) {
4060                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4061                    }
4062                    else {
4063                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4064                    }
4065    
4066                    boolean conjunctionable = false;
4067    
4068                    if (conjunctionable) {
4069                            query.append(WHERE_AND);
4070                    }
4071    
4072                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
4073    
4074                    conjunctionable = true;
4075    
4076                    if ((folderIds == null) || (folderIds.length > 0)) {
4077                            if (conjunctionable) {
4078                                    query.append(WHERE_AND);
4079                            }
4080    
4081                            query.append(StringPool.OPEN_PARENTHESIS);
4082    
4083                            for (int i = 0; i < folderIds.length; i++) {
4084                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
4085    
4086                                    if ((i + 1) < folderIds.length) {
4087                                            query.append(WHERE_OR);
4088                                    }
4089                            }
4090    
4091                            query.append(StringPool.CLOSE_PARENTHESIS);
4092    
4093                            conjunctionable = true;
4094                    }
4095    
4096                    if (!getDB().isSupportsInlineDistinct()) {
4097                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4098                    }
4099    
4100                    if (orderByComparator != null) {
4101                            if (getDB().isSupportsInlineDistinct()) {
4102                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4103                                            orderByComparator);
4104                            }
4105                            else {
4106                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4107                                            orderByComparator);
4108                            }
4109                    }
4110    
4111                    else {
4112                            if (getDB().isSupportsInlineDistinct()) {
4113                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4114                            }
4115                            else {
4116                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
4117                            }
4118                    }
4119    
4120                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4121                                    DLFileEntry.class.getName(),
4122                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4123    
4124                    Session session = null;
4125    
4126                    try {
4127                            session = openSession();
4128    
4129                            SQLQuery q = session.createSQLQuery(sql);
4130    
4131                            if (getDB().isSupportsInlineDistinct()) {
4132                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
4133                            }
4134                            else {
4135                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
4136                            }
4137    
4138                            QueryPos qPos = QueryPos.getInstance(q);
4139    
4140                            qPos.add(groupId);
4141    
4142                            if (folderIds != null) {
4143                                    qPos.add(folderIds);
4144                            }
4145    
4146                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
4147                    }
4148                    catch (Exception e) {
4149                            throw processException(e);
4150                    }
4151                    finally {
4152                            closeSession(session);
4153                    }
4154            }
4155    
4156            /**
4157             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
4158             *
4159             * @param groupId the group ID
4160             * @param userId the user ID
4161             * @param folderId the folder ID
4162             * @return the matching document library file entries
4163             * @throws SystemException if a system exception occurred
4164             */
4165            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4166                    long folderId) throws SystemException {
4167                    return findByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
4168                            QueryUtil.ALL_POS, null);
4169            }
4170    
4171            /**
4172             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
4173             *
4174             * <p>
4175             * 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.
4176             * </p>
4177             *
4178             * @param groupId the group ID
4179             * @param userId the user ID
4180             * @param folderId the folder ID
4181             * @param start the lower bound of the range of document library file entries
4182             * @param end the upper bound of the range of document library file entries (not inclusive)
4183             * @return the range of matching document library file entries
4184             * @throws SystemException if a system exception occurred
4185             */
4186            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4187                    long folderId, int start, int end) throws SystemException {
4188                    return findByG_U_F(groupId, userId, folderId, start, end, null);
4189            }
4190    
4191            /**
4192             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
4193             *
4194             * <p>
4195             * 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.
4196             * </p>
4197             *
4198             * @param groupId the group ID
4199             * @param userId the user ID
4200             * @param folderId the folder ID
4201             * @param start the lower bound of the range of document library file entries
4202             * @param end the upper bound of the range of document library file entries (not inclusive)
4203             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4204             * @return the ordered range of matching document library file entries
4205             * @throws SystemException if a system exception occurred
4206             */
4207            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4208                    long folderId, int start, int end, OrderByComparator orderByComparator)
4209                    throws SystemException {
4210                    FinderPath finderPath = null;
4211                    Object[] finderArgs = null;
4212    
4213                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4214                                    (orderByComparator == null)) {
4215                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F;
4216                            finderArgs = new Object[] { groupId, userId, folderId };
4217                    }
4218                    else {
4219                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
4220                            finderArgs = new Object[] {
4221                                            groupId, userId, folderId,
4222                                            
4223                                            start, end, orderByComparator
4224                                    };
4225                    }
4226    
4227                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
4228                                    finderArgs, this);
4229    
4230                    if (list == null) {
4231                            StringBundler query = null;
4232    
4233                            if (orderByComparator != null) {
4234                                    query = new StringBundler(5 +
4235                                                    (orderByComparator.getOrderByFields().length * 3));
4236                            }
4237                            else {
4238                                    query = new StringBundler(5);
4239                            }
4240    
4241                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4242    
4243                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
4244    
4245                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
4246    
4247                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
4248    
4249                            if (orderByComparator != null) {
4250                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4251                                            orderByComparator);
4252                            }
4253    
4254                            else {
4255                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4256                            }
4257    
4258                            String sql = query.toString();
4259    
4260                            Session session = null;
4261    
4262                            try {
4263                                    session = openSession();
4264    
4265                                    Query q = session.createQuery(sql);
4266    
4267                                    QueryPos qPos = QueryPos.getInstance(q);
4268    
4269                                    qPos.add(groupId);
4270    
4271                                    qPos.add(userId);
4272    
4273                                    qPos.add(folderId);
4274    
4275                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4276                                                    start, end);
4277                            }
4278                            catch (Exception e) {
4279                                    throw processException(e);
4280                            }
4281                            finally {
4282                                    if (list == null) {
4283                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4284                                    }
4285                                    else {
4286                                            cacheResult(list);
4287    
4288                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4289                                    }
4290    
4291                                    closeSession(session);
4292                            }
4293                    }
4294    
4295                    return list;
4296            }
4297    
4298            /**
4299             * Returns the first document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
4300             *
4301             * <p>
4302             * 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.
4303             * </p>
4304             *
4305             * @param groupId the group ID
4306             * @param userId the user ID
4307             * @param folderId the folder ID
4308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4309             * @return the first matching document library file entry
4310             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
4311             * @throws SystemException if a system exception occurred
4312             */
4313            public DLFileEntry findByG_U_F_First(long groupId, long userId,
4314                    long folderId, OrderByComparator orderByComparator)
4315                    throws NoSuchFileEntryException, SystemException {
4316                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId, 0, 1,
4317                                    orderByComparator);
4318    
4319                    if (list.isEmpty()) {
4320                            StringBundler msg = new StringBundler(8);
4321    
4322                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4323    
4324                            msg.append("groupId=");
4325                            msg.append(groupId);
4326    
4327                            msg.append(", userId=");
4328                            msg.append(userId);
4329    
4330                            msg.append(", folderId=");
4331                            msg.append(folderId);
4332    
4333                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4334    
4335                            throw new NoSuchFileEntryException(msg.toString());
4336                    }
4337                    else {
4338                            return list.get(0);
4339                    }
4340            }
4341    
4342            /**
4343             * Returns the last document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
4344             *
4345             * <p>
4346             * 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.
4347             * </p>
4348             *
4349             * @param groupId the group ID
4350             * @param userId the user ID
4351             * @param folderId the folder ID
4352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4353             * @return the last matching document library file entry
4354             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
4355             * @throws SystemException if a system exception occurred
4356             */
4357            public DLFileEntry findByG_U_F_Last(long groupId, long userId,
4358                    long folderId, OrderByComparator orderByComparator)
4359                    throws NoSuchFileEntryException, SystemException {
4360                    int count = countByG_U_F(groupId, userId, folderId);
4361    
4362                    List<DLFileEntry> list = findByG_U_F(groupId, userId, folderId,
4363                                    count - 1, count, orderByComparator);
4364    
4365                    if (list.isEmpty()) {
4366                            StringBundler msg = new StringBundler(8);
4367    
4368                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4369    
4370                            msg.append("groupId=");
4371                            msg.append(groupId);
4372    
4373                            msg.append(", userId=");
4374                            msg.append(userId);
4375    
4376                            msg.append(", folderId=");
4377                            msg.append(folderId);
4378    
4379                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4380    
4381                            throw new NoSuchFileEntryException(msg.toString());
4382                    }
4383                    else {
4384                            return list.get(0);
4385                    }
4386            }
4387    
4388            /**
4389             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63;.
4390             *
4391             * <p>
4392             * 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.
4393             * </p>
4394             *
4395             * @param fileEntryId the primary key of the current document library file entry
4396             * @param groupId the group ID
4397             * @param userId the user ID
4398             * @param folderId the folder ID
4399             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4400             * @return the previous, current, and next document library file entry
4401             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
4402             * @throws SystemException if a system exception occurred
4403             */
4404            public DLFileEntry[] findByG_U_F_PrevAndNext(long fileEntryId,
4405                    long groupId, long userId, long folderId,
4406                    OrderByComparator orderByComparator)
4407                    throws NoSuchFileEntryException, SystemException {
4408                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4409    
4410                    Session session = null;
4411    
4412                    try {
4413                            session = openSession();
4414    
4415                            DLFileEntry[] array = new DLFileEntryImpl[3];
4416    
4417                            array[0] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
4418                                            userId, folderId, orderByComparator, true);
4419    
4420                            array[1] = dlFileEntry;
4421    
4422                            array[2] = getByG_U_F_PrevAndNext(session, dlFileEntry, groupId,
4423                                            userId, folderId, orderByComparator, false);
4424    
4425                            return array;
4426                    }
4427                    catch (Exception e) {
4428                            throw processException(e);
4429                    }
4430                    finally {
4431                            closeSession(session);
4432                    }
4433            }
4434    
4435            protected DLFileEntry getByG_U_F_PrevAndNext(Session session,
4436                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
4437                    OrderByComparator orderByComparator, boolean previous) {
4438                    StringBundler query = null;
4439    
4440                    if (orderByComparator != null) {
4441                            query = new StringBundler(6 +
4442                                            (orderByComparator.getOrderByFields().length * 6));
4443                    }
4444                    else {
4445                            query = new StringBundler(3);
4446                    }
4447    
4448                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4449    
4450                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
4451    
4452                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
4453    
4454                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
4455    
4456                    if (orderByComparator != null) {
4457                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4458    
4459                            if (orderByConditionFields.length > 0) {
4460                                    query.append(WHERE_AND);
4461                            }
4462    
4463                            for (int i = 0; i < orderByConditionFields.length; i++) {
4464                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4465                                    query.append(orderByConditionFields[i]);
4466    
4467                                    if ((i + 1) < orderByConditionFields.length) {
4468                                            if (orderByComparator.isAscending() ^ previous) {
4469                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4470                                            }
4471                                            else {
4472                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4473                                            }
4474                                    }
4475                                    else {
4476                                            if (orderByComparator.isAscending() ^ previous) {
4477                                                    query.append(WHERE_GREATER_THAN);
4478                                            }
4479                                            else {
4480                                                    query.append(WHERE_LESSER_THAN);
4481                                            }
4482                                    }
4483                            }
4484    
4485                            query.append(ORDER_BY_CLAUSE);
4486    
4487                            String[] orderByFields = orderByComparator.getOrderByFields();
4488    
4489                            for (int i = 0; i < orderByFields.length; i++) {
4490                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4491                                    query.append(orderByFields[i]);
4492    
4493                                    if ((i + 1) < orderByFields.length) {
4494                                            if (orderByComparator.isAscending() ^ previous) {
4495                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4496                                            }
4497                                            else {
4498                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4499                                            }
4500                                    }
4501                                    else {
4502                                            if (orderByComparator.isAscending() ^ previous) {
4503                                                    query.append(ORDER_BY_ASC);
4504                                            }
4505                                            else {
4506                                                    query.append(ORDER_BY_DESC);
4507                                            }
4508                                    }
4509                            }
4510                    }
4511    
4512                    else {
4513                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4514                    }
4515    
4516                    String sql = query.toString();
4517    
4518                    Query q = session.createQuery(sql);
4519    
4520                    q.setFirstResult(0);
4521                    q.setMaxResults(2);
4522    
4523                    QueryPos qPos = QueryPos.getInstance(q);
4524    
4525                    qPos.add(groupId);
4526    
4527                    qPos.add(userId);
4528    
4529                    qPos.add(folderId);
4530    
4531                    if (orderByComparator != null) {
4532                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
4533    
4534                            for (Object value : values) {
4535                                    qPos.add(value);
4536                            }
4537                    }
4538    
4539                    List<DLFileEntry> list = q.list();
4540    
4541                    if (list.size() == 2) {
4542                            return list.get(1);
4543                    }
4544                    else {
4545                            return null;
4546                    }
4547            }
4548    
4549            /**
4550             * Returns all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
4551             *
4552             * <p>
4553             * 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.
4554             * </p>
4555             *
4556             * @param groupId the group ID
4557             * @param userId the user ID
4558             * @param folderIds the folder IDs
4559             * @return the matching document library file entries
4560             * @throws SystemException if a system exception occurred
4561             */
4562            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4563                    long[] folderIds) throws SystemException {
4564                    return findByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
4565                            QueryUtil.ALL_POS, null);
4566            }
4567    
4568            /**
4569             * Returns a range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
4570             *
4571             * <p>
4572             * 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.
4573             * </p>
4574             *
4575             * @param groupId the group ID
4576             * @param userId the user ID
4577             * @param folderIds the folder IDs
4578             * @param start the lower bound of the range of document library file entries
4579             * @param end the upper bound of the range of document library file entries (not inclusive)
4580             * @return the range of matching document library file entries
4581             * @throws SystemException if a system exception occurred
4582             */
4583            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4584                    long[] folderIds, int start, int end) throws SystemException {
4585                    return findByG_U_F(groupId, userId, folderIds, start, end, null);
4586            }
4587    
4588            /**
4589             * Returns an ordered range of all the document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
4590             *
4591             * <p>
4592             * 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.
4593             * </p>
4594             *
4595             * @param groupId the group ID
4596             * @param userId the user ID
4597             * @param folderIds the folder IDs
4598             * @param start the lower bound of the range of document library file entries
4599             * @param end the upper bound of the range of document library file entries (not inclusive)
4600             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4601             * @return the ordered range of matching document library file entries
4602             * @throws SystemException if a system exception occurred
4603             */
4604            public List<DLFileEntry> findByG_U_F(long groupId, long userId,
4605                    long[] folderIds, int start, int end,
4606                    OrderByComparator orderByComparator) throws SystemException {
4607                    FinderPath finderPath = null;
4608                    Object[] finderArgs = null;
4609    
4610                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4611                                    (orderByComparator == null)) {
4612                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F;
4613                            finderArgs = new Object[] {
4614                                            groupId, userId, StringUtil.merge(folderIds)
4615                                    };
4616                    }
4617                    else {
4618                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
4619                            finderArgs = new Object[] {
4620                                            groupId, userId, StringUtil.merge(folderIds),
4621                                            
4622                                            start, end, orderByComparator
4623                                    };
4624                    }
4625    
4626                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
4627                                    finderArgs, this);
4628    
4629                    if (list == null) {
4630                            StringBundler query = new StringBundler();
4631    
4632                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
4633    
4634                            boolean conjunctionable = false;
4635    
4636                            if (conjunctionable) {
4637                                    query.append(WHERE_AND);
4638                            }
4639    
4640                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
4641    
4642                            conjunctionable = true;
4643    
4644                            if (conjunctionable) {
4645                                    query.append(WHERE_AND);
4646                            }
4647    
4648                            query.append(_FINDER_COLUMN_G_U_F_USERID_5);
4649    
4650                            conjunctionable = true;
4651    
4652                            if ((folderIds == null) || (folderIds.length > 0)) {
4653                                    if (conjunctionable) {
4654                                            query.append(WHERE_AND);
4655                                    }
4656    
4657                                    query.append(StringPool.OPEN_PARENTHESIS);
4658    
4659                                    for (int i = 0; i < folderIds.length; i++) {
4660                                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
4661    
4662                                            if ((i + 1) < folderIds.length) {
4663                                                    query.append(WHERE_OR);
4664                                            }
4665                                    }
4666    
4667                                    query.append(StringPool.CLOSE_PARENTHESIS);
4668    
4669                                    conjunctionable = true;
4670                            }
4671    
4672                            if (orderByComparator != null) {
4673                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4674                                            orderByComparator);
4675                            }
4676    
4677                            else {
4678                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4679                            }
4680    
4681                            String sql = query.toString();
4682    
4683                            Session session = null;
4684    
4685                            try {
4686                                    session = openSession();
4687    
4688                                    Query q = session.createQuery(sql);
4689    
4690                                    QueryPos qPos = QueryPos.getInstance(q);
4691    
4692                                    qPos.add(groupId);
4693    
4694                                    qPos.add(userId);
4695    
4696                                    if (folderIds != null) {
4697                                            qPos.add(folderIds);
4698                                    }
4699    
4700                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
4701                                                    start, end);
4702                            }
4703                            catch (Exception e) {
4704                                    throw processException(e);
4705                            }
4706                            finally {
4707                                    if (list == null) {
4708                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4709                                    }
4710                                    else {
4711                                            cacheResult(list);
4712    
4713                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4714                                    }
4715    
4716                                    closeSession(session);
4717                            }
4718                    }
4719    
4720                    return list;
4721            }
4722    
4723            /**
4724             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
4725             *
4726             * @param groupId the group ID
4727             * @param userId the user ID
4728             * @param folderId the folder ID
4729             * @return the matching document library file entries that the user has permission to view
4730             * @throws SystemException if a system exception occurred
4731             */
4732            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
4733                    long folderId) throws SystemException {
4734                    return filterFindByG_U_F(groupId, userId, folderId, QueryUtil.ALL_POS,
4735                            QueryUtil.ALL_POS, null);
4736            }
4737    
4738            /**
4739             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
4740             *
4741             * <p>
4742             * 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.
4743             * </p>
4744             *
4745             * @param groupId the group ID
4746             * @param userId the user ID
4747             * @param folderId the folder ID
4748             * @param start the lower bound of the range of document library file entries
4749             * @param end the upper bound of the range of document library file entries (not inclusive)
4750             * @return the range of matching document library file entries that the user has permission to view
4751             * @throws SystemException if a system exception occurred
4752             */
4753            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
4754                    long folderId, int start, int end) throws SystemException {
4755                    return filterFindByG_U_F(groupId, userId, folderId, start, end, null);
4756            }
4757    
4758            /**
4759             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
4760             *
4761             * <p>
4762             * 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.
4763             * </p>
4764             *
4765             * @param groupId the group ID
4766             * @param userId the user ID
4767             * @param folderId the folder ID
4768             * @param start the lower bound of the range of document library file entries
4769             * @param end the upper bound of the range of document library file entries (not inclusive)
4770             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4771             * @return the ordered range of matching document library file entries that the user has permission to view
4772             * @throws SystemException if a system exception occurred
4773             */
4774            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
4775                    long folderId, int start, int end, OrderByComparator orderByComparator)
4776                    throws SystemException {
4777                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4778                            return findByG_U_F(groupId, userId, folderId, start, end,
4779                                    orderByComparator);
4780                    }
4781    
4782                    StringBundler query = null;
4783    
4784                    if (orderByComparator != null) {
4785                            query = new StringBundler(5 +
4786                                            (orderByComparator.getOrderByFields().length * 3));
4787                    }
4788                    else {
4789                            query = new StringBundler(5);
4790                    }
4791    
4792                    if (getDB().isSupportsInlineDistinct()) {
4793                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4794                    }
4795                    else {
4796                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4797                    }
4798    
4799                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
4800    
4801                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
4802    
4803                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
4804    
4805                    if (!getDB().isSupportsInlineDistinct()) {
4806                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4807                    }
4808    
4809                    if (orderByComparator != null) {
4810                            if (getDB().isSupportsInlineDistinct()) {
4811                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4812                                            orderByComparator);
4813                            }
4814                            else {
4815                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4816                                            orderByComparator);
4817                            }
4818                    }
4819    
4820                    else {
4821                            if (getDB().isSupportsInlineDistinct()) {
4822                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
4823                            }
4824                            else {
4825                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
4826                            }
4827                    }
4828    
4829                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4830                                    DLFileEntry.class.getName(),
4831                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4832    
4833                    Session session = null;
4834    
4835                    try {
4836                            session = openSession();
4837    
4838                            SQLQuery q = session.createSQLQuery(sql);
4839    
4840                            if (getDB().isSupportsInlineDistinct()) {
4841                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
4842                            }
4843                            else {
4844                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
4845                            }
4846    
4847                            QueryPos qPos = QueryPos.getInstance(q);
4848    
4849                            qPos.add(groupId);
4850    
4851                            qPos.add(userId);
4852    
4853                            qPos.add(folderId);
4854    
4855                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
4856                    }
4857                    catch (Exception e) {
4858                            throw processException(e);
4859                    }
4860                    finally {
4861                            closeSession(session);
4862                    }
4863            }
4864    
4865            /**
4866             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
4867             *
4868             * @param fileEntryId the primary key of the current document library file entry
4869             * @param groupId the group ID
4870             * @param userId the user ID
4871             * @param folderId the folder ID
4872             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4873             * @return the previous, current, and next document library file entry
4874             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
4875             * @throws SystemException if a system exception occurred
4876             */
4877            public DLFileEntry[] filterFindByG_U_F_PrevAndNext(long fileEntryId,
4878                    long groupId, long userId, long folderId,
4879                    OrderByComparator orderByComparator)
4880                    throws NoSuchFileEntryException, SystemException {
4881                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4882                            return findByG_U_F_PrevAndNext(fileEntryId, groupId, userId,
4883                                    folderId, orderByComparator);
4884                    }
4885    
4886                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
4887    
4888                    Session session = null;
4889    
4890                    try {
4891                            session = openSession();
4892    
4893                            DLFileEntry[] array = new DLFileEntryImpl[3];
4894    
4895                            array[0] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
4896                                            groupId, userId, folderId, orderByComparator, true);
4897    
4898                            array[1] = dlFileEntry;
4899    
4900                            array[2] = filterGetByG_U_F_PrevAndNext(session, dlFileEntry,
4901                                            groupId, userId, folderId, orderByComparator, false);
4902    
4903                            return array;
4904                    }
4905                    catch (Exception e) {
4906                            throw processException(e);
4907                    }
4908                    finally {
4909                            closeSession(session);
4910                    }
4911            }
4912    
4913            protected DLFileEntry filterGetByG_U_F_PrevAndNext(Session session,
4914                    DLFileEntry dlFileEntry, long groupId, long userId, long folderId,
4915                    OrderByComparator orderByComparator, boolean previous) {
4916                    StringBundler query = null;
4917    
4918                    if (orderByComparator != null) {
4919                            query = new StringBundler(6 +
4920                                            (orderByComparator.getOrderByFields().length * 6));
4921                    }
4922                    else {
4923                            query = new StringBundler(3);
4924                    }
4925    
4926                    if (getDB().isSupportsInlineDistinct()) {
4927                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
4928                    }
4929                    else {
4930                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
4931                    }
4932    
4933                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
4934    
4935                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
4936    
4937                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
4938    
4939                    if (!getDB().isSupportsInlineDistinct()) {
4940                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
4941                    }
4942    
4943                    if (orderByComparator != null) {
4944                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4945    
4946                            if (orderByConditionFields.length > 0) {
4947                                    query.append(WHERE_AND);
4948                            }
4949    
4950                            for (int i = 0; i < orderByConditionFields.length; i++) {
4951                                    if (getDB().isSupportsInlineDistinct()) {
4952                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4953                                    }
4954                                    else {
4955                                            query.append(_ORDER_BY_ENTITY_TABLE);
4956                                    }
4957    
4958                                    query.append(orderByConditionFields[i]);
4959    
4960                                    if ((i + 1) < orderByConditionFields.length) {
4961                                            if (orderByComparator.isAscending() ^ previous) {
4962                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4963                                            }
4964                                            else {
4965                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4966                                            }
4967                                    }
4968                                    else {
4969                                            if (orderByComparator.isAscending() ^ previous) {
4970                                                    query.append(WHERE_GREATER_THAN);
4971                                            }
4972                                            else {
4973                                                    query.append(WHERE_LESSER_THAN);
4974                                            }
4975                                    }
4976                            }
4977    
4978                            query.append(ORDER_BY_CLAUSE);
4979    
4980                            String[] orderByFields = orderByComparator.getOrderByFields();
4981    
4982                            for (int i = 0; i < orderByFields.length; i++) {
4983                                    if (getDB().isSupportsInlineDistinct()) {
4984                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4985                                    }
4986                                    else {
4987                                            query.append(_ORDER_BY_ENTITY_TABLE);
4988                                    }
4989    
4990                                    query.append(orderByFields[i]);
4991    
4992                                    if ((i + 1) < orderByFields.length) {
4993                                            if (orderByComparator.isAscending() ^ previous) {
4994                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4995                                            }
4996                                            else {
4997                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4998                                            }
4999                                    }
5000                                    else {
5001                                            if (orderByComparator.isAscending() ^ previous) {
5002                                                    query.append(ORDER_BY_ASC);
5003                                            }
5004                                            else {
5005                                                    query.append(ORDER_BY_DESC);
5006                                            }
5007                                    }
5008                            }
5009                    }
5010    
5011                    else {
5012                            if (getDB().isSupportsInlineDistinct()) {
5013                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5014                            }
5015                            else {
5016                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
5017                            }
5018                    }
5019    
5020                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5021                                    DLFileEntry.class.getName(),
5022                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5023    
5024                    SQLQuery q = session.createSQLQuery(sql);
5025    
5026                    q.setFirstResult(0);
5027                    q.setMaxResults(2);
5028    
5029                    if (getDB().isSupportsInlineDistinct()) {
5030                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5031                    }
5032                    else {
5033                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5034                    }
5035    
5036                    QueryPos qPos = QueryPos.getInstance(q);
5037    
5038                    qPos.add(groupId);
5039    
5040                    qPos.add(userId);
5041    
5042                    qPos.add(folderId);
5043    
5044                    if (orderByComparator != null) {
5045                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
5046    
5047                            for (Object value : values) {
5048                                    qPos.add(value);
5049                            }
5050                    }
5051    
5052                    List<DLFileEntry> list = q.list();
5053    
5054                    if (list.size() == 2) {
5055                            return list.get(1);
5056                    }
5057                    else {
5058                            return null;
5059                    }
5060            }
5061    
5062            /**
5063             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
5064             *
5065             * @param groupId the group ID
5066             * @param userId the user ID
5067             * @param folderIds the folder IDs
5068             * @return the matching document library file entries that the user has permission to view
5069             * @throws SystemException if a system exception occurred
5070             */
5071            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
5072                    long[] folderIds) throws SystemException {
5073                    return filterFindByG_U_F(groupId, userId, folderIds, QueryUtil.ALL_POS,
5074                            QueryUtil.ALL_POS, null);
5075            }
5076    
5077            /**
5078             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
5079             *
5080             * <p>
5081             * 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.
5082             * </p>
5083             *
5084             * @param groupId the group ID
5085             * @param userId the user ID
5086             * @param folderIds the folder IDs
5087             * @param start the lower bound of the range of document library file entries
5088             * @param end the upper bound of the range of document library file entries (not inclusive)
5089             * @return the range of matching document library file entries that the user has permission to view
5090             * @throws SystemException if a system exception occurred
5091             */
5092            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
5093                    long[] folderIds, int start, int end) throws SystemException {
5094                    return filterFindByG_U_F(groupId, userId, folderIds, start, end, null);
5095            }
5096    
5097            /**
5098             * Returns an ordered range of all the document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
5099             *
5100             * <p>
5101             * 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.
5102             * </p>
5103             *
5104             * @param groupId the group ID
5105             * @param userId the user ID
5106             * @param folderIds the folder IDs
5107             * @param start the lower bound of the range of document library file entries
5108             * @param end the upper bound of the range of document library file entries (not inclusive)
5109             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5110             * @return the ordered range of matching document library file entries that the user has permission to view
5111             * @throws SystemException if a system exception occurred
5112             */
5113            public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId,
5114                    long[] folderIds, int start, int end,
5115                    OrderByComparator orderByComparator) throws SystemException {
5116                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5117                            return findByG_U_F(groupId, userId, folderIds, start, end,
5118                                    orderByComparator);
5119                    }
5120    
5121                    StringBundler query = new StringBundler();
5122    
5123                    if (getDB().isSupportsInlineDistinct()) {
5124                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
5125                    }
5126                    else {
5127                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
5128                    }
5129    
5130                    boolean conjunctionable = false;
5131    
5132                    if (conjunctionable) {
5133                            query.append(WHERE_AND);
5134                    }
5135    
5136                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
5137    
5138                    conjunctionable = true;
5139    
5140                    if (conjunctionable) {
5141                            query.append(WHERE_AND);
5142                    }
5143    
5144                    query.append(_FINDER_COLUMN_G_U_F_USERID_5);
5145    
5146                    conjunctionable = true;
5147    
5148                    if ((folderIds == null) || (folderIds.length > 0)) {
5149                            if (conjunctionable) {
5150                                    query.append(WHERE_AND);
5151                            }
5152    
5153                            query.append(StringPool.OPEN_PARENTHESIS);
5154    
5155                            for (int i = 0; i < folderIds.length; i++) {
5156                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
5157    
5158                                    if ((i + 1) < folderIds.length) {
5159                                            query.append(WHERE_OR);
5160                                    }
5161                            }
5162    
5163                            query.append(StringPool.CLOSE_PARENTHESIS);
5164    
5165                            conjunctionable = true;
5166                    }
5167    
5168                    if (!getDB().isSupportsInlineDistinct()) {
5169                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
5170                    }
5171    
5172                    if (orderByComparator != null) {
5173                            if (getDB().isSupportsInlineDistinct()) {
5174                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5175                                            orderByComparator);
5176                            }
5177                            else {
5178                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5179                                            orderByComparator);
5180                            }
5181                    }
5182    
5183                    else {
5184                            if (getDB().isSupportsInlineDistinct()) {
5185                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5186                            }
5187                            else {
5188                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
5189                            }
5190                    }
5191    
5192                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5193                                    DLFileEntry.class.getName(),
5194                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5195    
5196                    Session session = null;
5197    
5198                    try {
5199                            session = openSession();
5200    
5201                            SQLQuery q = session.createSQLQuery(sql);
5202    
5203                            if (getDB().isSupportsInlineDistinct()) {
5204                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
5205                            }
5206                            else {
5207                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
5208                            }
5209    
5210                            QueryPos qPos = QueryPos.getInstance(q);
5211    
5212                            qPos.add(groupId);
5213    
5214                            qPos.add(userId);
5215    
5216                            if (folderIds != null) {
5217                                    qPos.add(folderIds);
5218                            }
5219    
5220                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
5221                    }
5222                    catch (Exception e) {
5223                            throw processException(e);
5224                    }
5225                    finally {
5226                            closeSession(session);
5227                    }
5228            }
5229    
5230            /**
5231             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryException} if it could not be found.
5232             *
5233             * @param groupId the group ID
5234             * @param folderId the folder ID
5235             * @param name the name
5236             * @return the matching document library file entry
5237             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
5238             * @throws SystemException if a system exception occurred
5239             */
5240            public DLFileEntry findByG_F_N(long groupId, long folderId, String name)
5241                    throws NoSuchFileEntryException, SystemException {
5242                    DLFileEntry dlFileEntry = fetchByG_F_N(groupId, folderId, name);
5243    
5244                    if (dlFileEntry == null) {
5245                            StringBundler msg = new StringBundler(8);
5246    
5247                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5248    
5249                            msg.append("groupId=");
5250                            msg.append(groupId);
5251    
5252                            msg.append(", folderId=");
5253                            msg.append(folderId);
5254    
5255                            msg.append(", name=");
5256                            msg.append(name);
5257    
5258                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5259    
5260                            if (_log.isWarnEnabled()) {
5261                                    _log.warn(msg.toString());
5262                            }
5263    
5264                            throw new NoSuchFileEntryException(msg.toString());
5265                    }
5266    
5267                    return dlFileEntry;
5268            }
5269    
5270            /**
5271             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
5272             *
5273             * @param groupId the group ID
5274             * @param folderId the folder ID
5275             * @param name the name
5276             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5277             * @throws SystemException if a system exception occurred
5278             */
5279            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name)
5280                    throws SystemException {
5281                    return fetchByG_F_N(groupId, folderId, name, true);
5282            }
5283    
5284            /**
5285             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
5286             *
5287             * @param groupId the group ID
5288             * @param folderId the folder ID
5289             * @param name the name
5290             * @param retrieveFromCache whether to use the finder cache
5291             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5292             * @throws SystemException if a system exception occurred
5293             */
5294            public DLFileEntry fetchByG_F_N(long groupId, long folderId, String name,
5295                    boolean retrieveFromCache) throws SystemException {
5296                    Object[] finderArgs = new Object[] { groupId, folderId, name };
5297    
5298                    Object result = null;
5299    
5300                    if (retrieveFromCache) {
5301                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_N,
5302                                            finderArgs, this);
5303                    }
5304    
5305                    if (result == null) {
5306                            StringBundler query = new StringBundler(5);
5307    
5308                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5309    
5310                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
5311    
5312                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
5313    
5314                            if (name == null) {
5315                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
5316                            }
5317                            else {
5318                                    if (name.equals(StringPool.BLANK)) {
5319                                            query.append(_FINDER_COLUMN_G_F_N_NAME_3);
5320                                    }
5321                                    else {
5322                                            query.append(_FINDER_COLUMN_G_F_N_NAME_2);
5323                                    }
5324                            }
5325    
5326                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5327    
5328                            String sql = query.toString();
5329    
5330                            Session session = null;
5331    
5332                            try {
5333                                    session = openSession();
5334    
5335                                    Query q = session.createQuery(sql);
5336    
5337                                    QueryPos qPos = QueryPos.getInstance(q);
5338    
5339                                    qPos.add(groupId);
5340    
5341                                    qPos.add(folderId);
5342    
5343                                    if (name != null) {
5344                                            qPos.add(name);
5345                                    }
5346    
5347                                    List<DLFileEntry> list = q.list();
5348    
5349                                    result = list;
5350    
5351                                    DLFileEntry dlFileEntry = null;
5352    
5353                                    if (list.isEmpty()) {
5354                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
5355                                                    finderArgs, list);
5356                                    }
5357                                    else {
5358                                            dlFileEntry = list.get(0);
5359    
5360                                            cacheResult(dlFileEntry);
5361    
5362                                            if ((dlFileEntry.getGroupId() != groupId) ||
5363                                                            (dlFileEntry.getFolderId() != folderId) ||
5364                                                            (dlFileEntry.getName() == null) ||
5365                                                            !dlFileEntry.getName().equals(name)) {
5366                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_N,
5367                                                            finderArgs, dlFileEntry);
5368                                            }
5369                                    }
5370    
5371                                    return dlFileEntry;
5372                            }
5373                            catch (Exception e) {
5374                                    throw processException(e);
5375                            }
5376                            finally {
5377                                    if (result == null) {
5378                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_N,
5379                                                    finderArgs);
5380                                    }
5381    
5382                                    closeSession(session);
5383                            }
5384                    }
5385                    else {
5386                            if (result instanceof List<?>) {
5387                                    return null;
5388                            }
5389                            else {
5390                                    return (DLFileEntry)result;
5391                            }
5392                    }
5393            }
5394    
5395            /**
5396             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryException} if it could not be found.
5397             *
5398             * @param groupId the group ID
5399             * @param folderId the folder ID
5400             * @param title the title
5401             * @return the matching document library file entry
5402             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
5403             * @throws SystemException if a system exception occurred
5404             */
5405            public DLFileEntry findByG_F_T(long groupId, long folderId, String title)
5406                    throws NoSuchFileEntryException, SystemException {
5407                    DLFileEntry dlFileEntry = fetchByG_F_T(groupId, folderId, title);
5408    
5409                    if (dlFileEntry == null) {
5410                            StringBundler msg = new StringBundler(8);
5411    
5412                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5413    
5414                            msg.append("groupId=");
5415                            msg.append(groupId);
5416    
5417                            msg.append(", folderId=");
5418                            msg.append(folderId);
5419    
5420                            msg.append(", title=");
5421                            msg.append(title);
5422    
5423                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5424    
5425                            if (_log.isWarnEnabled()) {
5426                                    _log.warn(msg.toString());
5427                            }
5428    
5429                            throw new NoSuchFileEntryException(msg.toString());
5430                    }
5431    
5432                    return dlFileEntry;
5433            }
5434    
5435            /**
5436             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
5437             *
5438             * @param groupId the group ID
5439             * @param folderId the folder ID
5440             * @param title the title
5441             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5442             * @throws SystemException if a system exception occurred
5443             */
5444            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title)
5445                    throws SystemException {
5446                    return fetchByG_F_T(groupId, folderId, title, true);
5447            }
5448    
5449            /**
5450             * Returns the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
5451             *
5452             * @param groupId the group ID
5453             * @param folderId the folder ID
5454             * @param title the title
5455             * @param retrieveFromCache whether to use the finder cache
5456             * @return the matching document library file entry, or <code>null</code> if a matching document library file entry could not be found
5457             * @throws SystemException if a system exception occurred
5458             */
5459            public DLFileEntry fetchByG_F_T(long groupId, long folderId, String title,
5460                    boolean retrieveFromCache) throws SystemException {
5461                    Object[] finderArgs = new Object[] { groupId, folderId, title };
5462    
5463                    Object result = null;
5464    
5465                    if (retrieveFromCache) {
5466                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_F_T,
5467                                            finderArgs, this);
5468                    }
5469    
5470                    if (result == null) {
5471                            StringBundler query = new StringBundler(5);
5472    
5473                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5474    
5475                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
5476    
5477                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
5478    
5479                            if (title == null) {
5480                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
5481                            }
5482                            else {
5483                                    if (title.equals(StringPool.BLANK)) {
5484                                            query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
5485                                    }
5486                                    else {
5487                                            query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
5488                                    }
5489                            }
5490    
5491                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5492    
5493                            String sql = query.toString();
5494    
5495                            Session session = null;
5496    
5497                            try {
5498                                    session = openSession();
5499    
5500                                    Query q = session.createQuery(sql);
5501    
5502                                    QueryPos qPos = QueryPos.getInstance(q);
5503    
5504                                    qPos.add(groupId);
5505    
5506                                    qPos.add(folderId);
5507    
5508                                    if (title != null) {
5509                                            qPos.add(title);
5510                                    }
5511    
5512                                    List<DLFileEntry> list = q.list();
5513    
5514                                    result = list;
5515    
5516                                    DLFileEntry dlFileEntry = null;
5517    
5518                                    if (list.isEmpty()) {
5519                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
5520                                                    finderArgs, list);
5521                                    }
5522                                    else {
5523                                            dlFileEntry = list.get(0);
5524    
5525                                            cacheResult(dlFileEntry);
5526    
5527                                            if ((dlFileEntry.getGroupId() != groupId) ||
5528                                                            (dlFileEntry.getFolderId() != folderId) ||
5529                                                            (dlFileEntry.getTitle() == null) ||
5530                                                            !dlFileEntry.getTitle().equals(title)) {
5531                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_F_T,
5532                                                            finderArgs, dlFileEntry);
5533                                            }
5534                                    }
5535    
5536                                    return dlFileEntry;
5537                            }
5538                            catch (Exception e) {
5539                                    throw processException(e);
5540                            }
5541                            finally {
5542                                    if (result == null) {
5543                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_F_T,
5544                                                    finderArgs);
5545                                    }
5546    
5547                                    closeSession(session);
5548                            }
5549                    }
5550                    else {
5551                            if (result instanceof List<?>) {
5552                                    return null;
5553                            }
5554                            else {
5555                                    return (DLFileEntry)result;
5556                            }
5557                    }
5558            }
5559    
5560            /**
5561             * Returns all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5562             *
5563             * @param groupId the group ID
5564             * @param folderId the folder ID
5565             * @param fileEntryTypeId the file entry type ID
5566             * @return the matching document library file entries
5567             * @throws SystemException if a system exception occurred
5568             */
5569            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
5570                    long fileEntryTypeId) throws SystemException {
5571                    return findByG_F_F(groupId, folderId, fileEntryTypeId,
5572                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5573            }
5574    
5575            /**
5576             * Returns a range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5577             *
5578             * <p>
5579             * 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.
5580             * </p>
5581             *
5582             * @param groupId the group ID
5583             * @param folderId the folder ID
5584             * @param fileEntryTypeId the file entry type ID
5585             * @param start the lower bound of the range of document library file entries
5586             * @param end the upper bound of the range of document library file entries (not inclusive)
5587             * @return the range of matching document library file entries
5588             * @throws SystemException if a system exception occurred
5589             */
5590            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
5591                    long fileEntryTypeId, int start, int end) throws SystemException {
5592                    return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end, null);
5593            }
5594    
5595            /**
5596             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5597             *
5598             * <p>
5599             * 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.
5600             * </p>
5601             *
5602             * @param groupId the group ID
5603             * @param folderId the folder ID
5604             * @param fileEntryTypeId the file entry type ID
5605             * @param start the lower bound of the range of document library file entries
5606             * @param end the upper bound of the range of document library file entries (not inclusive)
5607             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5608             * @return the ordered range of matching document library file entries
5609             * @throws SystemException if a system exception occurred
5610             */
5611            public List<DLFileEntry> findByG_F_F(long groupId, long folderId,
5612                    long fileEntryTypeId, int start, int end,
5613                    OrderByComparator orderByComparator) throws SystemException {
5614                    FinderPath finderPath = null;
5615                    Object[] finderArgs = null;
5616    
5617                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5618                                    (orderByComparator == null)) {
5619                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F;
5620                            finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
5621                    }
5622                    else {
5623                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F;
5624                            finderArgs = new Object[] {
5625                                            groupId, folderId, fileEntryTypeId,
5626                                            
5627                                            start, end, orderByComparator
5628                                    };
5629                    }
5630    
5631                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
5632                                    finderArgs, this);
5633    
5634                    if (list == null) {
5635                            StringBundler query = null;
5636    
5637                            if (orderByComparator != null) {
5638                                    query = new StringBundler(5 +
5639                                                    (orderByComparator.getOrderByFields().length * 3));
5640                            }
5641                            else {
5642                                    query = new StringBundler(5);
5643                            }
5644    
5645                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5646    
5647                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
5648    
5649                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
5650    
5651                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
5652    
5653                            if (orderByComparator != null) {
5654                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5655                                            orderByComparator);
5656                            }
5657    
5658                            else {
5659                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5660                            }
5661    
5662                            String sql = query.toString();
5663    
5664                            Session session = null;
5665    
5666                            try {
5667                                    session = openSession();
5668    
5669                                    Query q = session.createQuery(sql);
5670    
5671                                    QueryPos qPos = QueryPos.getInstance(q);
5672    
5673                                    qPos.add(groupId);
5674    
5675                                    qPos.add(folderId);
5676    
5677                                    qPos.add(fileEntryTypeId);
5678    
5679                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
5680                                                    start, end);
5681                            }
5682                            catch (Exception e) {
5683                                    throw processException(e);
5684                            }
5685                            finally {
5686                                    if (list == null) {
5687                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5688                                    }
5689                                    else {
5690                                            cacheResult(list);
5691    
5692                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5693                                    }
5694    
5695                                    closeSession(session);
5696                            }
5697                    }
5698    
5699                    return list;
5700            }
5701    
5702            /**
5703             * Returns the first document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5704             *
5705             * <p>
5706             * 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.
5707             * </p>
5708             *
5709             * @param groupId the group ID
5710             * @param folderId the folder ID
5711             * @param fileEntryTypeId the file entry type ID
5712             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5713             * @return the first matching document library file entry
5714             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
5715             * @throws SystemException if a system exception occurred
5716             */
5717            public DLFileEntry findByG_F_F_First(long groupId, long folderId,
5718                    long fileEntryTypeId, OrderByComparator orderByComparator)
5719                    throws NoSuchFileEntryException, SystemException {
5720                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
5721                                    fileEntryTypeId, 0, 1, orderByComparator);
5722    
5723                    if (list.isEmpty()) {
5724                            StringBundler msg = new StringBundler(8);
5725    
5726                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5727    
5728                            msg.append("groupId=");
5729                            msg.append(groupId);
5730    
5731                            msg.append(", folderId=");
5732                            msg.append(folderId);
5733    
5734                            msg.append(", fileEntryTypeId=");
5735                            msg.append(fileEntryTypeId);
5736    
5737                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5738    
5739                            throw new NoSuchFileEntryException(msg.toString());
5740                    }
5741                    else {
5742                            return list.get(0);
5743                    }
5744            }
5745    
5746            /**
5747             * Returns the last document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5748             *
5749             * <p>
5750             * 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.
5751             * </p>
5752             *
5753             * @param groupId the group ID
5754             * @param folderId the folder ID
5755             * @param fileEntryTypeId the file entry type ID
5756             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5757             * @return the last matching document library file entry
5758             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a matching document library file entry could not be found
5759             * @throws SystemException if a system exception occurred
5760             */
5761            public DLFileEntry findByG_F_F_Last(long groupId, long folderId,
5762                    long fileEntryTypeId, OrderByComparator orderByComparator)
5763                    throws NoSuchFileEntryException, SystemException {
5764                    int count = countByG_F_F(groupId, folderId, fileEntryTypeId);
5765    
5766                    List<DLFileEntry> list = findByG_F_F(groupId, folderId,
5767                                    fileEntryTypeId, count - 1, count, orderByComparator);
5768    
5769                    if (list.isEmpty()) {
5770                            StringBundler msg = new StringBundler(8);
5771    
5772                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5773    
5774                            msg.append("groupId=");
5775                            msg.append(groupId);
5776    
5777                            msg.append(", folderId=");
5778                            msg.append(folderId);
5779    
5780                            msg.append(", fileEntryTypeId=");
5781                            msg.append(fileEntryTypeId);
5782    
5783                            msg.append(StringPool.CLOSE_CURLY_BRACE);
5784    
5785                            throw new NoSuchFileEntryException(msg.toString());
5786                    }
5787                    else {
5788                            return list.get(0);
5789                    }
5790            }
5791    
5792            /**
5793             * Returns the document library file entries before and after the current document library file entry in the ordered set where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
5794             *
5795             * <p>
5796             * 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.
5797             * </p>
5798             *
5799             * @param fileEntryId the primary key of the current document library file entry
5800             * @param groupId the group ID
5801             * @param folderId the folder ID
5802             * @param fileEntryTypeId the file entry type ID
5803             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5804             * @return the previous, current, and next document library file entry
5805             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
5806             * @throws SystemException if a system exception occurred
5807             */
5808            public DLFileEntry[] findByG_F_F_PrevAndNext(long fileEntryId,
5809                    long groupId, long folderId, long fileEntryTypeId,
5810                    OrderByComparator orderByComparator)
5811                    throws NoSuchFileEntryException, SystemException {
5812                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
5813    
5814                    Session session = null;
5815    
5816                    try {
5817                            session = openSession();
5818    
5819                            DLFileEntry[] array = new DLFileEntryImpl[3];
5820    
5821                            array[0] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
5822                                            folderId, fileEntryTypeId, orderByComparator, true);
5823    
5824                            array[1] = dlFileEntry;
5825    
5826                            array[2] = getByG_F_F_PrevAndNext(session, dlFileEntry, groupId,
5827                                            folderId, fileEntryTypeId, orderByComparator, false);
5828    
5829                            return array;
5830                    }
5831                    catch (Exception e) {
5832                            throw processException(e);
5833                    }
5834                    finally {
5835                            closeSession(session);
5836                    }
5837            }
5838    
5839            protected DLFileEntry getByG_F_F_PrevAndNext(Session session,
5840                    DLFileEntry dlFileEntry, long groupId, long folderId,
5841                    long fileEntryTypeId, OrderByComparator orderByComparator,
5842                    boolean previous) {
5843                    StringBundler query = null;
5844    
5845                    if (orderByComparator != null) {
5846                            query = new StringBundler(6 +
5847                                            (orderByComparator.getOrderByFields().length * 6));
5848                    }
5849                    else {
5850                            query = new StringBundler(3);
5851                    }
5852    
5853                    query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
5854    
5855                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
5856    
5857                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
5858    
5859                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
5860    
5861                    if (orderByComparator != null) {
5862                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5863    
5864                            if (orderByConditionFields.length > 0) {
5865                                    query.append(WHERE_AND);
5866                            }
5867    
5868                            for (int i = 0; i < orderByConditionFields.length; i++) {
5869                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5870                                    query.append(orderByConditionFields[i]);
5871    
5872                                    if ((i + 1) < orderByConditionFields.length) {
5873                                            if (orderByComparator.isAscending() ^ previous) {
5874                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5875                                            }
5876                                            else {
5877                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5878                                            }
5879                                    }
5880                                    else {
5881                                            if (orderByComparator.isAscending() ^ previous) {
5882                                                    query.append(WHERE_GREATER_THAN);
5883                                            }
5884                                            else {
5885                                                    query.append(WHERE_LESSER_THAN);
5886                                            }
5887                                    }
5888                            }
5889    
5890                            query.append(ORDER_BY_CLAUSE);
5891    
5892                            String[] orderByFields = orderByComparator.getOrderByFields();
5893    
5894                            for (int i = 0; i < orderByFields.length; i++) {
5895                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5896                                    query.append(orderByFields[i]);
5897    
5898                                    if ((i + 1) < orderByFields.length) {
5899                                            if (orderByComparator.isAscending() ^ previous) {
5900                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5901                                            }
5902                                            else {
5903                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5904                                            }
5905                                    }
5906                                    else {
5907                                            if (orderByComparator.isAscending() ^ previous) {
5908                                                    query.append(ORDER_BY_ASC);
5909                                            }
5910                                            else {
5911                                                    query.append(ORDER_BY_DESC);
5912                                            }
5913                                    }
5914                            }
5915                    }
5916    
5917                    else {
5918                            query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
5919                    }
5920    
5921                    String sql = query.toString();
5922    
5923                    Query q = session.createQuery(sql);
5924    
5925                    q.setFirstResult(0);
5926                    q.setMaxResults(2);
5927    
5928                    QueryPos qPos = QueryPos.getInstance(q);
5929    
5930                    qPos.add(groupId);
5931    
5932                    qPos.add(folderId);
5933    
5934                    qPos.add(fileEntryTypeId);
5935    
5936                    if (orderByComparator != null) {
5937                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
5938    
5939                            for (Object value : values) {
5940                                    qPos.add(value);
5941                            }
5942                    }
5943    
5944                    List<DLFileEntry> list = q.list();
5945    
5946                    if (list.size() == 2) {
5947                            return list.get(1);
5948                    }
5949                    else {
5950                            return null;
5951                    }
5952            }
5953    
5954            /**
5955             * Returns all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
5956             *
5957             * <p>
5958             * 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.
5959             * </p>
5960             *
5961             * @param groupId the group ID
5962             * @param folderIds the folder IDs
5963             * @param fileEntryTypeId the file entry type ID
5964             * @return the matching document library file entries
5965             * @throws SystemException if a system exception occurred
5966             */
5967            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
5968                    long fileEntryTypeId) throws SystemException {
5969                    return findByG_F_F(groupId, folderIds, fileEntryTypeId,
5970                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5971            }
5972    
5973            /**
5974             * Returns a range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
5975             *
5976             * <p>
5977             * 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.
5978             * </p>
5979             *
5980             * @param groupId the group ID
5981             * @param folderIds the folder IDs
5982             * @param fileEntryTypeId the file entry type ID
5983             * @param start the lower bound of the range of document library file entries
5984             * @param end the upper bound of the range of document library file entries (not inclusive)
5985             * @return the range of matching document library file entries
5986             * @throws SystemException if a system exception occurred
5987             */
5988            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
5989                    long fileEntryTypeId, int start, int end) throws SystemException {
5990                    return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end, null);
5991            }
5992    
5993            /**
5994             * Returns an ordered range of all the document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
5995             *
5996             * <p>
5997             * 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.
5998             * </p>
5999             *
6000             * @param groupId the group ID
6001             * @param folderIds the folder IDs
6002             * @param fileEntryTypeId the file entry type ID
6003             * @param start the lower bound of the range of document library file entries
6004             * @param end the upper bound of the range of document library file entries (not inclusive)
6005             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6006             * @return the ordered range of matching document library file entries
6007             * @throws SystemException if a system exception occurred
6008             */
6009            public List<DLFileEntry> findByG_F_F(long groupId, long[] folderIds,
6010                    long fileEntryTypeId, int start, int end,
6011                    OrderByComparator orderByComparator) throws SystemException {
6012                    FinderPath finderPath = null;
6013                    Object[] finderArgs = null;
6014    
6015                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6016                                    (orderByComparator == null)) {
6017                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_F;
6018                            finderArgs = new Object[] {
6019                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId
6020                                    };
6021                    }
6022                    else {
6023                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F;
6024                            finderArgs = new Object[] {
6025                                            groupId, StringUtil.merge(folderIds), fileEntryTypeId,
6026                                            
6027                                            start, end, orderByComparator
6028                                    };
6029                    }
6030    
6031                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
6032                                    finderArgs, this);
6033    
6034                    if (list == null) {
6035                            StringBundler query = new StringBundler();
6036    
6037                            query.append(_SQL_SELECT_DLFILEENTRY_WHERE);
6038    
6039                            boolean conjunctionable = false;
6040    
6041                            if (conjunctionable) {
6042                                    query.append(WHERE_AND);
6043                            }
6044    
6045                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
6046    
6047                            conjunctionable = true;
6048    
6049                            if ((folderIds == null) || (folderIds.length > 0)) {
6050                                    if (conjunctionable) {
6051                                            query.append(WHERE_AND);
6052                                    }
6053    
6054                                    query.append(StringPool.OPEN_PARENTHESIS);
6055    
6056                                    for (int i = 0; i < folderIds.length; i++) {
6057                                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
6058    
6059                                            if ((i + 1) < folderIds.length) {
6060                                                    query.append(WHERE_OR);
6061                                            }
6062                                    }
6063    
6064                                    query.append(StringPool.CLOSE_PARENTHESIS);
6065    
6066                                    conjunctionable = true;
6067                            }
6068    
6069                            if (conjunctionable) {
6070                                    query.append(WHERE_AND);
6071                            }
6072    
6073                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
6074    
6075                            conjunctionable = true;
6076    
6077                            if (orderByComparator != null) {
6078                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6079                                            orderByComparator);
6080                            }
6081    
6082                            else {
6083                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6084                            }
6085    
6086                            String sql = query.toString();
6087    
6088                            Session session = null;
6089    
6090                            try {
6091                                    session = openSession();
6092    
6093                                    Query q = session.createQuery(sql);
6094    
6095                                    QueryPos qPos = QueryPos.getInstance(q);
6096    
6097                                    qPos.add(groupId);
6098    
6099                                    if (folderIds != null) {
6100                                            qPos.add(folderIds);
6101                                    }
6102    
6103                                    qPos.add(fileEntryTypeId);
6104    
6105                                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6106                                                    start, end);
6107                            }
6108                            catch (Exception e) {
6109                                    throw processException(e);
6110                            }
6111                            finally {
6112                                    if (list == null) {
6113                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6114                                    }
6115                                    else {
6116                                            cacheResult(list);
6117    
6118                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6119                                    }
6120    
6121                                    closeSession(session);
6122                            }
6123                    }
6124    
6125                    return list;
6126            }
6127    
6128            /**
6129             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
6130             *
6131             * @param groupId the group ID
6132             * @param folderId the folder ID
6133             * @param fileEntryTypeId the file entry type ID
6134             * @return the matching document library file entries that the user has permission to view
6135             * @throws SystemException if a system exception occurred
6136             */
6137            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
6138                    long fileEntryTypeId) throws SystemException {
6139                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId,
6140                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6141            }
6142    
6143            /**
6144             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
6145             *
6146             * <p>
6147             * 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.
6148             * </p>
6149             *
6150             * @param groupId the group ID
6151             * @param folderId the folder ID
6152             * @param fileEntryTypeId the file entry type ID
6153             * @param start the lower bound of the range of document library file entries
6154             * @param end the upper bound of the range of document library file entries (not inclusive)
6155             * @return the range of matching document library file entries that the user has permission to view
6156             * @throws SystemException if a system exception occurred
6157             */
6158            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
6159                    long fileEntryTypeId, int start, int end) throws SystemException {
6160                    return filterFindByG_F_F(groupId, folderId, fileEntryTypeId, start,
6161                            end, null);
6162            }
6163    
6164            /**
6165             * Returns an ordered range of all the document library file entries that the user has permissions to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
6166             *
6167             * <p>
6168             * 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.
6169             * </p>
6170             *
6171             * @param groupId the group ID
6172             * @param folderId the folder ID
6173             * @param fileEntryTypeId the file entry type ID
6174             * @param start the lower bound of the range of document library file entries
6175             * @param end the upper bound of the range of document library file entries (not inclusive)
6176             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6177             * @return the ordered range of matching document library file entries that the user has permission to view
6178             * @throws SystemException if a system exception occurred
6179             */
6180            public List<DLFileEntry> filterFindByG_F_F(long groupId, long folderId,
6181                    long fileEntryTypeId, int start, int end,
6182                    OrderByComparator orderByComparator) throws SystemException {
6183                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6184                            return findByG_F_F(groupId, folderId, fileEntryTypeId, start, end,
6185                                    orderByComparator);
6186                    }
6187    
6188                    StringBundler query = null;
6189    
6190                    if (orderByComparator != null) {
6191                            query = new StringBundler(5 +
6192                                            (orderByComparator.getOrderByFields().length * 3));
6193                    }
6194                    else {
6195                            query = new StringBundler(5);
6196                    }
6197    
6198                    if (getDB().isSupportsInlineDistinct()) {
6199                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
6200                    }
6201                    else {
6202                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
6203                    }
6204    
6205                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
6206    
6207                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
6208    
6209                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
6210    
6211                    if (!getDB().isSupportsInlineDistinct()) {
6212                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
6213                    }
6214    
6215                    if (orderByComparator != null) {
6216                            if (getDB().isSupportsInlineDistinct()) {
6217                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6218                                            orderByComparator);
6219                            }
6220                            else {
6221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6222                                            orderByComparator);
6223                            }
6224                    }
6225    
6226                    else {
6227                            if (getDB().isSupportsInlineDistinct()) {
6228                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6229                            }
6230                            else {
6231                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6232                            }
6233                    }
6234    
6235                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6236                                    DLFileEntry.class.getName(),
6237                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6238    
6239                    Session session = null;
6240    
6241                    try {
6242                            session = openSession();
6243    
6244                            SQLQuery q = session.createSQLQuery(sql);
6245    
6246                            if (getDB().isSupportsInlineDistinct()) {
6247                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6248                            }
6249                            else {
6250                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6251                            }
6252    
6253                            QueryPos qPos = QueryPos.getInstance(q);
6254    
6255                            qPos.add(groupId);
6256    
6257                            qPos.add(folderId);
6258    
6259                            qPos.add(fileEntryTypeId);
6260    
6261                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
6262                    }
6263                    catch (Exception e) {
6264                            throw processException(e);
6265                    }
6266                    finally {
6267                            closeSession(session);
6268                    }
6269            }
6270    
6271            /**
6272             * Returns the document library file entries before and after the current document library file entry in the ordered set of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
6273             *
6274             * @param fileEntryId the primary key of the current document library file entry
6275             * @param groupId the group ID
6276             * @param folderId the folder ID
6277             * @param fileEntryTypeId the file entry type ID
6278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6279             * @return the previous, current, and next document library file entry
6280             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryException if a document library file entry with the primary key could not be found
6281             * @throws SystemException if a system exception occurred
6282             */
6283            public DLFileEntry[] filterFindByG_F_F_PrevAndNext(long fileEntryId,
6284                    long groupId, long folderId, long fileEntryTypeId,
6285                    OrderByComparator orderByComparator)
6286                    throws NoSuchFileEntryException, SystemException {
6287                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6288                            return findByG_F_F_PrevAndNext(fileEntryId, groupId, folderId,
6289                                    fileEntryTypeId, orderByComparator);
6290                    }
6291    
6292                    DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
6293    
6294                    Session session = null;
6295    
6296                    try {
6297                            session = openSession();
6298    
6299                            DLFileEntry[] array = new DLFileEntryImpl[3];
6300    
6301                            array[0] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
6302                                            groupId, folderId, fileEntryTypeId, orderByComparator, true);
6303    
6304                            array[1] = dlFileEntry;
6305    
6306                            array[2] = filterGetByG_F_F_PrevAndNext(session, dlFileEntry,
6307                                            groupId, folderId, fileEntryTypeId, orderByComparator, false);
6308    
6309                            return array;
6310                    }
6311                    catch (Exception e) {
6312                            throw processException(e);
6313                    }
6314                    finally {
6315                            closeSession(session);
6316                    }
6317            }
6318    
6319            protected DLFileEntry filterGetByG_F_F_PrevAndNext(Session session,
6320                    DLFileEntry dlFileEntry, long groupId, long folderId,
6321                    long fileEntryTypeId, OrderByComparator orderByComparator,
6322                    boolean previous) {
6323                    StringBundler query = null;
6324    
6325                    if (orderByComparator != null) {
6326                            query = new StringBundler(6 +
6327                                            (orderByComparator.getOrderByFields().length * 6));
6328                    }
6329                    else {
6330                            query = new StringBundler(3);
6331                    }
6332    
6333                    if (getDB().isSupportsInlineDistinct()) {
6334                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
6335                    }
6336                    else {
6337                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
6338                    }
6339    
6340                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
6341    
6342                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
6343    
6344                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
6345    
6346                    if (!getDB().isSupportsInlineDistinct()) {
6347                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
6348                    }
6349    
6350                    if (orderByComparator != null) {
6351                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6352    
6353                            if (orderByConditionFields.length > 0) {
6354                                    query.append(WHERE_AND);
6355                            }
6356    
6357                            for (int i = 0; i < orderByConditionFields.length; i++) {
6358                                    if (getDB().isSupportsInlineDistinct()) {
6359                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6360                                    }
6361                                    else {
6362                                            query.append(_ORDER_BY_ENTITY_TABLE);
6363                                    }
6364    
6365                                    query.append(orderByConditionFields[i]);
6366    
6367                                    if ((i + 1) < orderByConditionFields.length) {
6368                                            if (orderByComparator.isAscending() ^ previous) {
6369                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6370                                            }
6371                                            else {
6372                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6373                                            }
6374                                    }
6375                                    else {
6376                                            if (orderByComparator.isAscending() ^ previous) {
6377                                                    query.append(WHERE_GREATER_THAN);
6378                                            }
6379                                            else {
6380                                                    query.append(WHERE_LESSER_THAN);
6381                                            }
6382                                    }
6383                            }
6384    
6385                            query.append(ORDER_BY_CLAUSE);
6386    
6387                            String[] orderByFields = orderByComparator.getOrderByFields();
6388    
6389                            for (int i = 0; i < orderByFields.length; i++) {
6390                                    if (getDB().isSupportsInlineDistinct()) {
6391                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6392                                    }
6393                                    else {
6394                                            query.append(_ORDER_BY_ENTITY_TABLE);
6395                                    }
6396    
6397                                    query.append(orderByFields[i]);
6398    
6399                                    if ((i + 1) < orderByFields.length) {
6400                                            if (orderByComparator.isAscending() ^ previous) {
6401                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6402                                            }
6403                                            else {
6404                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6405                                            }
6406                                    }
6407                                    else {
6408                                            if (orderByComparator.isAscending() ^ previous) {
6409                                                    query.append(ORDER_BY_ASC);
6410                                            }
6411                                            else {
6412                                                    query.append(ORDER_BY_DESC);
6413                                            }
6414                                    }
6415                            }
6416                    }
6417    
6418                    else {
6419                            if (getDB().isSupportsInlineDistinct()) {
6420                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6421                            }
6422                            else {
6423                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6424                            }
6425                    }
6426    
6427                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6428                                    DLFileEntry.class.getName(),
6429                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6430    
6431                    SQLQuery q = session.createSQLQuery(sql);
6432    
6433                    q.setFirstResult(0);
6434                    q.setMaxResults(2);
6435    
6436                    if (getDB().isSupportsInlineDistinct()) {
6437                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6438                    }
6439                    else {
6440                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6441                    }
6442    
6443                    QueryPos qPos = QueryPos.getInstance(q);
6444    
6445                    qPos.add(groupId);
6446    
6447                    qPos.add(folderId);
6448    
6449                    qPos.add(fileEntryTypeId);
6450    
6451                    if (orderByComparator != null) {
6452                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntry);
6453    
6454                            for (Object value : values) {
6455                                    qPos.add(value);
6456                            }
6457                    }
6458    
6459                    List<DLFileEntry> list = q.list();
6460    
6461                    if (list.size() == 2) {
6462                            return list.get(1);
6463                    }
6464                    else {
6465                            return null;
6466                    }
6467            }
6468    
6469            /**
6470             * Returns all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
6471             *
6472             * @param groupId the group ID
6473             * @param folderIds the folder IDs
6474             * @param fileEntryTypeId the file entry type ID
6475             * @return the matching document library file entries that the user has permission to view
6476             * @throws SystemException if a system exception occurred
6477             */
6478            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
6479                    long fileEntryTypeId) throws SystemException {
6480                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId,
6481                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6482            }
6483    
6484            /**
6485             * Returns a range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
6486             *
6487             * <p>
6488             * 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.
6489             * </p>
6490             *
6491             * @param groupId the group ID
6492             * @param folderIds the folder IDs
6493             * @param fileEntryTypeId the file entry type ID
6494             * @param start the lower bound of the range of document library file entries
6495             * @param end the upper bound of the range of document library file entries (not inclusive)
6496             * @return the range of matching document library file entries that the user has permission to view
6497             * @throws SystemException if a system exception occurred
6498             */
6499            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
6500                    long fileEntryTypeId, int start, int end) throws SystemException {
6501                    return filterFindByG_F_F(groupId, folderIds, fileEntryTypeId, start,
6502                            end, null);
6503            }
6504    
6505            /**
6506             * Returns an ordered range of all the document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
6507             *
6508             * <p>
6509             * 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.
6510             * </p>
6511             *
6512             * @param groupId the group ID
6513             * @param folderIds the folder IDs
6514             * @param fileEntryTypeId the file entry type ID
6515             * @param start the lower bound of the range of document library file entries
6516             * @param end the upper bound of the range of document library file entries (not inclusive)
6517             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6518             * @return the ordered range of matching document library file entries that the user has permission to view
6519             * @throws SystemException if a system exception occurred
6520             */
6521            public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds,
6522                    long fileEntryTypeId, int start, int end,
6523                    OrderByComparator orderByComparator) throws SystemException {
6524                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6525                            return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end,
6526                                    orderByComparator);
6527                    }
6528    
6529                    StringBundler query = new StringBundler();
6530    
6531                    if (getDB().isSupportsInlineDistinct()) {
6532                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
6533                    }
6534                    else {
6535                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
6536                    }
6537    
6538                    boolean conjunctionable = false;
6539    
6540                    if (conjunctionable) {
6541                            query.append(WHERE_AND);
6542                    }
6543    
6544                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
6545    
6546                    conjunctionable = true;
6547    
6548                    if ((folderIds == null) || (folderIds.length > 0)) {
6549                            if (conjunctionable) {
6550                                    query.append(WHERE_AND);
6551                            }
6552    
6553                            query.append(StringPool.OPEN_PARENTHESIS);
6554    
6555                            for (int i = 0; i < folderIds.length; i++) {
6556                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
6557    
6558                                    if ((i + 1) < folderIds.length) {
6559                                            query.append(WHERE_OR);
6560                                    }
6561                            }
6562    
6563                            query.append(StringPool.CLOSE_PARENTHESIS);
6564    
6565                            conjunctionable = true;
6566                    }
6567    
6568                    if (conjunctionable) {
6569                            query.append(WHERE_AND);
6570                    }
6571    
6572                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
6573    
6574                    conjunctionable = true;
6575    
6576                    if (!getDB().isSupportsInlineDistinct()) {
6577                            query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2);
6578                    }
6579    
6580                    if (orderByComparator != null) {
6581                            if (getDB().isSupportsInlineDistinct()) {
6582                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6583                                            orderByComparator);
6584                            }
6585                            else {
6586                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6587                                            orderByComparator);
6588                            }
6589                    }
6590    
6591                    else {
6592                            if (getDB().isSupportsInlineDistinct()) {
6593                                    query.append(DLFileEntryModelImpl.ORDER_BY_JPQL);
6594                            }
6595                            else {
6596                                    query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
6597                            }
6598                    }
6599    
6600                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6601                                    DLFileEntry.class.getName(),
6602                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6603    
6604                    Session session = null;
6605    
6606                    try {
6607                            session = openSession();
6608    
6609                            SQLQuery q = session.createSQLQuery(sql);
6610    
6611                            if (getDB().isSupportsInlineDistinct()) {
6612                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryImpl.class);
6613                            }
6614                            else {
6615                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
6616                            }
6617    
6618                            QueryPos qPos = QueryPos.getInstance(q);
6619    
6620                            qPos.add(groupId);
6621    
6622                            if (folderIds != null) {
6623                                    qPos.add(folderIds);
6624                            }
6625    
6626                            qPos.add(fileEntryTypeId);
6627    
6628                            return (List<DLFileEntry>)QueryUtil.list(q, getDialect(), start, end);
6629                    }
6630                    catch (Exception e) {
6631                            throw processException(e);
6632                    }
6633                    finally {
6634                            closeSession(session);
6635                    }
6636            }
6637    
6638            /**
6639             * Returns all the document library file entries.
6640             *
6641             * @return the document library file entries
6642             * @throws SystemException if a system exception occurred
6643             */
6644            public List<DLFileEntry> findAll() throws SystemException {
6645                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6646            }
6647    
6648            /**
6649             * Returns a range of all the document library file entries.
6650             *
6651             * <p>
6652             * 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.
6653             * </p>
6654             *
6655             * @param start the lower bound of the range of document library file entries
6656             * @param end the upper bound of the range of document library file entries (not inclusive)
6657             * @return the range of document library file entries
6658             * @throws SystemException if a system exception occurred
6659             */
6660            public List<DLFileEntry> findAll(int start, int end)
6661                    throws SystemException {
6662                    return findAll(start, end, null);
6663            }
6664    
6665            /**
6666             * Returns an ordered range of all the document library file entries.
6667             *
6668             * <p>
6669             * 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.
6670             * </p>
6671             *
6672             * @param start the lower bound of the range of document library file entries
6673             * @param end the upper bound of the range of document library file entries (not inclusive)
6674             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6675             * @return the ordered range of document library file entries
6676             * @throws SystemException if a system exception occurred
6677             */
6678            public List<DLFileEntry> findAll(int start, int end,
6679                    OrderByComparator orderByComparator) throws SystemException {
6680                    FinderPath finderPath = null;
6681                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
6682    
6683                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6684                                    (orderByComparator == null)) {
6685                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
6686                            finderArgs = FINDER_ARGS_EMPTY;
6687                    }
6688                    else {
6689                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
6690                            finderArgs = new Object[] { start, end, orderByComparator };
6691                    }
6692    
6693                    List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(finderPath,
6694                                    finderArgs, this);
6695    
6696                    if (list == null) {
6697                            StringBundler query = null;
6698                            String sql = null;
6699    
6700                            if (orderByComparator != null) {
6701                                    query = new StringBundler(2 +
6702                                                    (orderByComparator.getOrderByFields().length * 3));
6703    
6704                                    query.append(_SQL_SELECT_DLFILEENTRY);
6705    
6706                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6707                                            orderByComparator);
6708    
6709                                    sql = query.toString();
6710                            }
6711                            else {
6712                                    sql = _SQL_SELECT_DLFILEENTRY.concat(DLFileEntryModelImpl.ORDER_BY_JPQL);
6713                            }
6714    
6715                            Session session = null;
6716    
6717                            try {
6718                                    session = openSession();
6719    
6720                                    Query q = session.createQuery(sql);
6721    
6722                                    if (orderByComparator == null) {
6723                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6724                                                            start, end, false);
6725    
6726                                            Collections.sort(list);
6727                                    }
6728                                    else {
6729                                            list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
6730                                                            start, end);
6731                                    }
6732                            }
6733                            catch (Exception e) {
6734                                    throw processException(e);
6735                            }
6736                            finally {
6737                                    if (list == null) {
6738                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6739                                    }
6740                                    else {
6741                                            cacheResult(list);
6742    
6743                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6744                                    }
6745    
6746                                    closeSession(session);
6747                            }
6748                    }
6749    
6750                    return list;
6751            }
6752    
6753            /**
6754             * Removes all the document library file entries where uuid = &#63; from the database.
6755             *
6756             * @param uuid the uuid
6757             * @throws SystemException if a system exception occurred
6758             */
6759            public void removeByUuid(String uuid) throws SystemException {
6760                    for (DLFileEntry dlFileEntry : findByUuid(uuid)) {
6761                            remove(dlFileEntry);
6762                    }
6763            }
6764    
6765            /**
6766             * Removes the document library file entry where uuid = &#63; and groupId = &#63; from the database.
6767             *
6768             * @param uuid the uuid
6769             * @param groupId the group ID
6770             * @throws SystemException if a system exception occurred
6771             */
6772            public void removeByUUID_G(String uuid, long groupId)
6773                    throws NoSuchFileEntryException, SystemException {
6774                    DLFileEntry dlFileEntry = findByUUID_G(uuid, groupId);
6775    
6776                    remove(dlFileEntry);
6777            }
6778    
6779            /**
6780             * Removes all the document library file entries where groupId = &#63; from the database.
6781             *
6782             * @param groupId the group ID
6783             * @throws SystemException if a system exception occurred
6784             */
6785            public void removeByGroupId(long groupId) throws SystemException {
6786                    for (DLFileEntry dlFileEntry : findByGroupId(groupId)) {
6787                            remove(dlFileEntry);
6788                    }
6789            }
6790    
6791            /**
6792             * Removes all the document library file entries where companyId = &#63; from the database.
6793             *
6794             * @param companyId the company ID
6795             * @throws SystemException if a system exception occurred
6796             */
6797            public void removeByCompanyId(long companyId) throws SystemException {
6798                    for (DLFileEntry dlFileEntry : findByCompanyId(companyId)) {
6799                            remove(dlFileEntry);
6800                    }
6801            }
6802    
6803            /**
6804             * Removes all the document library file entries where groupId = &#63; and userId = &#63; from the database.
6805             *
6806             * @param groupId the group ID
6807             * @param userId the user ID
6808             * @throws SystemException if a system exception occurred
6809             */
6810            public void removeByG_U(long groupId, long userId)
6811                    throws SystemException {
6812                    for (DLFileEntry dlFileEntry : findByG_U(groupId, userId)) {
6813                            remove(dlFileEntry);
6814                    }
6815            }
6816    
6817            /**
6818             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; from the database.
6819             *
6820             * @param groupId the group ID
6821             * @param folderId the folder ID
6822             * @throws SystemException if a system exception occurred
6823             */
6824            public void removeByG_F(long groupId, long folderId)
6825                    throws SystemException {
6826                    for (DLFileEntry dlFileEntry : findByG_F(groupId, folderId)) {
6827                            remove(dlFileEntry);
6828                    }
6829            }
6830    
6831            /**
6832             * Removes all the document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63; from the database.
6833             *
6834             * @param groupId the group ID
6835             * @param userId the user ID
6836             * @param folderId the folder ID
6837             * @throws SystemException if a system exception occurred
6838             */
6839            public void removeByG_U_F(long groupId, long userId, long folderId)
6840                    throws SystemException {
6841                    for (DLFileEntry dlFileEntry : findByG_U_F(groupId, userId, folderId)) {
6842                            remove(dlFileEntry);
6843                    }
6844            }
6845    
6846            /**
6847             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and name = &#63; from the database.
6848             *
6849             * @param groupId the group ID
6850             * @param folderId the folder ID
6851             * @param name the name
6852             * @throws SystemException if a system exception occurred
6853             */
6854            public void removeByG_F_N(long groupId, long folderId, String name)
6855                    throws NoSuchFileEntryException, SystemException {
6856                    DLFileEntry dlFileEntry = findByG_F_N(groupId, folderId, name);
6857    
6858                    remove(dlFileEntry);
6859            }
6860    
6861            /**
6862             * Removes the document library file entry where groupId = &#63; and folderId = &#63; and title = &#63; from the database.
6863             *
6864             * @param groupId the group ID
6865             * @param folderId the folder ID
6866             * @param title the title
6867             * @throws SystemException if a system exception occurred
6868             */
6869            public void removeByG_F_T(long groupId, long folderId, String title)
6870                    throws NoSuchFileEntryException, SystemException {
6871                    DLFileEntry dlFileEntry = findByG_F_T(groupId, folderId, title);
6872    
6873                    remove(dlFileEntry);
6874            }
6875    
6876            /**
6877             * Removes all the document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63; from the database.
6878             *
6879             * @param groupId the group ID
6880             * @param folderId the folder ID
6881             * @param fileEntryTypeId the file entry type ID
6882             * @throws SystemException if a system exception occurred
6883             */
6884            public void removeByG_F_F(long groupId, long folderId, long fileEntryTypeId)
6885                    throws SystemException {
6886                    for (DLFileEntry dlFileEntry : findByG_F_F(groupId, folderId,
6887                                    fileEntryTypeId)) {
6888                            remove(dlFileEntry);
6889                    }
6890            }
6891    
6892            /**
6893             * Removes all the document library file entries from the database.
6894             *
6895             * @throws SystemException if a system exception occurred
6896             */
6897            public void removeAll() throws SystemException {
6898                    for (DLFileEntry dlFileEntry : findAll()) {
6899                            remove(dlFileEntry);
6900                    }
6901            }
6902    
6903            /**
6904             * Returns the number of document library file entries where uuid = &#63;.
6905             *
6906             * @param uuid the uuid
6907             * @return the number of matching document library file entries
6908             * @throws SystemException if a system exception occurred
6909             */
6910            public int countByUuid(String uuid) throws SystemException {
6911                    Object[] finderArgs = new Object[] { uuid };
6912    
6913                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
6914                                    finderArgs, this);
6915    
6916                    if (count == null) {
6917                            StringBundler query = new StringBundler(2);
6918    
6919                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
6920    
6921                            if (uuid == null) {
6922                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
6923                            }
6924                            else {
6925                                    if (uuid.equals(StringPool.BLANK)) {
6926                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
6927                                    }
6928                                    else {
6929                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
6930                                    }
6931                            }
6932    
6933                            String sql = query.toString();
6934    
6935                            Session session = null;
6936    
6937                            try {
6938                                    session = openSession();
6939    
6940                                    Query q = session.createQuery(sql);
6941    
6942                                    QueryPos qPos = QueryPos.getInstance(q);
6943    
6944                                    if (uuid != null) {
6945                                            qPos.add(uuid);
6946                                    }
6947    
6948                                    count = (Long)q.uniqueResult();
6949                            }
6950                            catch (Exception e) {
6951                                    throw processException(e);
6952                            }
6953                            finally {
6954                                    if (count == null) {
6955                                            count = Long.valueOf(0);
6956                                    }
6957    
6958                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
6959                                            finderArgs, count);
6960    
6961                                    closeSession(session);
6962                            }
6963                    }
6964    
6965                    return count.intValue();
6966            }
6967    
6968            /**
6969             * Returns the number of document library file entries where uuid = &#63; and groupId = &#63;.
6970             *
6971             * @param uuid the uuid
6972             * @param groupId the group ID
6973             * @return the number of matching document library file entries
6974             * @throws SystemException if a system exception occurred
6975             */
6976            public int countByUUID_G(String uuid, long groupId)
6977                    throws SystemException {
6978                    Object[] finderArgs = new Object[] { uuid, groupId };
6979    
6980                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
6981                                    finderArgs, this);
6982    
6983                    if (count == null) {
6984                            StringBundler query = new StringBundler(3);
6985    
6986                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
6987    
6988                            if (uuid == null) {
6989                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
6990                            }
6991                            else {
6992                                    if (uuid.equals(StringPool.BLANK)) {
6993                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
6994                                    }
6995                                    else {
6996                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
6997                                    }
6998                            }
6999    
7000                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
7001    
7002                            String sql = query.toString();
7003    
7004                            Session session = null;
7005    
7006                            try {
7007                                    session = openSession();
7008    
7009                                    Query q = session.createQuery(sql);
7010    
7011                                    QueryPos qPos = QueryPos.getInstance(q);
7012    
7013                                    if (uuid != null) {
7014                                            qPos.add(uuid);
7015                                    }
7016    
7017                                    qPos.add(groupId);
7018    
7019                                    count = (Long)q.uniqueResult();
7020                            }
7021                            catch (Exception e) {
7022                                    throw processException(e);
7023                            }
7024                            finally {
7025                                    if (count == null) {
7026                                            count = Long.valueOf(0);
7027                                    }
7028    
7029                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
7030                                            finderArgs, count);
7031    
7032                                    closeSession(session);
7033                            }
7034                    }
7035    
7036                    return count.intValue();
7037            }
7038    
7039            /**
7040             * Returns the number of document library file entries where groupId = &#63;.
7041             *
7042             * @param groupId the group ID
7043             * @return the number of matching document library file entries
7044             * @throws SystemException if a system exception occurred
7045             */
7046            public int countByGroupId(long groupId) throws SystemException {
7047                    Object[] finderArgs = new Object[] { groupId };
7048    
7049                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
7050                                    finderArgs, this);
7051    
7052                    if (count == null) {
7053                            StringBundler query = new StringBundler(2);
7054    
7055                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7056    
7057                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7058    
7059                            String sql = query.toString();
7060    
7061                            Session session = null;
7062    
7063                            try {
7064                                    session = openSession();
7065    
7066                                    Query q = session.createQuery(sql);
7067    
7068                                    QueryPos qPos = QueryPos.getInstance(q);
7069    
7070                                    qPos.add(groupId);
7071    
7072                                    count = (Long)q.uniqueResult();
7073                            }
7074                            catch (Exception e) {
7075                                    throw processException(e);
7076                            }
7077                            finally {
7078                                    if (count == null) {
7079                                            count = Long.valueOf(0);
7080                                    }
7081    
7082                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
7083                                            finderArgs, count);
7084    
7085                                    closeSession(session);
7086                            }
7087                    }
7088    
7089                    return count.intValue();
7090            }
7091    
7092            /**
7093             * Returns the number of document library file entries that the user has permission to view where groupId = &#63;.
7094             *
7095             * @param groupId the group ID
7096             * @return the number of matching document library file entries that the user has permission to view
7097             * @throws SystemException if a system exception occurred
7098             */
7099            public int filterCountByGroupId(long groupId) throws SystemException {
7100                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7101                            return countByGroupId(groupId);
7102                    }
7103    
7104                    StringBundler query = new StringBundler(2);
7105    
7106                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7107    
7108                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
7109    
7110                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7111                                    DLFileEntry.class.getName(),
7112                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7113    
7114                    Session session = null;
7115    
7116                    try {
7117                            session = openSession();
7118    
7119                            SQLQuery q = session.createSQLQuery(sql);
7120    
7121                            q.addScalar(COUNT_COLUMN_NAME,
7122                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7123    
7124                            QueryPos qPos = QueryPos.getInstance(q);
7125    
7126                            qPos.add(groupId);
7127    
7128                            Long count = (Long)q.uniqueResult();
7129    
7130                            return count.intValue();
7131                    }
7132                    catch (Exception e) {
7133                            throw processException(e);
7134                    }
7135                    finally {
7136                            closeSession(session);
7137                    }
7138            }
7139    
7140            /**
7141             * Returns the number of document library file entries where companyId = &#63;.
7142             *
7143             * @param companyId the company ID
7144             * @return the number of matching document library file entries
7145             * @throws SystemException if a system exception occurred
7146             */
7147            public int countByCompanyId(long companyId) throws SystemException {
7148                    Object[] finderArgs = new Object[] { companyId };
7149    
7150                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
7151                                    finderArgs, this);
7152    
7153                    if (count == null) {
7154                            StringBundler query = new StringBundler(2);
7155    
7156                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7157    
7158                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
7159    
7160                            String sql = query.toString();
7161    
7162                            Session session = null;
7163    
7164                            try {
7165                                    session = openSession();
7166    
7167                                    Query q = session.createQuery(sql);
7168    
7169                                    QueryPos qPos = QueryPos.getInstance(q);
7170    
7171                                    qPos.add(companyId);
7172    
7173                                    count = (Long)q.uniqueResult();
7174                            }
7175                            catch (Exception e) {
7176                                    throw processException(e);
7177                            }
7178                            finally {
7179                                    if (count == null) {
7180                                            count = Long.valueOf(0);
7181                                    }
7182    
7183                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
7184                                            finderArgs, count);
7185    
7186                                    closeSession(session);
7187                            }
7188                    }
7189    
7190                    return count.intValue();
7191            }
7192    
7193            /**
7194             * Returns the number of document library file entries where groupId = &#63; and userId = &#63;.
7195             *
7196             * @param groupId the group ID
7197             * @param userId the user ID
7198             * @return the number of matching document library file entries
7199             * @throws SystemException if a system exception occurred
7200             */
7201            public int countByG_U(long groupId, long userId) throws SystemException {
7202                    Object[] finderArgs = new Object[] { groupId, userId };
7203    
7204                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
7205                                    finderArgs, this);
7206    
7207                    if (count == null) {
7208                            StringBundler query = new StringBundler(3);
7209    
7210                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7211    
7212                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7213    
7214                            query.append(_FINDER_COLUMN_G_U_USERID_2);
7215    
7216                            String sql = query.toString();
7217    
7218                            Session session = null;
7219    
7220                            try {
7221                                    session = openSession();
7222    
7223                                    Query q = session.createQuery(sql);
7224    
7225                                    QueryPos qPos = QueryPos.getInstance(q);
7226    
7227                                    qPos.add(groupId);
7228    
7229                                    qPos.add(userId);
7230    
7231                                    count = (Long)q.uniqueResult();
7232                            }
7233                            catch (Exception e) {
7234                                    throw processException(e);
7235                            }
7236                            finally {
7237                                    if (count == null) {
7238                                            count = Long.valueOf(0);
7239                                    }
7240    
7241                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
7242                                            count);
7243    
7244                                    closeSession(session);
7245                            }
7246                    }
7247    
7248                    return count.intValue();
7249            }
7250    
7251            /**
7252             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63;.
7253             *
7254             * @param groupId the group ID
7255             * @param userId the user ID
7256             * @return the number of matching document library file entries that the user has permission to view
7257             * @throws SystemException if a system exception occurred
7258             */
7259            public int filterCountByG_U(long groupId, long userId)
7260                    throws SystemException {
7261                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7262                            return countByG_U(groupId, userId);
7263                    }
7264    
7265                    StringBundler query = new StringBundler(3);
7266    
7267                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7268    
7269                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
7270    
7271                    query.append(_FINDER_COLUMN_G_U_USERID_2);
7272    
7273                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7274                                    DLFileEntry.class.getName(),
7275                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7276    
7277                    Session session = null;
7278    
7279                    try {
7280                            session = openSession();
7281    
7282                            SQLQuery q = session.createSQLQuery(sql);
7283    
7284                            q.addScalar(COUNT_COLUMN_NAME,
7285                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7286    
7287                            QueryPos qPos = QueryPos.getInstance(q);
7288    
7289                            qPos.add(groupId);
7290    
7291                            qPos.add(userId);
7292    
7293                            Long count = (Long)q.uniqueResult();
7294    
7295                            return count.intValue();
7296                    }
7297                    catch (Exception e) {
7298                            throw processException(e);
7299                    }
7300                    finally {
7301                            closeSession(session);
7302                    }
7303            }
7304    
7305            /**
7306             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63;.
7307             *
7308             * @param groupId the group ID
7309             * @param folderId the folder ID
7310             * @return the number of matching document library file entries
7311             * @throws SystemException if a system exception occurred
7312             */
7313            public int countByG_F(long groupId, long folderId)
7314                    throws SystemException {
7315                    Object[] finderArgs = new Object[] { groupId, folderId };
7316    
7317                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
7318                                    finderArgs, this);
7319    
7320                    if (count == null) {
7321                            StringBundler query = new StringBundler(3);
7322    
7323                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7324    
7325                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7326    
7327                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7328    
7329                            String sql = query.toString();
7330    
7331                            Session session = null;
7332    
7333                            try {
7334                                    session = openSession();
7335    
7336                                    Query q = session.createQuery(sql);
7337    
7338                                    QueryPos qPos = QueryPos.getInstance(q);
7339    
7340                                    qPos.add(groupId);
7341    
7342                                    qPos.add(folderId);
7343    
7344                                    count = (Long)q.uniqueResult();
7345                            }
7346                            catch (Exception e) {
7347                                    throw processException(e);
7348                            }
7349                            finally {
7350                                    if (count == null) {
7351                                            count = Long.valueOf(0);
7352                                    }
7353    
7354                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
7355                                            count);
7356    
7357                                    closeSession(session);
7358                            }
7359                    }
7360    
7361                    return count.intValue();
7362            }
7363    
7364            /**
7365             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63;.
7366             *
7367             * @param groupId the group ID
7368             * @param folderIds the folder IDs
7369             * @return the number of matching document library file entries
7370             * @throws SystemException if a system exception occurred
7371             */
7372            public int countByG_F(long groupId, long[] folderIds)
7373                    throws SystemException {
7374                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
7375    
7376                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
7377                                    finderArgs, this);
7378    
7379                    if (count == null) {
7380                            StringBundler query = new StringBundler();
7381    
7382                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7383    
7384                            boolean conjunctionable = false;
7385    
7386                            if (conjunctionable) {
7387                                    query.append(WHERE_AND);
7388                            }
7389    
7390                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7391    
7392                            conjunctionable = true;
7393    
7394                            if ((folderIds == null) || (folderIds.length > 0)) {
7395                                    if (conjunctionable) {
7396                                            query.append(WHERE_AND);
7397                                    }
7398    
7399                                    query.append(StringPool.OPEN_PARENTHESIS);
7400    
7401                                    for (int i = 0; i < folderIds.length; i++) {
7402                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7403    
7404                                            if ((i + 1) < folderIds.length) {
7405                                                    query.append(WHERE_OR);
7406                                            }
7407                                    }
7408    
7409                                    query.append(StringPool.CLOSE_PARENTHESIS);
7410    
7411                                    conjunctionable = true;
7412                            }
7413    
7414                            String sql = query.toString();
7415    
7416                            Session session = null;
7417    
7418                            try {
7419                                    session = openSession();
7420    
7421                                    Query q = session.createQuery(sql);
7422    
7423                                    QueryPos qPos = QueryPos.getInstance(q);
7424    
7425                                    qPos.add(groupId);
7426    
7427                                    if (folderIds != null) {
7428                                            qPos.add(folderIds);
7429                                    }
7430    
7431                                    count = (Long)q.uniqueResult();
7432                            }
7433                            catch (Exception e) {
7434                                    throw processException(e);
7435                            }
7436                            finally {
7437                                    if (count == null) {
7438                                            count = Long.valueOf(0);
7439                                    }
7440    
7441                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
7442                                            count);
7443    
7444                                    closeSession(session);
7445                            }
7446                    }
7447    
7448                    return count.intValue();
7449            }
7450    
7451            /**
7452             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
7453             *
7454             * @param groupId the group ID
7455             * @param folderId the folder ID
7456             * @return the number of matching document library file entries that the user has permission to view
7457             * @throws SystemException if a system exception occurred
7458             */
7459            public int filterCountByG_F(long groupId, long folderId)
7460                    throws SystemException {
7461                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7462                            return countByG_F(groupId, folderId);
7463                    }
7464    
7465                    StringBundler query = new StringBundler(3);
7466    
7467                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7468    
7469                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
7470    
7471                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
7472    
7473                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7474                                    DLFileEntry.class.getName(),
7475                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7476    
7477                    Session session = null;
7478    
7479                    try {
7480                            session = openSession();
7481    
7482                            SQLQuery q = session.createSQLQuery(sql);
7483    
7484                            q.addScalar(COUNT_COLUMN_NAME,
7485                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7486    
7487                            QueryPos qPos = QueryPos.getInstance(q);
7488    
7489                            qPos.add(groupId);
7490    
7491                            qPos.add(folderId);
7492    
7493                            Long count = (Long)q.uniqueResult();
7494    
7495                            return count.intValue();
7496                    }
7497                    catch (Exception e) {
7498                            throw processException(e);
7499                    }
7500                    finally {
7501                            closeSession(session);
7502                    }
7503            }
7504    
7505            /**
7506             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
7507             *
7508             * @param groupId the group ID
7509             * @param folderIds the folder IDs
7510             * @return the number of matching document library file entries that the user has permission to view
7511             * @throws SystemException if a system exception occurred
7512             */
7513            public int filterCountByG_F(long groupId, long[] folderIds)
7514                    throws SystemException {
7515                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7516                            return countByG_F(groupId, folderIds);
7517                    }
7518    
7519                    StringBundler query = new StringBundler();
7520    
7521                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7522    
7523                    boolean conjunctionable = false;
7524    
7525                    if (conjunctionable) {
7526                            query.append(WHERE_AND);
7527                    }
7528    
7529                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
7530    
7531                    conjunctionable = true;
7532    
7533                    if ((folderIds == null) || (folderIds.length > 0)) {
7534                            if (conjunctionable) {
7535                                    query.append(WHERE_AND);
7536                            }
7537    
7538                            query.append(StringPool.OPEN_PARENTHESIS);
7539    
7540                            for (int i = 0; i < folderIds.length; i++) {
7541                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
7542    
7543                                    if ((i + 1) < folderIds.length) {
7544                                            query.append(WHERE_OR);
7545                                    }
7546                            }
7547    
7548                            query.append(StringPool.CLOSE_PARENTHESIS);
7549    
7550                            conjunctionable = true;
7551                    }
7552    
7553                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7554                                    DLFileEntry.class.getName(),
7555                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7556    
7557                    Session session = null;
7558    
7559                    try {
7560                            session = openSession();
7561    
7562                            SQLQuery q = session.createSQLQuery(sql);
7563    
7564                            q.addScalar(COUNT_COLUMN_NAME,
7565                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7566    
7567                            QueryPos qPos = QueryPos.getInstance(q);
7568    
7569                            qPos.add(groupId);
7570    
7571                            if (folderIds != null) {
7572                                    qPos.add(folderIds);
7573                            }
7574    
7575                            Long count = (Long)q.uniqueResult();
7576    
7577                            return count.intValue();
7578                    }
7579                    catch (Exception e) {
7580                            throw processException(e);
7581                    }
7582                    finally {
7583                            closeSession(session);
7584                    }
7585            }
7586    
7587            /**
7588             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = &#63;.
7589             *
7590             * @param groupId the group ID
7591             * @param userId the user ID
7592             * @param folderId the folder ID
7593             * @return the number of matching document library file entries
7594             * @throws SystemException if a system exception occurred
7595             */
7596            public int countByG_U_F(long groupId, long userId, long folderId)
7597                    throws SystemException {
7598                    Object[] finderArgs = new Object[] { groupId, userId, folderId };
7599    
7600                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_F,
7601                                    finderArgs, this);
7602    
7603                    if (count == null) {
7604                            StringBundler query = new StringBundler(4);
7605    
7606                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7607    
7608                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7609    
7610                            query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7611    
7612                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7613    
7614                            String sql = query.toString();
7615    
7616                            Session session = null;
7617    
7618                            try {
7619                                    session = openSession();
7620    
7621                                    Query q = session.createQuery(sql);
7622    
7623                                    QueryPos qPos = QueryPos.getInstance(q);
7624    
7625                                    qPos.add(groupId);
7626    
7627                                    qPos.add(userId);
7628    
7629                                    qPos.add(folderId);
7630    
7631                                    count = (Long)q.uniqueResult();
7632                            }
7633                            catch (Exception e) {
7634                                    throw processException(e);
7635                            }
7636                            finally {
7637                                    if (count == null) {
7638                                            count = Long.valueOf(0);
7639                                    }
7640    
7641                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_F,
7642                                            finderArgs, count);
7643    
7644                                    closeSession(session);
7645                            }
7646                    }
7647    
7648                    return count.intValue();
7649            }
7650    
7651            /**
7652             * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
7653             *
7654             * @param groupId the group ID
7655             * @param userId the user ID
7656             * @param folderIds the folder IDs
7657             * @return the number of matching document library file entries
7658             * @throws SystemException if a system exception occurred
7659             */
7660            public int countByG_U_F(long groupId, long userId, long[] folderIds)
7661                    throws SystemException {
7662                    Object[] finderArgs = new Object[] {
7663                                    groupId, userId, StringUtil.merge(folderIds)
7664                            };
7665    
7666                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_F,
7667                                    finderArgs, this);
7668    
7669                    if (count == null) {
7670                            StringBundler query = new StringBundler();
7671    
7672                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7673    
7674                            boolean conjunctionable = false;
7675    
7676                            if (conjunctionable) {
7677                                    query.append(WHERE_AND);
7678                            }
7679    
7680                            query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
7681    
7682                            conjunctionable = true;
7683    
7684                            if (conjunctionable) {
7685                                    query.append(WHERE_AND);
7686                            }
7687    
7688                            query.append(_FINDER_COLUMN_G_U_F_USERID_5);
7689    
7690                            conjunctionable = true;
7691    
7692                            if ((folderIds == null) || (folderIds.length > 0)) {
7693                                    if (conjunctionable) {
7694                                            query.append(WHERE_AND);
7695                                    }
7696    
7697                                    query.append(StringPool.OPEN_PARENTHESIS);
7698    
7699                                    for (int i = 0; i < folderIds.length; i++) {
7700                                            query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
7701    
7702                                            if ((i + 1) < folderIds.length) {
7703                                                    query.append(WHERE_OR);
7704                                            }
7705                                    }
7706    
7707                                    query.append(StringPool.CLOSE_PARENTHESIS);
7708    
7709                                    conjunctionable = true;
7710                            }
7711    
7712                            String sql = query.toString();
7713    
7714                            Session session = null;
7715    
7716                            try {
7717                                    session = openSession();
7718    
7719                                    Query q = session.createQuery(sql);
7720    
7721                                    QueryPos qPos = QueryPos.getInstance(q);
7722    
7723                                    qPos.add(groupId);
7724    
7725                                    qPos.add(userId);
7726    
7727                                    if (folderIds != null) {
7728                                            qPos.add(folderIds);
7729                                    }
7730    
7731                                    count = (Long)q.uniqueResult();
7732                            }
7733                            catch (Exception e) {
7734                                    throw processException(e);
7735                            }
7736                            finally {
7737                                    if (count == null) {
7738                                            count = Long.valueOf(0);
7739                                    }
7740    
7741                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_F,
7742                                            finderArgs, count);
7743    
7744                                    closeSession(session);
7745                            }
7746                    }
7747    
7748                    return count.intValue();
7749            }
7750    
7751            /**
7752             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63;.
7753             *
7754             * @param groupId the group ID
7755             * @param userId the user ID
7756             * @param folderId the folder ID
7757             * @return the number of matching document library file entries that the user has permission to view
7758             * @throws SystemException if a system exception occurred
7759             */
7760            public int filterCountByG_U_F(long groupId, long userId, long folderId)
7761                    throws SystemException {
7762                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7763                            return countByG_U_F(groupId, userId, folderId);
7764                    }
7765    
7766                    StringBundler query = new StringBundler(4);
7767    
7768                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7769    
7770                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_2);
7771    
7772                    query.append(_FINDER_COLUMN_G_U_F_USERID_2);
7773    
7774                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_2);
7775    
7776                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7777                                    DLFileEntry.class.getName(),
7778                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7779    
7780                    Session session = null;
7781    
7782                    try {
7783                            session = openSession();
7784    
7785                            SQLQuery q = session.createSQLQuery(sql);
7786    
7787                            q.addScalar(COUNT_COLUMN_NAME,
7788                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7789    
7790                            QueryPos qPos = QueryPos.getInstance(q);
7791    
7792                            qPos.add(groupId);
7793    
7794                            qPos.add(userId);
7795    
7796                            qPos.add(folderId);
7797    
7798                            Long count = (Long)q.uniqueResult();
7799    
7800                            return count.intValue();
7801                    }
7802                    catch (Exception e) {
7803                            throw processException(e);
7804                    }
7805                    finally {
7806                            closeSession(session);
7807                    }
7808            }
7809    
7810            /**
7811             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
7812             *
7813             * @param groupId the group ID
7814             * @param userId the user ID
7815             * @param folderIds the folder IDs
7816             * @return the number of matching document library file entries that the user has permission to view
7817             * @throws SystemException if a system exception occurred
7818             */
7819            public int filterCountByG_U_F(long groupId, long userId, long[] folderIds)
7820                    throws SystemException {
7821                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7822                            return countByG_U_F(groupId, userId, folderIds);
7823                    }
7824    
7825                    StringBundler query = new StringBundler();
7826    
7827                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
7828    
7829                    boolean conjunctionable = false;
7830    
7831                    if (conjunctionable) {
7832                            query.append(WHERE_AND);
7833                    }
7834    
7835                    query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);
7836    
7837                    conjunctionable = true;
7838    
7839                    if (conjunctionable) {
7840                            query.append(WHERE_AND);
7841                    }
7842    
7843                    query.append(_FINDER_COLUMN_G_U_F_USERID_5);
7844    
7845                    conjunctionable = true;
7846    
7847                    if ((folderIds == null) || (folderIds.length > 0)) {
7848                            if (conjunctionable) {
7849                                    query.append(WHERE_AND);
7850                            }
7851    
7852                            query.append(StringPool.OPEN_PARENTHESIS);
7853    
7854                            for (int i = 0; i < folderIds.length; i++) {
7855                                    query.append(_FINDER_COLUMN_G_U_F_FOLDERID_5);
7856    
7857                                    if ((i + 1) < folderIds.length) {
7858                                            query.append(WHERE_OR);
7859                                    }
7860                            }
7861    
7862                            query.append(StringPool.CLOSE_PARENTHESIS);
7863    
7864                            conjunctionable = true;
7865                    }
7866    
7867                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7868                                    DLFileEntry.class.getName(),
7869                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7870    
7871                    Session session = null;
7872    
7873                    try {
7874                            session = openSession();
7875    
7876                            SQLQuery q = session.createSQLQuery(sql);
7877    
7878                            q.addScalar(COUNT_COLUMN_NAME,
7879                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7880    
7881                            QueryPos qPos = QueryPos.getInstance(q);
7882    
7883                            qPos.add(groupId);
7884    
7885                            qPos.add(userId);
7886    
7887                            if (folderIds != null) {
7888                                    qPos.add(folderIds);
7889                            }
7890    
7891                            Long count = (Long)q.uniqueResult();
7892    
7893                            return count.intValue();
7894                    }
7895                    catch (Exception e) {
7896                            throw processException(e);
7897                    }
7898                    finally {
7899                            closeSession(session);
7900                    }
7901            }
7902    
7903            /**
7904             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and name = &#63;.
7905             *
7906             * @param groupId the group ID
7907             * @param folderId the folder ID
7908             * @param name the name
7909             * @return the number of matching document library file entries
7910             * @throws SystemException if a system exception occurred
7911             */
7912            public int countByG_F_N(long groupId, long folderId, String name)
7913                    throws SystemException {
7914                    Object[] finderArgs = new Object[] { groupId, folderId, name };
7915    
7916                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_N,
7917                                    finderArgs, this);
7918    
7919                    if (count == null) {
7920                            StringBundler query = new StringBundler(4);
7921    
7922                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7923    
7924                            query.append(_FINDER_COLUMN_G_F_N_GROUPID_2);
7925    
7926                            query.append(_FINDER_COLUMN_G_F_N_FOLDERID_2);
7927    
7928                            if (name == null) {
7929                                    query.append(_FINDER_COLUMN_G_F_N_NAME_1);
7930                            }
7931                            else {
7932                                    if (name.equals(StringPool.BLANK)) {
7933                                            query.append(_FINDER_COLUMN_G_F_N_NAME_3);
7934                                    }
7935                                    else {
7936                                            query.append(_FINDER_COLUMN_G_F_N_NAME_2);
7937                                    }
7938                            }
7939    
7940                            String sql = query.toString();
7941    
7942                            Session session = null;
7943    
7944                            try {
7945                                    session = openSession();
7946    
7947                                    Query q = session.createQuery(sql);
7948    
7949                                    QueryPos qPos = QueryPos.getInstance(q);
7950    
7951                                    qPos.add(groupId);
7952    
7953                                    qPos.add(folderId);
7954    
7955                                    if (name != null) {
7956                                            qPos.add(name);
7957                                    }
7958    
7959                                    count = (Long)q.uniqueResult();
7960                            }
7961                            catch (Exception e) {
7962                                    throw processException(e);
7963                            }
7964                            finally {
7965                                    if (count == null) {
7966                                            count = Long.valueOf(0);
7967                                    }
7968    
7969                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_N,
7970                                            finderArgs, count);
7971    
7972                                    closeSession(session);
7973                            }
7974                    }
7975    
7976                    return count.intValue();
7977            }
7978    
7979            /**
7980             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and title = &#63;.
7981             *
7982             * @param groupId the group ID
7983             * @param folderId the folder ID
7984             * @param title the title
7985             * @return the number of matching document library file entries
7986             * @throws SystemException if a system exception occurred
7987             */
7988            public int countByG_F_T(long groupId, long folderId, String title)
7989                    throws SystemException {
7990                    Object[] finderArgs = new Object[] { groupId, folderId, title };
7991    
7992                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_T,
7993                                    finderArgs, this);
7994    
7995                    if (count == null) {
7996                            StringBundler query = new StringBundler(4);
7997    
7998                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
7999    
8000                            query.append(_FINDER_COLUMN_G_F_T_GROUPID_2);
8001    
8002                            query.append(_FINDER_COLUMN_G_F_T_FOLDERID_2);
8003    
8004                            if (title == null) {
8005                                    query.append(_FINDER_COLUMN_G_F_T_TITLE_1);
8006                            }
8007                            else {
8008                                    if (title.equals(StringPool.BLANK)) {
8009                                            query.append(_FINDER_COLUMN_G_F_T_TITLE_3);
8010                                    }
8011                                    else {
8012                                            query.append(_FINDER_COLUMN_G_F_T_TITLE_2);
8013                                    }
8014                            }
8015    
8016                            String sql = query.toString();
8017    
8018                            Session session = null;
8019    
8020                            try {
8021                                    session = openSession();
8022    
8023                                    Query q = session.createQuery(sql);
8024    
8025                                    QueryPos qPos = QueryPos.getInstance(q);
8026    
8027                                    qPos.add(groupId);
8028    
8029                                    qPos.add(folderId);
8030    
8031                                    if (title != null) {
8032                                            qPos.add(title);
8033                                    }
8034    
8035                                    count = (Long)q.uniqueResult();
8036                            }
8037                            catch (Exception e) {
8038                                    throw processException(e);
8039                            }
8040                            finally {
8041                                    if (count == null) {
8042                                            count = Long.valueOf(0);
8043                                    }
8044    
8045                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_T,
8046                                            finderArgs, count);
8047    
8048                                    closeSession(session);
8049                            }
8050                    }
8051    
8052                    return count.intValue();
8053            }
8054    
8055            /**
8056             * Returns the number of document library file entries where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
8057             *
8058             * @param groupId the group ID
8059             * @param folderId the folder ID
8060             * @param fileEntryTypeId the file entry type ID
8061             * @return the number of matching document library file entries
8062             * @throws SystemException if a system exception occurred
8063             */
8064            public int countByG_F_F(long groupId, long folderId, long fileEntryTypeId)
8065                    throws SystemException {
8066                    Object[] finderArgs = new Object[] { groupId, folderId, fileEntryTypeId };
8067    
8068                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_F,
8069                                    finderArgs, this);
8070    
8071                    if (count == null) {
8072                            StringBundler query = new StringBundler(4);
8073    
8074                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8075    
8076                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
8077    
8078                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
8079    
8080                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
8081    
8082                            String sql = query.toString();
8083    
8084                            Session session = null;
8085    
8086                            try {
8087                                    session = openSession();
8088    
8089                                    Query q = session.createQuery(sql);
8090    
8091                                    QueryPos qPos = QueryPos.getInstance(q);
8092    
8093                                    qPos.add(groupId);
8094    
8095                                    qPos.add(folderId);
8096    
8097                                    qPos.add(fileEntryTypeId);
8098    
8099                                    count = (Long)q.uniqueResult();
8100                            }
8101                            catch (Exception e) {
8102                                    throw processException(e);
8103                            }
8104                            finally {
8105                                    if (count == null) {
8106                                            count = Long.valueOf(0);
8107                                    }
8108    
8109                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_F,
8110                                            finderArgs, count);
8111    
8112                                    closeSession(session);
8113                            }
8114                    }
8115    
8116                    return count.intValue();
8117            }
8118    
8119            /**
8120             * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
8121             *
8122             * @param groupId the group ID
8123             * @param folderIds the folder IDs
8124             * @param fileEntryTypeId the file entry type ID
8125             * @return the number of matching document library file entries
8126             * @throws SystemException if a system exception occurred
8127             */
8128            public int countByG_F_F(long groupId, long[] folderIds, long fileEntryTypeId)
8129                    throws SystemException {
8130                    Object[] finderArgs = new Object[] {
8131                                    groupId, StringUtil.merge(folderIds), fileEntryTypeId
8132                            };
8133    
8134                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_F,
8135                                    finderArgs, this);
8136    
8137                    if (count == null) {
8138                            StringBundler query = new StringBundler();
8139    
8140                            query.append(_SQL_COUNT_DLFILEENTRY_WHERE);
8141    
8142                            boolean conjunctionable = false;
8143    
8144                            if (conjunctionable) {
8145                                    query.append(WHERE_AND);
8146                            }
8147    
8148                            query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
8149    
8150                            conjunctionable = true;
8151    
8152                            if ((folderIds == null) || (folderIds.length > 0)) {
8153                                    if (conjunctionable) {
8154                                            query.append(WHERE_AND);
8155                                    }
8156    
8157                                    query.append(StringPool.OPEN_PARENTHESIS);
8158    
8159                                    for (int i = 0; i < folderIds.length; i++) {
8160                                            query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
8161    
8162                                            if ((i + 1) < folderIds.length) {
8163                                                    query.append(WHERE_OR);
8164                                            }
8165                                    }
8166    
8167                                    query.append(StringPool.CLOSE_PARENTHESIS);
8168    
8169                                    conjunctionable = true;
8170                            }
8171    
8172                            if (conjunctionable) {
8173                                    query.append(WHERE_AND);
8174                            }
8175    
8176                            query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
8177    
8178                            conjunctionable = true;
8179    
8180                            String sql = query.toString();
8181    
8182                            Session session = null;
8183    
8184                            try {
8185                                    session = openSession();
8186    
8187                                    Query q = session.createQuery(sql);
8188    
8189                                    QueryPos qPos = QueryPos.getInstance(q);
8190    
8191                                    qPos.add(groupId);
8192    
8193                                    if (folderIds != null) {
8194                                            qPos.add(folderIds);
8195                                    }
8196    
8197                                    qPos.add(fileEntryTypeId);
8198    
8199                                    count = (Long)q.uniqueResult();
8200                            }
8201                            catch (Exception e) {
8202                                    throw processException(e);
8203                            }
8204                            finally {
8205                                    if (count == null) {
8206                                            count = Long.valueOf(0);
8207                                    }
8208    
8209                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_F,
8210                                            finderArgs, count);
8211    
8212                                    closeSession(session);
8213                            }
8214                    }
8215    
8216                    return count.intValue();
8217            }
8218    
8219            /**
8220             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = &#63; and fileEntryTypeId = &#63;.
8221             *
8222             * @param groupId the group ID
8223             * @param folderId the folder ID
8224             * @param fileEntryTypeId the file entry type ID
8225             * @return the number of matching document library file entries that the user has permission to view
8226             * @throws SystemException if a system exception occurred
8227             */
8228            public int filterCountByG_F_F(long groupId, long folderId,
8229                    long fileEntryTypeId) throws SystemException {
8230                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8231                            return countByG_F_F(groupId, folderId, fileEntryTypeId);
8232                    }
8233    
8234                    StringBundler query = new StringBundler(4);
8235    
8236                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
8237    
8238                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_2);
8239    
8240                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_2);
8241    
8242                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2);
8243    
8244                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8245                                    DLFileEntry.class.getName(),
8246                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8247    
8248                    Session session = null;
8249    
8250                    try {
8251                            session = openSession();
8252    
8253                            SQLQuery q = session.createSQLQuery(sql);
8254    
8255                            q.addScalar(COUNT_COLUMN_NAME,
8256                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8257    
8258                            QueryPos qPos = QueryPos.getInstance(q);
8259    
8260                            qPos.add(groupId);
8261    
8262                            qPos.add(folderId);
8263    
8264                            qPos.add(fileEntryTypeId);
8265    
8266                            Long count = (Long)q.uniqueResult();
8267    
8268                            return count.intValue();
8269                    }
8270                    catch (Exception e) {
8271                            throw processException(e);
8272                    }
8273                    finally {
8274                            closeSession(session);
8275                    }
8276            }
8277    
8278            /**
8279             * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
8280             *
8281             * @param groupId the group ID
8282             * @param folderIds the folder IDs
8283             * @param fileEntryTypeId the file entry type ID
8284             * @return the number of matching document library file entries that the user has permission to view
8285             * @throws SystemException if a system exception occurred
8286             */
8287            public int filterCountByG_F_F(long groupId, long[] folderIds,
8288                    long fileEntryTypeId) throws SystemException {
8289                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8290                            return countByG_F_F(groupId, folderIds, fileEntryTypeId);
8291                    }
8292    
8293                    StringBundler query = new StringBundler();
8294    
8295                    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);
8296    
8297                    boolean conjunctionable = false;
8298    
8299                    if (conjunctionable) {
8300                            query.append(WHERE_AND);
8301                    }
8302    
8303                    query.append(_FINDER_COLUMN_G_F_F_GROUPID_5);
8304    
8305                    conjunctionable = true;
8306    
8307                    if ((folderIds == null) || (folderIds.length > 0)) {
8308                            if (conjunctionable) {
8309                                    query.append(WHERE_AND);
8310                            }
8311    
8312                            query.append(StringPool.OPEN_PARENTHESIS);
8313    
8314                            for (int i = 0; i < folderIds.length; i++) {
8315                                    query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5);
8316    
8317                                    if ((i + 1) < folderIds.length) {
8318                                            query.append(WHERE_OR);
8319                                    }
8320                            }
8321    
8322                            query.append(StringPool.CLOSE_PARENTHESIS);
8323    
8324                            conjunctionable = true;
8325                    }
8326    
8327                    if (conjunctionable) {
8328                            query.append(WHERE_AND);
8329                    }
8330    
8331                    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);
8332    
8333                    conjunctionable = true;
8334    
8335                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8336                                    DLFileEntry.class.getName(),
8337                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8338    
8339                    Session session = null;
8340    
8341                    try {
8342                            session = openSession();
8343    
8344                            SQLQuery q = session.createSQLQuery(sql);
8345    
8346                            q.addScalar(COUNT_COLUMN_NAME,
8347                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8348    
8349                            QueryPos qPos = QueryPos.getInstance(q);
8350    
8351                            qPos.add(groupId);
8352    
8353                            if (folderIds != null) {
8354                                    qPos.add(folderIds);
8355                            }
8356    
8357                            qPos.add(fileEntryTypeId);
8358    
8359                            Long count = (Long)q.uniqueResult();
8360    
8361                            return count.intValue();
8362                    }
8363                    catch (Exception e) {
8364                            throw processException(e);
8365                    }
8366                    finally {
8367                            closeSession(session);
8368                    }
8369            }
8370    
8371            /**
8372             * Returns the number of document library file entries.
8373             *
8374             * @return the number of document library file entries
8375             * @throws SystemException if a system exception occurred
8376             */
8377            public int countAll() throws SystemException {
8378                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
8379                                    FINDER_ARGS_EMPTY, this);
8380    
8381                    if (count == null) {
8382                            Session session = null;
8383    
8384                            try {
8385                                    session = openSession();
8386    
8387                                    Query q = session.createQuery(_SQL_COUNT_DLFILEENTRY);
8388    
8389                                    count = (Long)q.uniqueResult();
8390                            }
8391                            catch (Exception e) {
8392                                    throw processException(e);
8393                            }
8394                            finally {
8395                                    if (count == null) {
8396                                            count = Long.valueOf(0);
8397                                    }
8398    
8399                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
8400                                            FINDER_ARGS_EMPTY, count);
8401    
8402                                    closeSession(session);
8403                            }
8404                    }
8405    
8406                    return count.intValue();
8407            }
8408    
8409            /**
8410             * Initializes the document library file entry persistence.
8411             */
8412            public void afterPropertiesSet() {
8413                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
8414                                            com.liferay.portal.util.PropsUtil.get(
8415                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry")));
8416    
8417                    if (listenerClassNames.length > 0) {
8418                            try {
8419                                    List<ModelListener<DLFileEntry>> listenersList = new ArrayList<ModelListener<DLFileEntry>>();
8420    
8421                                    for (String listenerClassName : listenerClassNames) {
8422                                            listenersList.add((ModelListener<DLFileEntry>)InstanceFactory.newInstance(
8423                                                            listenerClassName));
8424                                    }
8425    
8426                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
8427                            }
8428                            catch (Exception e) {
8429                                    _log.error(e);
8430                            }
8431                    }
8432            }
8433    
8434            public void destroy() {
8435                    EntityCacheUtil.removeCache(DLFileEntryImpl.class.getName());
8436                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
8437                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8438            }
8439    
8440            @BeanReference(type = DLContentPersistence.class)
8441            protected DLContentPersistence dlContentPersistence;
8442            @BeanReference(type = DLFileEntryPersistence.class)
8443            protected DLFileEntryPersistence dlFileEntryPersistence;
8444            @BeanReference(type = DLFileEntryMetadataPersistence.class)
8445            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
8446            @BeanReference(type = DLFileEntryTypePersistence.class)
8447            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
8448            @BeanReference(type = DLFileRankPersistence.class)
8449            protected DLFileRankPersistence dlFileRankPersistence;
8450            @BeanReference(type = DLFileShortcutPersistence.class)
8451            protected DLFileShortcutPersistence dlFileShortcutPersistence;
8452            @BeanReference(type = DLFileVersionPersistence.class)
8453            protected DLFileVersionPersistence dlFileVersionPersistence;
8454            @BeanReference(type = DLFolderPersistence.class)
8455            protected DLFolderPersistence dlFolderPersistence;
8456            @BeanReference(type = DLSyncPersistence.class)
8457            protected DLSyncPersistence dlSyncPersistence;
8458            @BeanReference(type = ImagePersistence.class)
8459            protected ImagePersistence imagePersistence;
8460            @BeanReference(type = LockPersistence.class)
8461            protected LockPersistence lockPersistence;
8462            @BeanReference(type = ResourcePersistence.class)
8463            protected ResourcePersistence resourcePersistence;
8464            @BeanReference(type = UserPersistence.class)
8465            protected UserPersistence userPersistence;
8466            @BeanReference(type = WebDAVPropsPersistence.class)
8467            protected WebDAVPropsPersistence webDAVPropsPersistence;
8468            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
8469            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
8470            @BeanReference(type = AssetCategoryPersistence.class)
8471            protected AssetCategoryPersistence assetCategoryPersistence;
8472            @BeanReference(type = AssetEntryPersistence.class)
8473            protected AssetEntryPersistence assetEntryPersistence;
8474            @BeanReference(type = AssetLinkPersistence.class)
8475            protected AssetLinkPersistence assetLinkPersistence;
8476            @BeanReference(type = AssetTagPersistence.class)
8477            protected AssetTagPersistence assetTagPersistence;
8478            @BeanReference(type = DDMStructurePersistence.class)
8479            protected DDMStructurePersistence ddmStructurePersistence;
8480            @BeanReference(type = ExpandoValuePersistence.class)
8481            protected ExpandoValuePersistence expandoValuePersistence;
8482            private static final String _SQL_SELECT_DLFILEENTRY = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry";
8483            private static final String _SQL_SELECT_DLFILEENTRY_WHERE = "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ";
8484            private static final String _SQL_COUNT_DLFILEENTRY = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry";
8485            private static final String _SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry WHERE ";
8486            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntry.uuid IS NULL";
8487            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntry.uuid = ?";
8488            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = ?)";
8489            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntry.uuid IS NULL AND ";
8490            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntry.uuid = ? AND ";
8491            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntry.uuid IS NULL OR dlFileEntry.uuid = ?) AND ";
8492            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntry.groupId = ?";
8493            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntry.groupId = ?";
8494            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "dlFileEntry.companyId = ?";
8495            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8496            private static final String _FINDER_COLUMN_G_U_USERID_2 = "dlFileEntry.userId = ?";
8497            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8498            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
8499                    _removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
8500            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
8501            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
8502                    _removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
8503            private static final String _FINDER_COLUMN_G_U_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8504            private static final String _FINDER_COLUMN_G_U_F_GROUPID_5 = "(" +
8505                    _removeConjunction(_FINDER_COLUMN_G_U_F_GROUPID_2) + ")";
8506            private static final String _FINDER_COLUMN_G_U_F_USERID_2 = "dlFileEntry.userId = ? AND ";
8507            private static final String _FINDER_COLUMN_G_U_F_USERID_5 = "(" +
8508                    _removeConjunction(_FINDER_COLUMN_G_U_F_USERID_2) + ")";
8509            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_2 = "dlFileEntry.folderId = ?";
8510            private static final String _FINDER_COLUMN_G_U_F_FOLDERID_5 = "(" +
8511                    _removeConjunction(_FINDER_COLUMN_G_U_F_FOLDERID_2) + ")";
8512            private static final String _FINDER_COLUMN_G_F_N_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8513            private static final String _FINDER_COLUMN_G_F_N_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
8514            private static final String _FINDER_COLUMN_G_F_N_NAME_1 = "dlFileEntry.name IS NULL";
8515            private static final String _FINDER_COLUMN_G_F_N_NAME_2 = "dlFileEntry.name = ?";
8516            private static final String _FINDER_COLUMN_G_F_N_NAME_3 = "(dlFileEntry.name IS NULL OR dlFileEntry.name = ?)";
8517            private static final String _FINDER_COLUMN_G_F_T_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8518            private static final String _FINDER_COLUMN_G_F_T_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
8519            private static final String _FINDER_COLUMN_G_F_T_TITLE_1 = "dlFileEntry.title IS NULL";
8520            private static final String _FINDER_COLUMN_G_F_T_TITLE_2 = "dlFileEntry.title = ?";
8521            private static final String _FINDER_COLUMN_G_F_T_TITLE_3 = "(dlFileEntry.title IS NULL OR dlFileEntry.title = ?)";
8522            private static final String _FINDER_COLUMN_G_F_F_GROUPID_2 = "dlFileEntry.groupId = ? AND ";
8523            private static final String _FINDER_COLUMN_G_F_F_GROUPID_5 = "(" +
8524                    _removeConjunction(_FINDER_COLUMN_G_F_F_GROUPID_2) + ")";
8525            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_2 = "dlFileEntry.folderId = ? AND ";
8526            private static final String _FINDER_COLUMN_G_F_F_FOLDERID_5 = "(" +
8527                    _removeConjunction(_FINDER_COLUMN_G_F_F_FOLDERID_2) + ")";
8528            private static final String _FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2 = "dlFileEntry.fileEntryTypeId = ?";
8529            private static final String _FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5 = "(" +
8530                    _removeConjunction(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_2) + ")";
8531    
8532            private static String _removeConjunction(String sql) {
8533                    int pos = sql.indexOf(" AND ");
8534    
8535                    if (pos != -1) {
8536                            sql = sql.substring(0, pos);
8537                    }
8538    
8539                    return sql;
8540            }
8541    
8542            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntry.fileEntryId";
8543            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_WHERE = "SELECT DISTINCT {dlFileEntry.*} FROM DLFileEntry dlFileEntry WHERE ";
8544            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1 =
8545                    "SELECT {DLFileEntry.*} FROM (SELECT DISTINCT dlFileEntry.fileEntryId FROM DLFileEntry dlFileEntry WHERE ";
8546            private static final String _FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_2 =
8547                    ") TEMP_TABLE INNER JOIN DLFileEntry ON TEMP_TABLE.fileEntryId = DLFileEntry.fileEntryId";
8548            private static final String _FILTER_SQL_COUNT_DLFILEENTRY_WHERE = "SELECT COUNT(DISTINCT dlFileEntry.fileEntryId) AS COUNT_VALUE FROM DLFileEntry dlFileEntry WHERE ";
8549            private static final String _FILTER_ENTITY_ALIAS = "dlFileEntry";
8550            private static final String _FILTER_ENTITY_TABLE = "DLFileEntry";
8551            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntry.";
8552            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntry.";
8553            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntry exists with the primary key ";
8554            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntry exists with the key {";
8555            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
8556            private static Log _log = LogFactoryUtil.getLog(DLFileEntryPersistenceImpl.class);
8557            private static DLFileEntry _nullDLFileEntry = new DLFileEntryImpl() {
8558                            @Override
8559                            public Object clone() {
8560                                    return this;
8561                            }
8562    
8563                            @Override
8564                            public CacheModel<DLFileEntry> toCacheModel() {
8565                                    return _nullDLFileEntryCacheModel;
8566                            }
8567                    };
8568    
8569            private static CacheModel<DLFileEntry> _nullDLFileEntryCacheModel = new CacheModel<DLFileEntry>() {
8570                            public DLFileEntry toEntityModel() {
8571                                    return _nullDLFileEntry;
8572                            }
8573                    };
8574    }