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.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.ResourcePersistence;
040    import com.liferay.portal.service.persistence.UserPersistence;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.documentlibrary.NoSuchFileVersionException;
044    import com.liferay.portlet.documentlibrary.model.DLFileVersion;
045    import com.liferay.portlet.documentlibrary.model.impl.DLFileVersionImpl;
046    import com.liferay.portlet.documentlibrary.model.impl.DLFileVersionModelImpl;
047    
048    import java.io.Serializable;
049    
050    import java.util.ArrayList;
051    import java.util.Collections;
052    import java.util.List;
053    
054    /**
055     * The persistence implementation for the document library file version service.
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see DLFileVersionPersistence
063     * @see DLFileVersionUtil
064     * @generated
065     */
066    public class DLFileVersionPersistenceImpl extends BasePersistenceImpl<DLFileVersion>
067            implements DLFileVersionPersistence {
068            /*
069             * NOTE FOR DEVELOPERS:
070             *
071             * Never modify or reference this class directly. Always use {@link DLFileVersionUtil} to access the document library file version persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072             */
073            public static final String FINDER_CLASS_NAME_ENTITY = DLFileVersionImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075                    ".List1";
076            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List2";
078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID =
079                    new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
080                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
081                            DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
082                            "findByFileEntryId",
083                            new String[] {
084                                    Long.class.getName(),
085                                    
086                            "java.lang.Integer", "java.lang.Integer",
087                                    "com.liferay.portal.kernel.util.OrderByComparator"
088                            });
089            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID =
090                    new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
091                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
092                            DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
093                            "findByFileEntryId", new String[] { Long.class.getName() },
094                            DLFileVersionModelImpl.FILEENTRYID_COLUMN_BITMASK);
095            public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYID = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
096                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFileEntryId",
098                            new String[] { Long.class.getName() });
099            public static final FinderPath FINDER_PATH_FETCH_BY_F_V = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
100                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
101                            DLFileVersionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByF_V",
102                            new String[] { Long.class.getName(), String.class.getName() },
103                            DLFileVersionModelImpl.FILEENTRYID_COLUMN_BITMASK |
104                            DLFileVersionModelImpl.VERSION_COLUMN_BITMASK);
105            public static final FinderPath FINDER_PATH_COUNT_BY_F_V = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
106                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByF_V",
108                            new String[] { Long.class.getName(), String.class.getName() });
109            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
110                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
111                            DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
112                            "findByF_S",
113                            new String[] {
114                                    Long.class.getName(), Integer.class.getName(),
115                                    
116                            "java.lang.Integer", "java.lang.Integer",
117                                    "com.liferay.portal.kernel.util.OrderByComparator"
118                            });
119            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
120                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
121                            DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
122                            "findByF_S",
123                            new String[] { Long.class.getName(), Integer.class.getName() },
124                            DLFileVersionModelImpl.FILEENTRYID_COLUMN_BITMASK |
125                            DLFileVersionModelImpl.STATUS_COLUMN_BITMASK);
126            public static final FinderPath FINDER_PATH_COUNT_BY_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
127                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByF_S",
129                            new String[] { Long.class.getName(), Integer.class.getName() });
130            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
131                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
132                            DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
133                            "findByG_F_S",
134                            new String[] {
135                                    Long.class.getName(), Long.class.getName(),
136                                    Integer.class.getName(),
137                                    
138                            "java.lang.Integer", "java.lang.Integer",
139                                    "com.liferay.portal.kernel.util.OrderByComparator"
140                            });
141            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
142                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
143                            DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
144                            "findByG_F_S",
145                            new String[] {
146                                    Long.class.getName(), Long.class.getName(),
147                                    Integer.class.getName()
148                            },
149                            DLFileVersionModelImpl.GROUPID_COLUMN_BITMASK |
150                            DLFileVersionModelImpl.FOLDERID_COLUMN_BITMASK |
151                            DLFileVersionModelImpl.STATUS_COLUMN_BITMASK);
152            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
153                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
154                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_S",
155                            new String[] {
156                                    Long.class.getName(), Long.class.getName(),
157                                    Integer.class.getName()
158                            });
159            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
160                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
161                            DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
162                            "findAll", new String[0]);
163            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
164                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED,
165                            DLFileVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
166                            "findAll", new String[0]);
167            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
168                            DLFileVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
170    
171            /**
172             * Caches the document library file version in the entity cache if it is enabled.
173             *
174             * @param dlFileVersion the document library file version
175             */
176            public void cacheResult(DLFileVersion dlFileVersion) {
177                    EntityCacheUtil.putResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
178                            DLFileVersionImpl.class, dlFileVersion.getPrimaryKey(),
179                            dlFileVersion);
180    
181                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
182                            new Object[] {
183                                    Long.valueOf(dlFileVersion.getFileEntryId()),
184                                    
185                            dlFileVersion.getVersion()
186                            }, dlFileVersion);
187    
188                    dlFileVersion.resetOriginalValues();
189            }
190    
191            /**
192             * Caches the document library file versions in the entity cache if it is enabled.
193             *
194             * @param dlFileVersions the document library file versions
195             */
196            public void cacheResult(List<DLFileVersion> dlFileVersions) {
197                    for (DLFileVersion dlFileVersion : dlFileVersions) {
198                            if (EntityCacheUtil.getResult(
199                                                    DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
200                                                    DLFileVersionImpl.class, dlFileVersion.getPrimaryKey()) == null) {
201                                    cacheResult(dlFileVersion);
202                            }
203                            else {
204                                    dlFileVersion.resetOriginalValues();
205                            }
206                    }
207            }
208    
209            /**
210             * Clears the cache for all document library file versions.
211             *
212             * <p>
213             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
214             * </p>
215             */
216            @Override
217            public void clearCache() {
218                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
219                            CacheRegistryUtil.clear(DLFileVersionImpl.class.getName());
220                    }
221    
222                    EntityCacheUtil.clearCache(DLFileVersionImpl.class.getName());
223    
224                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
225                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
226                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
227            }
228    
229            /**
230             * Clears the cache for the document library file version.
231             *
232             * <p>
233             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
234             * </p>
235             */
236            @Override
237            public void clearCache(DLFileVersion dlFileVersion) {
238                    EntityCacheUtil.removeResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
239                            DLFileVersionImpl.class, dlFileVersion.getPrimaryKey());
240    
241                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
242                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
243    
244                    clearUniqueFindersCache(dlFileVersion);
245            }
246    
247            @Override
248            public void clearCache(List<DLFileVersion> dlFileVersions) {
249                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
250                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
251    
252                    for (DLFileVersion dlFileVersion : dlFileVersions) {
253                            EntityCacheUtil.removeResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
254                                    DLFileVersionImpl.class, dlFileVersion.getPrimaryKey());
255    
256                            clearUniqueFindersCache(dlFileVersion);
257                    }
258            }
259    
260            protected void clearUniqueFindersCache(DLFileVersion dlFileVersion) {
261                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V,
262                            new Object[] {
263                                    Long.valueOf(dlFileVersion.getFileEntryId()),
264                                    
265                            dlFileVersion.getVersion()
266                            });
267            }
268    
269            /**
270             * Creates a new document library file version with the primary key. Does not add the document library file version to the database.
271             *
272             * @param fileVersionId the primary key for the new document library file version
273             * @return the new document library file version
274             */
275            public DLFileVersion create(long fileVersionId) {
276                    DLFileVersion dlFileVersion = new DLFileVersionImpl();
277    
278                    dlFileVersion.setNew(true);
279                    dlFileVersion.setPrimaryKey(fileVersionId);
280    
281                    return dlFileVersion;
282            }
283    
284            /**
285             * Removes the document library file version with the primary key from the database. Also notifies the appropriate model listeners.
286             *
287             * @param fileVersionId the primary key of the document library file version
288             * @return the document library file version that was removed
289             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a document library file version with the primary key could not be found
290             * @throws SystemException if a system exception occurred
291             */
292            public DLFileVersion remove(long fileVersionId)
293                    throws NoSuchFileVersionException, SystemException {
294                    return remove(Long.valueOf(fileVersionId));
295            }
296    
297            /**
298             * Removes the document library file version with the primary key from the database. Also notifies the appropriate model listeners.
299             *
300             * @param primaryKey the primary key of the document library file version
301             * @return the document library file version that was removed
302             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a document library file version with the primary key could not be found
303             * @throws SystemException if a system exception occurred
304             */
305            @Override
306            public DLFileVersion remove(Serializable primaryKey)
307                    throws NoSuchFileVersionException, SystemException {
308                    Session session = null;
309    
310                    try {
311                            session = openSession();
312    
313                            DLFileVersion dlFileVersion = (DLFileVersion)session.get(DLFileVersionImpl.class,
314                                            primaryKey);
315    
316                            if (dlFileVersion == null) {
317                                    if (_log.isWarnEnabled()) {
318                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
319                                    }
320    
321                                    throw new NoSuchFileVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
322                                            primaryKey);
323                            }
324    
325                            return remove(dlFileVersion);
326                    }
327                    catch (NoSuchFileVersionException nsee) {
328                            throw nsee;
329                    }
330                    catch (Exception e) {
331                            throw processException(e);
332                    }
333                    finally {
334                            closeSession(session);
335                    }
336            }
337    
338            @Override
339            protected DLFileVersion removeImpl(DLFileVersion dlFileVersion)
340                    throws SystemException {
341                    dlFileVersion = toUnwrappedModel(dlFileVersion);
342    
343                    Session session = null;
344    
345                    try {
346                            session = openSession();
347    
348                            BatchSessionUtil.delete(session, dlFileVersion);
349                    }
350                    catch (Exception e) {
351                            throw processException(e);
352                    }
353                    finally {
354                            closeSession(session);
355                    }
356    
357                    clearCache(dlFileVersion);
358    
359                    return dlFileVersion;
360            }
361    
362            @Override
363            public DLFileVersion updateImpl(
364                    com.liferay.portlet.documentlibrary.model.DLFileVersion dlFileVersion,
365                    boolean merge) throws SystemException {
366                    dlFileVersion = toUnwrappedModel(dlFileVersion);
367    
368                    boolean isNew = dlFileVersion.isNew();
369    
370                    DLFileVersionModelImpl dlFileVersionModelImpl = (DLFileVersionModelImpl)dlFileVersion;
371    
372                    Session session = null;
373    
374                    try {
375                            session = openSession();
376    
377                            BatchSessionUtil.update(session, dlFileVersion, merge);
378    
379                            dlFileVersion.setNew(false);
380                    }
381                    catch (Exception e) {
382                            throw processException(e);
383                    }
384                    finally {
385                            closeSession(session);
386                    }
387    
388                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
389    
390                    if (isNew || !DLFileVersionModelImpl.COLUMN_BITMASK_ENABLED) {
391                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
392                    }
393    
394                    else {
395                            if ((dlFileVersionModelImpl.getColumnBitmask() &
396                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID.getColumnBitmask()) != 0) {
397                                    Object[] args = new Object[] {
398                                                    Long.valueOf(dlFileVersionModelImpl.getOriginalFileEntryId())
399                                            };
400    
401                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
402                                            args);
403                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
404                                            args);
405    
406                                    args = new Object[] {
407                                                    Long.valueOf(dlFileVersionModelImpl.getFileEntryId())
408                                            };
409    
410                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
411                                            args);
412                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
413                                            args);
414                            }
415    
416                            if ((dlFileVersionModelImpl.getColumnBitmask() &
417                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S.getColumnBitmask()) != 0) {
418                                    Object[] args = new Object[] {
419                                                    Long.valueOf(dlFileVersionModelImpl.getOriginalFileEntryId()),
420                                                    Integer.valueOf(dlFileVersionModelImpl.getOriginalStatus())
421                                            };
422    
423                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_S, args);
424                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S,
425                                            args);
426    
427                                    args = new Object[] {
428                                                    Long.valueOf(dlFileVersionModelImpl.getFileEntryId()),
429                                                    Integer.valueOf(dlFileVersionModelImpl.getStatus())
430                                            };
431    
432                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_S, args);
433                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S,
434                                            args);
435                            }
436    
437                            if ((dlFileVersionModelImpl.getColumnBitmask() &
438                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S.getColumnBitmask()) != 0) {
439                                    Object[] args = new Object[] {
440                                                    Long.valueOf(dlFileVersionModelImpl.getOriginalGroupId()),
441                                                    Long.valueOf(dlFileVersionModelImpl.getOriginalFolderId()),
442                                                    Integer.valueOf(dlFileVersionModelImpl.getOriginalStatus())
443                                            };
444    
445                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
446                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
447                                            args);
448    
449                                    args = new Object[] {
450                                                    Long.valueOf(dlFileVersionModelImpl.getGroupId()),
451                                                    Long.valueOf(dlFileVersionModelImpl.getFolderId()),
452                                                    Integer.valueOf(dlFileVersionModelImpl.getStatus())
453                                            };
454    
455                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
456                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
457                                            args);
458                            }
459                    }
460    
461                    EntityCacheUtil.putResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
462                            DLFileVersionImpl.class, dlFileVersion.getPrimaryKey(),
463                            dlFileVersion);
464    
465                    if (isNew) {
466                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
467                                    new Object[] {
468                                            Long.valueOf(dlFileVersion.getFileEntryId()),
469                                            
470                                    dlFileVersion.getVersion()
471                                    }, dlFileVersion);
472                    }
473                    else {
474                            if ((dlFileVersionModelImpl.getColumnBitmask() &
475                                            FINDER_PATH_FETCH_BY_F_V.getColumnBitmask()) != 0) {
476                                    Object[] args = new Object[] {
477                                                    Long.valueOf(dlFileVersionModelImpl.getOriginalFileEntryId()),
478                                                    
479                                                    dlFileVersionModelImpl.getOriginalVersion()
480                                            };
481    
482                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_V, args);
483                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V, args);
484    
485                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
486                                            new Object[] {
487                                                    Long.valueOf(dlFileVersion.getFileEntryId()),
488                                                    
489                                            dlFileVersion.getVersion()
490                                            }, dlFileVersion);
491                            }
492                    }
493    
494                    return dlFileVersion;
495            }
496    
497            protected DLFileVersion toUnwrappedModel(DLFileVersion dlFileVersion) {
498                    if (dlFileVersion instanceof DLFileVersionImpl) {
499                            return dlFileVersion;
500                    }
501    
502                    DLFileVersionImpl dlFileVersionImpl = new DLFileVersionImpl();
503    
504                    dlFileVersionImpl.setNew(dlFileVersion.isNew());
505                    dlFileVersionImpl.setPrimaryKey(dlFileVersion.getPrimaryKey());
506    
507                    dlFileVersionImpl.setFileVersionId(dlFileVersion.getFileVersionId());
508                    dlFileVersionImpl.setGroupId(dlFileVersion.getGroupId());
509                    dlFileVersionImpl.setCompanyId(dlFileVersion.getCompanyId());
510                    dlFileVersionImpl.setUserId(dlFileVersion.getUserId());
511                    dlFileVersionImpl.setUserName(dlFileVersion.getUserName());
512                    dlFileVersionImpl.setCreateDate(dlFileVersion.getCreateDate());
513                    dlFileVersionImpl.setModifiedDate(dlFileVersion.getModifiedDate());
514                    dlFileVersionImpl.setRepositoryId(dlFileVersion.getRepositoryId());
515                    dlFileVersionImpl.setFolderId(dlFileVersion.getFolderId());
516                    dlFileVersionImpl.setFileEntryId(dlFileVersion.getFileEntryId());
517                    dlFileVersionImpl.setExtension(dlFileVersion.getExtension());
518                    dlFileVersionImpl.setMimeType(dlFileVersion.getMimeType());
519                    dlFileVersionImpl.setTitle(dlFileVersion.getTitle());
520                    dlFileVersionImpl.setDescription(dlFileVersion.getDescription());
521                    dlFileVersionImpl.setChangeLog(dlFileVersion.getChangeLog());
522                    dlFileVersionImpl.setExtraSettings(dlFileVersion.getExtraSettings());
523                    dlFileVersionImpl.setFileEntryTypeId(dlFileVersion.getFileEntryTypeId());
524                    dlFileVersionImpl.setVersion(dlFileVersion.getVersion());
525                    dlFileVersionImpl.setSize(dlFileVersion.getSize());
526                    dlFileVersionImpl.setStatus(dlFileVersion.getStatus());
527                    dlFileVersionImpl.setStatusByUserId(dlFileVersion.getStatusByUserId());
528                    dlFileVersionImpl.setStatusByUserName(dlFileVersion.getStatusByUserName());
529                    dlFileVersionImpl.setStatusDate(dlFileVersion.getStatusDate());
530    
531                    return dlFileVersionImpl;
532            }
533    
534            /**
535             * Returns the document library file version with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
536             *
537             * @param primaryKey the primary key of the document library file version
538             * @return the document library file version
539             * @throws com.liferay.portal.NoSuchModelException if a document library file version with the primary key could not be found
540             * @throws SystemException if a system exception occurred
541             */
542            @Override
543            public DLFileVersion findByPrimaryKey(Serializable primaryKey)
544                    throws NoSuchModelException, SystemException {
545                    return findByPrimaryKey(((Long)primaryKey).longValue());
546            }
547    
548            /**
549             * Returns the document library file version with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileVersionException} if it could not be found.
550             *
551             * @param fileVersionId the primary key of the document library file version
552             * @return the document library file version
553             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a document library file version with the primary key could not be found
554             * @throws SystemException if a system exception occurred
555             */
556            public DLFileVersion findByPrimaryKey(long fileVersionId)
557                    throws NoSuchFileVersionException, SystemException {
558                    DLFileVersion dlFileVersion = fetchByPrimaryKey(fileVersionId);
559    
560                    if (dlFileVersion == null) {
561                            if (_log.isWarnEnabled()) {
562                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileVersionId);
563                            }
564    
565                            throw new NoSuchFileVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
566                                    fileVersionId);
567                    }
568    
569                    return dlFileVersion;
570            }
571    
572            /**
573             * Returns the document library file version with the primary key or returns <code>null</code> if it could not be found.
574             *
575             * @param primaryKey the primary key of the document library file version
576             * @return the document library file version, or <code>null</code> if a document library file version with the primary key could not be found
577             * @throws SystemException if a system exception occurred
578             */
579            @Override
580            public DLFileVersion fetchByPrimaryKey(Serializable primaryKey)
581                    throws SystemException {
582                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
583            }
584    
585            /**
586             * Returns the document library file version with the primary key or returns <code>null</code> if it could not be found.
587             *
588             * @param fileVersionId the primary key of the document library file version
589             * @return the document library file version, or <code>null</code> if a document library file version with the primary key could not be found
590             * @throws SystemException if a system exception occurred
591             */
592            public DLFileVersion fetchByPrimaryKey(long fileVersionId)
593                    throws SystemException {
594                    DLFileVersion dlFileVersion = (DLFileVersion)EntityCacheUtil.getResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
595                                    DLFileVersionImpl.class, fileVersionId);
596    
597                    if (dlFileVersion == _nullDLFileVersion) {
598                            return null;
599                    }
600    
601                    if (dlFileVersion == null) {
602                            Session session = null;
603    
604                            boolean hasException = false;
605    
606                            try {
607                                    session = openSession();
608    
609                                    dlFileVersion = (DLFileVersion)session.get(DLFileVersionImpl.class,
610                                                    Long.valueOf(fileVersionId));
611                            }
612                            catch (Exception e) {
613                                    hasException = true;
614    
615                                    throw processException(e);
616                            }
617                            finally {
618                                    if (dlFileVersion != null) {
619                                            cacheResult(dlFileVersion);
620                                    }
621                                    else if (!hasException) {
622                                            EntityCacheUtil.putResult(DLFileVersionModelImpl.ENTITY_CACHE_ENABLED,
623                                                    DLFileVersionImpl.class, fileVersionId,
624                                                    _nullDLFileVersion);
625                                    }
626    
627                                    closeSession(session);
628                            }
629                    }
630    
631                    return dlFileVersion;
632            }
633    
634            /**
635             * Returns all the document library file versions where fileEntryId = &#63;.
636             *
637             * @param fileEntryId the file entry ID
638             * @return the matching document library file versions
639             * @throws SystemException if a system exception occurred
640             */
641            public List<DLFileVersion> findByFileEntryId(long fileEntryId)
642                    throws SystemException {
643                    return findByFileEntryId(fileEntryId, QueryUtil.ALL_POS,
644                            QueryUtil.ALL_POS, null);
645            }
646    
647            /**
648             * Returns a range of all the document library file versions where fileEntryId = &#63;.
649             *
650             * <p>
651             * 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.
652             * </p>
653             *
654             * @param fileEntryId the file entry ID
655             * @param start the lower bound of the range of document library file versions
656             * @param end the upper bound of the range of document library file versions (not inclusive)
657             * @return the range of matching document library file versions
658             * @throws SystemException if a system exception occurred
659             */
660            public List<DLFileVersion> findByFileEntryId(long fileEntryId, int start,
661                    int end) throws SystemException {
662                    return findByFileEntryId(fileEntryId, start, end, null);
663            }
664    
665            /**
666             * Returns an ordered range of all the document library file versions where fileEntryId = &#63;.
667             *
668             * <p>
669             * 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.
670             * </p>
671             *
672             * @param fileEntryId the file entry ID
673             * @param start the lower bound of the range of document library file versions
674             * @param end the upper bound of the range of document library file versions (not inclusive)
675             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
676             * @return the ordered range of matching document library file versions
677             * @throws SystemException if a system exception occurred
678             */
679            public List<DLFileVersion> findByFileEntryId(long fileEntryId, int start,
680                    int end, OrderByComparator orderByComparator) throws SystemException {
681                    FinderPath finderPath = null;
682                    Object[] finderArgs = null;
683    
684                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
685                                    (orderByComparator == null)) {
686                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID;
687                            finderArgs = new Object[] { fileEntryId };
688                    }
689                    else {
690                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID;
691                            finderArgs = new Object[] { fileEntryId, start, end, orderByComparator };
692                    }
693    
694                    List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
695                                    finderArgs, this);
696    
697                    if (list == null) {
698                            StringBundler query = null;
699    
700                            if (orderByComparator != null) {
701                                    query = new StringBundler(3 +
702                                                    (orderByComparator.getOrderByFields().length * 3));
703                            }
704                            else {
705                                    query = new StringBundler(3);
706                            }
707    
708                            query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
709    
710                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
711    
712                            if (orderByComparator != null) {
713                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
714                                            orderByComparator);
715                            }
716    
717                            else {
718                                    query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
719                            }
720    
721                            String sql = query.toString();
722    
723                            Session session = null;
724    
725                            try {
726                                    session = openSession();
727    
728                                    Query q = session.createQuery(sql);
729    
730                                    QueryPos qPos = QueryPos.getInstance(q);
731    
732                                    qPos.add(fileEntryId);
733    
734                                    list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
735                                                    start, end);
736                            }
737                            catch (Exception e) {
738                                    throw processException(e);
739                            }
740                            finally {
741                                    if (list == null) {
742                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
743                                    }
744                                    else {
745                                            cacheResult(list);
746    
747                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
748                                    }
749    
750                                    closeSession(session);
751                            }
752                    }
753    
754                    return list;
755            }
756    
757            /**
758             * Returns the first document library file version in the ordered set where fileEntryId = &#63;.
759             *
760             * <p>
761             * 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.
762             * </p>
763             *
764             * @param fileEntryId the file entry ID
765             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
766             * @return the first matching document library file version
767             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a matching document library file version could not be found
768             * @throws SystemException if a system exception occurred
769             */
770            public DLFileVersion findByFileEntryId_First(long fileEntryId,
771                    OrderByComparator orderByComparator)
772                    throws NoSuchFileVersionException, SystemException {
773                    List<DLFileVersion> list = findByFileEntryId(fileEntryId, 0, 1,
774                                    orderByComparator);
775    
776                    if (list.isEmpty()) {
777                            StringBundler msg = new StringBundler(4);
778    
779                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
780    
781                            msg.append("fileEntryId=");
782                            msg.append(fileEntryId);
783    
784                            msg.append(StringPool.CLOSE_CURLY_BRACE);
785    
786                            throw new NoSuchFileVersionException(msg.toString());
787                    }
788                    else {
789                            return list.get(0);
790                    }
791            }
792    
793            /**
794             * Returns the last document library file version in the ordered set where fileEntryId = &#63;.
795             *
796             * <p>
797             * 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.
798             * </p>
799             *
800             * @param fileEntryId the file entry ID
801             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
802             * @return the last matching document library file version
803             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a matching document library file version could not be found
804             * @throws SystemException if a system exception occurred
805             */
806            public DLFileVersion findByFileEntryId_Last(long fileEntryId,
807                    OrderByComparator orderByComparator)
808                    throws NoSuchFileVersionException, SystemException {
809                    int count = countByFileEntryId(fileEntryId);
810    
811                    List<DLFileVersion> list = findByFileEntryId(fileEntryId, count - 1,
812                                    count, orderByComparator);
813    
814                    if (list.isEmpty()) {
815                            StringBundler msg = new StringBundler(4);
816    
817                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
818    
819                            msg.append("fileEntryId=");
820                            msg.append(fileEntryId);
821    
822                            msg.append(StringPool.CLOSE_CURLY_BRACE);
823    
824                            throw new NoSuchFileVersionException(msg.toString());
825                    }
826                    else {
827                            return list.get(0);
828                    }
829            }
830    
831            /**
832             * Returns the document library file versions before and after the current document library file version in the ordered set where fileEntryId = &#63;.
833             *
834             * <p>
835             * 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.
836             * </p>
837             *
838             * @param fileVersionId the primary key of the current document library file version
839             * @param fileEntryId the file entry ID
840             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
841             * @return the previous, current, and next document library file version
842             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a document library file version with the primary key could not be found
843             * @throws SystemException if a system exception occurred
844             */
845            public DLFileVersion[] findByFileEntryId_PrevAndNext(long fileVersionId,
846                    long fileEntryId, OrderByComparator orderByComparator)
847                    throws NoSuchFileVersionException, SystemException {
848                    DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
849    
850                    Session session = null;
851    
852                    try {
853                            session = openSession();
854    
855                            DLFileVersion[] array = new DLFileVersionImpl[3];
856    
857                            array[0] = getByFileEntryId_PrevAndNext(session, dlFileVersion,
858                                            fileEntryId, orderByComparator, true);
859    
860                            array[1] = dlFileVersion;
861    
862                            array[2] = getByFileEntryId_PrevAndNext(session, dlFileVersion,
863                                            fileEntryId, orderByComparator, false);
864    
865                            return array;
866                    }
867                    catch (Exception e) {
868                            throw processException(e);
869                    }
870                    finally {
871                            closeSession(session);
872                    }
873            }
874    
875            protected DLFileVersion getByFileEntryId_PrevAndNext(Session session,
876                    DLFileVersion dlFileVersion, long fileEntryId,
877                    OrderByComparator orderByComparator, boolean previous) {
878                    StringBundler query = null;
879    
880                    if (orderByComparator != null) {
881                            query = new StringBundler(6 +
882                                            (orderByComparator.getOrderByFields().length * 6));
883                    }
884                    else {
885                            query = new StringBundler(3);
886                    }
887    
888                    query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
889    
890                    query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
891    
892                    if (orderByComparator != null) {
893                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
894    
895                            if (orderByConditionFields.length > 0) {
896                                    query.append(WHERE_AND);
897                            }
898    
899                            for (int i = 0; i < orderByConditionFields.length; i++) {
900                                    query.append(_ORDER_BY_ENTITY_ALIAS);
901                                    query.append(orderByConditionFields[i]);
902    
903                                    if ((i + 1) < orderByConditionFields.length) {
904                                            if (orderByComparator.isAscending() ^ previous) {
905                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
906                                            }
907                                            else {
908                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
909                                            }
910                                    }
911                                    else {
912                                            if (orderByComparator.isAscending() ^ previous) {
913                                                    query.append(WHERE_GREATER_THAN);
914                                            }
915                                            else {
916                                                    query.append(WHERE_LESSER_THAN);
917                                            }
918                                    }
919                            }
920    
921                            query.append(ORDER_BY_CLAUSE);
922    
923                            String[] orderByFields = orderByComparator.getOrderByFields();
924    
925                            for (int i = 0; i < orderByFields.length; i++) {
926                                    query.append(_ORDER_BY_ENTITY_ALIAS);
927                                    query.append(orderByFields[i]);
928    
929                                    if ((i + 1) < orderByFields.length) {
930                                            if (orderByComparator.isAscending() ^ previous) {
931                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
932                                            }
933                                            else {
934                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
935                                            }
936                                    }
937                                    else {
938                                            if (orderByComparator.isAscending() ^ previous) {
939                                                    query.append(ORDER_BY_ASC);
940                                            }
941                                            else {
942                                                    query.append(ORDER_BY_DESC);
943                                            }
944                                    }
945                            }
946                    }
947    
948                    else {
949                            query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
950                    }
951    
952                    String sql = query.toString();
953    
954                    Query q = session.createQuery(sql);
955    
956                    q.setFirstResult(0);
957                    q.setMaxResults(2);
958    
959                    QueryPos qPos = QueryPos.getInstance(q);
960    
961                    qPos.add(fileEntryId);
962    
963                    if (orderByComparator != null) {
964                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
965    
966                            for (Object value : values) {
967                                    qPos.add(value);
968                            }
969                    }
970    
971                    List<DLFileVersion> list = q.list();
972    
973                    if (list.size() == 2) {
974                            return list.get(1);
975                    }
976                    else {
977                            return null;
978                    }
979            }
980    
981            /**
982             * Returns the document library file version where fileEntryId = &#63; and version = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileVersionException} if it could not be found.
983             *
984             * @param fileEntryId the file entry ID
985             * @param version the version
986             * @return the matching document library file version
987             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a matching document library file version could not be found
988             * @throws SystemException if a system exception occurred
989             */
990            public DLFileVersion findByF_V(long fileEntryId, String version)
991                    throws NoSuchFileVersionException, SystemException {
992                    DLFileVersion dlFileVersion = fetchByF_V(fileEntryId, version);
993    
994                    if (dlFileVersion == null) {
995                            StringBundler msg = new StringBundler(6);
996    
997                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
998    
999                            msg.append("fileEntryId=");
1000                            msg.append(fileEntryId);
1001    
1002                            msg.append(", version=");
1003                            msg.append(version);
1004    
1005                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1006    
1007                            if (_log.isWarnEnabled()) {
1008                                    _log.warn(msg.toString());
1009                            }
1010    
1011                            throw new NoSuchFileVersionException(msg.toString());
1012                    }
1013    
1014                    return dlFileVersion;
1015            }
1016    
1017            /**
1018             * Returns the document library file version where fileEntryId = &#63; and version = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1019             *
1020             * @param fileEntryId the file entry ID
1021             * @param version the version
1022             * @return the matching document library file version, or <code>null</code> if a matching document library file version could not be found
1023             * @throws SystemException if a system exception occurred
1024             */
1025            public DLFileVersion fetchByF_V(long fileEntryId, String version)
1026                    throws SystemException {
1027                    return fetchByF_V(fileEntryId, version, true);
1028            }
1029    
1030            /**
1031             * Returns the document library file version where fileEntryId = &#63; and version = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1032             *
1033             * @param fileEntryId the file entry ID
1034             * @param version the version
1035             * @param retrieveFromCache whether to use the finder cache
1036             * @return the matching document library file version, or <code>null</code> if a matching document library file version could not be found
1037             * @throws SystemException if a system exception occurred
1038             */
1039            public DLFileVersion fetchByF_V(long fileEntryId, String version,
1040                    boolean retrieveFromCache) throws SystemException {
1041                    Object[] finderArgs = new Object[] { fileEntryId, version };
1042    
1043                    Object result = null;
1044    
1045                    if (retrieveFromCache) {
1046                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_F_V,
1047                                            finderArgs, this);
1048                    }
1049    
1050                    if (result == null) {
1051                            StringBundler query = new StringBundler(4);
1052    
1053                            query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1054    
1055                            query.append(_FINDER_COLUMN_F_V_FILEENTRYID_2);
1056    
1057                            if (version == null) {
1058                                    query.append(_FINDER_COLUMN_F_V_VERSION_1);
1059                            }
1060                            else {
1061                                    if (version.equals(StringPool.BLANK)) {
1062                                            query.append(_FINDER_COLUMN_F_V_VERSION_3);
1063                                    }
1064                                    else {
1065                                            query.append(_FINDER_COLUMN_F_V_VERSION_2);
1066                                    }
1067                            }
1068    
1069                            query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1070    
1071                            String sql = query.toString();
1072    
1073                            Session session = null;
1074    
1075                            try {
1076                                    session = openSession();
1077    
1078                                    Query q = session.createQuery(sql);
1079    
1080                                    QueryPos qPos = QueryPos.getInstance(q);
1081    
1082                                    qPos.add(fileEntryId);
1083    
1084                                    if (version != null) {
1085                                            qPos.add(version);
1086                                    }
1087    
1088                                    List<DLFileVersion> list = q.list();
1089    
1090                                    result = list;
1091    
1092                                    DLFileVersion dlFileVersion = null;
1093    
1094                                    if (list.isEmpty()) {
1095                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
1096                                                    finderArgs, list);
1097                                    }
1098                                    else {
1099                                            dlFileVersion = list.get(0);
1100    
1101                                            cacheResult(dlFileVersion);
1102    
1103                                            if ((dlFileVersion.getFileEntryId() != fileEntryId) ||
1104                                                            (dlFileVersion.getVersion() == null) ||
1105                                                            !dlFileVersion.getVersion().equals(version)) {
1106                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
1107                                                            finderArgs, dlFileVersion);
1108                                            }
1109                                    }
1110    
1111                                    return dlFileVersion;
1112                            }
1113                            catch (Exception e) {
1114                                    throw processException(e);
1115                            }
1116                            finally {
1117                                    if (result == null) {
1118                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V,
1119                                                    finderArgs);
1120                                    }
1121    
1122                                    closeSession(session);
1123                            }
1124                    }
1125                    else {
1126                            if (result instanceof List<?>) {
1127                                    return null;
1128                            }
1129                            else {
1130                                    return (DLFileVersion)result;
1131                            }
1132                    }
1133            }
1134    
1135            /**
1136             * Returns all the document library file versions where fileEntryId = &#63; and status = &#63;.
1137             *
1138             * @param fileEntryId the file entry ID
1139             * @param status the status
1140             * @return the matching document library file versions
1141             * @throws SystemException if a system exception occurred
1142             */
1143            public List<DLFileVersion> findByF_S(long fileEntryId, int status)
1144                    throws SystemException {
1145                    return findByF_S(fileEntryId, status, QueryUtil.ALL_POS,
1146                            QueryUtil.ALL_POS, null);
1147            }
1148    
1149            /**
1150             * Returns a range of all the document library file versions where fileEntryId = &#63; and status = &#63;.
1151             *
1152             * <p>
1153             * 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.
1154             * </p>
1155             *
1156             * @param fileEntryId the file entry ID
1157             * @param status the status
1158             * @param start the lower bound of the range of document library file versions
1159             * @param end the upper bound of the range of document library file versions (not inclusive)
1160             * @return the range of matching document library file versions
1161             * @throws SystemException if a system exception occurred
1162             */
1163            public List<DLFileVersion> findByF_S(long fileEntryId, int status,
1164                    int start, int end) throws SystemException {
1165                    return findByF_S(fileEntryId, status, start, end, null);
1166            }
1167    
1168            /**
1169             * Returns an ordered range of all the document library file versions where fileEntryId = &#63; and status = &#63;.
1170             *
1171             * <p>
1172             * 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.
1173             * </p>
1174             *
1175             * @param fileEntryId the file entry ID
1176             * @param status the status
1177             * @param start the lower bound of the range of document library file versions
1178             * @param end the upper bound of the range of document library file versions (not inclusive)
1179             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1180             * @return the ordered range of matching document library file versions
1181             * @throws SystemException if a system exception occurred
1182             */
1183            public List<DLFileVersion> findByF_S(long fileEntryId, int status,
1184                    int start, int end, OrderByComparator orderByComparator)
1185                    throws SystemException {
1186                    FinderPath finderPath = null;
1187                    Object[] finderArgs = null;
1188    
1189                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1190                                    (orderByComparator == null)) {
1191                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_F_S;
1192                            finderArgs = new Object[] { fileEntryId, status };
1193                    }
1194                    else {
1195                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_F_S;
1196                            finderArgs = new Object[] {
1197                                            fileEntryId, status,
1198                                            
1199                                            start, end, orderByComparator
1200                                    };
1201                    }
1202    
1203                    List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
1204                                    finderArgs, this);
1205    
1206                    if (list == null) {
1207                            StringBundler query = null;
1208    
1209                            if (orderByComparator != null) {
1210                                    query = new StringBundler(4 +
1211                                                    (orderByComparator.getOrderByFields().length * 3));
1212                            }
1213                            else {
1214                                    query = new StringBundler(4);
1215                            }
1216    
1217                            query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1218    
1219                            query.append(_FINDER_COLUMN_F_S_FILEENTRYID_2);
1220    
1221                            query.append(_FINDER_COLUMN_F_S_STATUS_2);
1222    
1223                            if (orderByComparator != null) {
1224                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1225                                            orderByComparator);
1226                            }
1227    
1228                            else {
1229                                    query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1230                            }
1231    
1232                            String sql = query.toString();
1233    
1234                            Session session = null;
1235    
1236                            try {
1237                                    session = openSession();
1238    
1239                                    Query q = session.createQuery(sql);
1240    
1241                                    QueryPos qPos = QueryPos.getInstance(q);
1242    
1243                                    qPos.add(fileEntryId);
1244    
1245                                    qPos.add(status);
1246    
1247                                    list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1248                                                    start, end);
1249                            }
1250                            catch (Exception e) {
1251                                    throw processException(e);
1252                            }
1253                            finally {
1254                                    if (list == null) {
1255                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1256                                    }
1257                                    else {
1258                                            cacheResult(list);
1259    
1260                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1261                                    }
1262    
1263                                    closeSession(session);
1264                            }
1265                    }
1266    
1267                    return list;
1268            }
1269    
1270            /**
1271             * Returns the first document library file version in the ordered set where fileEntryId = &#63; and status = &#63;.
1272             *
1273             * <p>
1274             * 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.
1275             * </p>
1276             *
1277             * @param fileEntryId the file entry ID
1278             * @param status the status
1279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1280             * @return the first matching document library file version
1281             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a matching document library file version could not be found
1282             * @throws SystemException if a system exception occurred
1283             */
1284            public DLFileVersion findByF_S_First(long fileEntryId, int status,
1285                    OrderByComparator orderByComparator)
1286                    throws NoSuchFileVersionException, SystemException {
1287                    List<DLFileVersion> list = findByF_S(fileEntryId, status, 0, 1,
1288                                    orderByComparator);
1289    
1290                    if (list.isEmpty()) {
1291                            StringBundler msg = new StringBundler(6);
1292    
1293                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1294    
1295                            msg.append("fileEntryId=");
1296                            msg.append(fileEntryId);
1297    
1298                            msg.append(", status=");
1299                            msg.append(status);
1300    
1301                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1302    
1303                            throw new NoSuchFileVersionException(msg.toString());
1304                    }
1305                    else {
1306                            return list.get(0);
1307                    }
1308            }
1309    
1310            /**
1311             * Returns the last document library file version in the ordered set where fileEntryId = &#63; and status = &#63;.
1312             *
1313             * <p>
1314             * 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.
1315             * </p>
1316             *
1317             * @param fileEntryId the file entry ID
1318             * @param status the status
1319             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1320             * @return the last matching document library file version
1321             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a matching document library file version could not be found
1322             * @throws SystemException if a system exception occurred
1323             */
1324            public DLFileVersion findByF_S_Last(long fileEntryId, int status,
1325                    OrderByComparator orderByComparator)
1326                    throws NoSuchFileVersionException, SystemException {
1327                    int count = countByF_S(fileEntryId, status);
1328    
1329                    List<DLFileVersion> list = findByF_S(fileEntryId, status, count - 1,
1330                                    count, orderByComparator);
1331    
1332                    if (list.isEmpty()) {
1333                            StringBundler msg = new StringBundler(6);
1334    
1335                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1336    
1337                            msg.append("fileEntryId=");
1338                            msg.append(fileEntryId);
1339    
1340                            msg.append(", status=");
1341                            msg.append(status);
1342    
1343                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1344    
1345                            throw new NoSuchFileVersionException(msg.toString());
1346                    }
1347                    else {
1348                            return list.get(0);
1349                    }
1350            }
1351    
1352            /**
1353             * Returns the document library file versions before and after the current document library file version in the ordered set where fileEntryId = &#63; and status = &#63;.
1354             *
1355             * <p>
1356             * 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.
1357             * </p>
1358             *
1359             * @param fileVersionId the primary key of the current document library file version
1360             * @param fileEntryId the file entry ID
1361             * @param status the status
1362             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1363             * @return the previous, current, and next document library file version
1364             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a document library file version with the primary key could not be found
1365             * @throws SystemException if a system exception occurred
1366             */
1367            public DLFileVersion[] findByF_S_PrevAndNext(long fileVersionId,
1368                    long fileEntryId, int status, OrderByComparator orderByComparator)
1369                    throws NoSuchFileVersionException, SystemException {
1370                    DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
1371    
1372                    Session session = null;
1373    
1374                    try {
1375                            session = openSession();
1376    
1377                            DLFileVersion[] array = new DLFileVersionImpl[3];
1378    
1379                            array[0] = getByF_S_PrevAndNext(session, dlFileVersion,
1380                                            fileEntryId, status, orderByComparator, true);
1381    
1382                            array[1] = dlFileVersion;
1383    
1384                            array[2] = getByF_S_PrevAndNext(session, dlFileVersion,
1385                                            fileEntryId, status, orderByComparator, false);
1386    
1387                            return array;
1388                    }
1389                    catch (Exception e) {
1390                            throw processException(e);
1391                    }
1392                    finally {
1393                            closeSession(session);
1394                    }
1395            }
1396    
1397            protected DLFileVersion getByF_S_PrevAndNext(Session session,
1398                    DLFileVersion dlFileVersion, long fileEntryId, int status,
1399                    OrderByComparator orderByComparator, boolean previous) {
1400                    StringBundler query = null;
1401    
1402                    if (orderByComparator != null) {
1403                            query = new StringBundler(6 +
1404                                            (orderByComparator.getOrderByFields().length * 6));
1405                    }
1406                    else {
1407                            query = new StringBundler(3);
1408                    }
1409    
1410                    query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1411    
1412                    query.append(_FINDER_COLUMN_F_S_FILEENTRYID_2);
1413    
1414                    query.append(_FINDER_COLUMN_F_S_STATUS_2);
1415    
1416                    if (orderByComparator != null) {
1417                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1418    
1419                            if (orderByConditionFields.length > 0) {
1420                                    query.append(WHERE_AND);
1421                            }
1422    
1423                            for (int i = 0; i < orderByConditionFields.length; i++) {
1424                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1425                                    query.append(orderByConditionFields[i]);
1426    
1427                                    if ((i + 1) < orderByConditionFields.length) {
1428                                            if (orderByComparator.isAscending() ^ previous) {
1429                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1430                                            }
1431                                            else {
1432                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1433                                            }
1434                                    }
1435                                    else {
1436                                            if (orderByComparator.isAscending() ^ previous) {
1437                                                    query.append(WHERE_GREATER_THAN);
1438                                            }
1439                                            else {
1440                                                    query.append(WHERE_LESSER_THAN);
1441                                            }
1442                                    }
1443                            }
1444    
1445                            query.append(ORDER_BY_CLAUSE);
1446    
1447                            String[] orderByFields = orderByComparator.getOrderByFields();
1448    
1449                            for (int i = 0; i < orderByFields.length; i++) {
1450                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1451                                    query.append(orderByFields[i]);
1452    
1453                                    if ((i + 1) < orderByFields.length) {
1454                                            if (orderByComparator.isAscending() ^ previous) {
1455                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1456                                            }
1457                                            else {
1458                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1459                                            }
1460                                    }
1461                                    else {
1462                                            if (orderByComparator.isAscending() ^ previous) {
1463                                                    query.append(ORDER_BY_ASC);
1464                                            }
1465                                            else {
1466                                                    query.append(ORDER_BY_DESC);
1467                                            }
1468                                    }
1469                            }
1470                    }
1471    
1472                    else {
1473                            query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1474                    }
1475    
1476                    String sql = query.toString();
1477    
1478                    Query q = session.createQuery(sql);
1479    
1480                    q.setFirstResult(0);
1481                    q.setMaxResults(2);
1482    
1483                    QueryPos qPos = QueryPos.getInstance(q);
1484    
1485                    qPos.add(fileEntryId);
1486    
1487                    qPos.add(status);
1488    
1489                    if (orderByComparator != null) {
1490                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
1491    
1492                            for (Object value : values) {
1493                                    qPos.add(value);
1494                            }
1495                    }
1496    
1497                    List<DLFileVersion> list = q.list();
1498    
1499                    if (list.size() == 2) {
1500                            return list.get(1);
1501                    }
1502                    else {
1503                            return null;
1504                    }
1505            }
1506    
1507            /**
1508             * Returns all the document library file versions where groupId = &#63; and folderId = &#63; and status = &#63;.
1509             *
1510             * @param groupId the group ID
1511             * @param folderId the folder ID
1512             * @param status the status
1513             * @return the matching document library file versions
1514             * @throws SystemException if a system exception occurred
1515             */
1516            public List<DLFileVersion> findByG_F_S(long groupId, long folderId,
1517                    int status) throws SystemException {
1518                    return findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
1519                            QueryUtil.ALL_POS, null);
1520            }
1521    
1522            /**
1523             * Returns a range of all the document library file versions where groupId = &#63; and folderId = &#63; and status = &#63;.
1524             *
1525             * <p>
1526             * 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.
1527             * </p>
1528             *
1529             * @param groupId the group ID
1530             * @param folderId the folder ID
1531             * @param status the status
1532             * @param start the lower bound of the range of document library file versions
1533             * @param end the upper bound of the range of document library file versions (not inclusive)
1534             * @return the range of matching document library file versions
1535             * @throws SystemException if a system exception occurred
1536             */
1537            public List<DLFileVersion> findByG_F_S(long groupId, long folderId,
1538                    int status, int start, int end) throws SystemException {
1539                    return findByG_F_S(groupId, folderId, status, start, end, null);
1540            }
1541    
1542            /**
1543             * Returns an ordered range of all the document library file versions where groupId = &#63; and folderId = &#63; and status = &#63;.
1544             *
1545             * <p>
1546             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1547             * </p>
1548             *
1549             * @param groupId the group ID
1550             * @param folderId the folder ID
1551             * @param status the status
1552             * @param start the lower bound of the range of document library file versions
1553             * @param end the upper bound of the range of document library file versions (not inclusive)
1554             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1555             * @return the ordered range of matching document library file versions
1556             * @throws SystemException if a system exception occurred
1557             */
1558            public List<DLFileVersion> findByG_F_S(long groupId, long folderId,
1559                    int status, int start, int end, OrderByComparator orderByComparator)
1560                    throws SystemException {
1561                    FinderPath finderPath = null;
1562                    Object[] finderArgs = null;
1563    
1564                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1565                                    (orderByComparator == null)) {
1566                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S;
1567                            finderArgs = new Object[] { groupId, folderId, status };
1568                    }
1569                    else {
1570                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S;
1571                            finderArgs = new Object[] {
1572                                            groupId, folderId, status,
1573                                            
1574                                            start, end, orderByComparator
1575                                    };
1576                    }
1577    
1578                    List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
1579                                    finderArgs, this);
1580    
1581                    if (list == null) {
1582                            StringBundler query = null;
1583    
1584                            if (orderByComparator != null) {
1585                                    query = new StringBundler(5 +
1586                                                    (orderByComparator.getOrderByFields().length * 3));
1587                            }
1588                            else {
1589                                    query = new StringBundler(5);
1590                            }
1591    
1592                            query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1593    
1594                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
1595    
1596                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
1597    
1598                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
1599    
1600                            if (orderByComparator != null) {
1601                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1602                                            orderByComparator);
1603                            }
1604    
1605                            else {
1606                                    query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1607                            }
1608    
1609                            String sql = query.toString();
1610    
1611                            Session session = null;
1612    
1613                            try {
1614                                    session = openSession();
1615    
1616                                    Query q = session.createQuery(sql);
1617    
1618                                    QueryPos qPos = QueryPos.getInstance(q);
1619    
1620                                    qPos.add(groupId);
1621    
1622                                    qPos.add(folderId);
1623    
1624                                    qPos.add(status);
1625    
1626                                    list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1627                                                    start, end);
1628                            }
1629                            catch (Exception e) {
1630                                    throw processException(e);
1631                            }
1632                            finally {
1633                                    if (list == null) {
1634                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1635                                    }
1636                                    else {
1637                                            cacheResult(list);
1638    
1639                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1640                                    }
1641    
1642                                    closeSession(session);
1643                            }
1644                    }
1645    
1646                    return list;
1647            }
1648    
1649            /**
1650             * Returns the first document library file version in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
1651             *
1652             * <p>
1653             * 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.
1654             * </p>
1655             *
1656             * @param groupId the group ID
1657             * @param folderId the folder ID
1658             * @param status the status
1659             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1660             * @return the first matching document library file version
1661             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a matching document library file version could not be found
1662             * @throws SystemException if a system exception occurred
1663             */
1664            public DLFileVersion findByG_F_S_First(long groupId, long folderId,
1665                    int status, OrderByComparator orderByComparator)
1666                    throws NoSuchFileVersionException, SystemException {
1667                    List<DLFileVersion> list = findByG_F_S(groupId, folderId, status, 0, 1,
1668                                    orderByComparator);
1669    
1670                    if (list.isEmpty()) {
1671                            StringBundler msg = new StringBundler(8);
1672    
1673                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1674    
1675                            msg.append("groupId=");
1676                            msg.append(groupId);
1677    
1678                            msg.append(", folderId=");
1679                            msg.append(folderId);
1680    
1681                            msg.append(", status=");
1682                            msg.append(status);
1683    
1684                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1685    
1686                            throw new NoSuchFileVersionException(msg.toString());
1687                    }
1688                    else {
1689                            return list.get(0);
1690                    }
1691            }
1692    
1693            /**
1694             * Returns the last document library file version in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
1695             *
1696             * <p>
1697             * 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.
1698             * </p>
1699             *
1700             * @param groupId the group ID
1701             * @param folderId the folder ID
1702             * @param status the status
1703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1704             * @return the last matching document library file version
1705             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a matching document library file version could not be found
1706             * @throws SystemException if a system exception occurred
1707             */
1708            public DLFileVersion findByG_F_S_Last(long groupId, long folderId,
1709                    int status, OrderByComparator orderByComparator)
1710                    throws NoSuchFileVersionException, SystemException {
1711                    int count = countByG_F_S(groupId, folderId, status);
1712    
1713                    List<DLFileVersion> list = findByG_F_S(groupId, folderId, status,
1714                                    count - 1, count, orderByComparator);
1715    
1716                    if (list.isEmpty()) {
1717                            StringBundler msg = new StringBundler(8);
1718    
1719                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1720    
1721                            msg.append("groupId=");
1722                            msg.append(groupId);
1723    
1724                            msg.append(", folderId=");
1725                            msg.append(folderId);
1726    
1727                            msg.append(", status=");
1728                            msg.append(status);
1729    
1730                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1731    
1732                            throw new NoSuchFileVersionException(msg.toString());
1733                    }
1734                    else {
1735                            return list.get(0);
1736                    }
1737            }
1738    
1739            /**
1740             * Returns the document library file versions before and after the current document library file version in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
1741             *
1742             * <p>
1743             * 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.
1744             * </p>
1745             *
1746             * @param fileVersionId the primary key of the current document library file version
1747             * @param groupId the group ID
1748             * @param folderId the folder ID
1749             * @param status the status
1750             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1751             * @return the previous, current, and next document library file version
1752             * @throws com.liferay.portlet.documentlibrary.NoSuchFileVersionException if a document library file version with the primary key could not be found
1753             * @throws SystemException if a system exception occurred
1754             */
1755            public DLFileVersion[] findByG_F_S_PrevAndNext(long fileVersionId,
1756                    long groupId, long folderId, int status,
1757                    OrderByComparator orderByComparator)
1758                    throws NoSuchFileVersionException, SystemException {
1759                    DLFileVersion dlFileVersion = findByPrimaryKey(fileVersionId);
1760    
1761                    Session session = null;
1762    
1763                    try {
1764                            session = openSession();
1765    
1766                            DLFileVersion[] array = new DLFileVersionImpl[3];
1767    
1768                            array[0] = getByG_F_S_PrevAndNext(session, dlFileVersion, groupId,
1769                                            folderId, status, orderByComparator, true);
1770    
1771                            array[1] = dlFileVersion;
1772    
1773                            array[2] = getByG_F_S_PrevAndNext(session, dlFileVersion, groupId,
1774                                            folderId, status, orderByComparator, false);
1775    
1776                            return array;
1777                    }
1778                    catch (Exception e) {
1779                            throw processException(e);
1780                    }
1781                    finally {
1782                            closeSession(session);
1783                    }
1784            }
1785    
1786            protected DLFileVersion getByG_F_S_PrevAndNext(Session session,
1787                    DLFileVersion dlFileVersion, long groupId, long folderId, int status,
1788                    OrderByComparator orderByComparator, boolean previous) {
1789                    StringBundler query = null;
1790    
1791                    if (orderByComparator != null) {
1792                            query = new StringBundler(6 +
1793                                            (orderByComparator.getOrderByFields().length * 6));
1794                    }
1795                    else {
1796                            query = new StringBundler(3);
1797                    }
1798    
1799                    query.append(_SQL_SELECT_DLFILEVERSION_WHERE);
1800    
1801                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
1802    
1803                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
1804    
1805                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
1806    
1807                    if (orderByComparator != null) {
1808                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1809    
1810                            if (orderByConditionFields.length > 0) {
1811                                    query.append(WHERE_AND);
1812                            }
1813    
1814                            for (int i = 0; i < orderByConditionFields.length; i++) {
1815                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1816                                    query.append(orderByConditionFields[i]);
1817    
1818                                    if ((i + 1) < orderByConditionFields.length) {
1819                                            if (orderByComparator.isAscending() ^ previous) {
1820                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1821                                            }
1822                                            else {
1823                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1824                                            }
1825                                    }
1826                                    else {
1827                                            if (orderByComparator.isAscending() ^ previous) {
1828                                                    query.append(WHERE_GREATER_THAN);
1829                                            }
1830                                            else {
1831                                                    query.append(WHERE_LESSER_THAN);
1832                                            }
1833                                    }
1834                            }
1835    
1836                            query.append(ORDER_BY_CLAUSE);
1837    
1838                            String[] orderByFields = orderByComparator.getOrderByFields();
1839    
1840                            for (int i = 0; i < orderByFields.length; i++) {
1841                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1842                                    query.append(orderByFields[i]);
1843    
1844                                    if ((i + 1) < orderByFields.length) {
1845                                            if (orderByComparator.isAscending() ^ previous) {
1846                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1847                                            }
1848                                            else {
1849                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1850                                            }
1851                                    }
1852                                    else {
1853                                            if (orderByComparator.isAscending() ^ previous) {
1854                                                    query.append(ORDER_BY_ASC);
1855                                            }
1856                                            else {
1857                                                    query.append(ORDER_BY_DESC);
1858                                            }
1859                                    }
1860                            }
1861                    }
1862    
1863                    else {
1864                            query.append(DLFileVersionModelImpl.ORDER_BY_JPQL);
1865                    }
1866    
1867                    String sql = query.toString();
1868    
1869                    Query q = session.createQuery(sql);
1870    
1871                    q.setFirstResult(0);
1872                    q.setMaxResults(2);
1873    
1874                    QueryPos qPos = QueryPos.getInstance(q);
1875    
1876                    qPos.add(groupId);
1877    
1878                    qPos.add(folderId);
1879    
1880                    qPos.add(status);
1881    
1882                    if (orderByComparator != null) {
1883                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileVersion);
1884    
1885                            for (Object value : values) {
1886                                    qPos.add(value);
1887                            }
1888                    }
1889    
1890                    List<DLFileVersion> list = q.list();
1891    
1892                    if (list.size() == 2) {
1893                            return list.get(1);
1894                    }
1895                    else {
1896                            return null;
1897                    }
1898            }
1899    
1900            /**
1901             * Returns all the document library file versions.
1902             *
1903             * @return the document library file versions
1904             * @throws SystemException if a system exception occurred
1905             */
1906            public List<DLFileVersion> findAll() throws SystemException {
1907                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1908            }
1909    
1910            /**
1911             * Returns a range of all the document library file versions.
1912             *
1913             * <p>
1914             * 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.
1915             * </p>
1916             *
1917             * @param start the lower bound of the range of document library file versions
1918             * @param end the upper bound of the range of document library file versions (not inclusive)
1919             * @return the range of document library file versions
1920             * @throws SystemException if a system exception occurred
1921             */
1922            public List<DLFileVersion> findAll(int start, int end)
1923                    throws SystemException {
1924                    return findAll(start, end, null);
1925            }
1926    
1927            /**
1928             * Returns an ordered range of all the document library file versions.
1929             *
1930             * <p>
1931             * 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.
1932             * </p>
1933             *
1934             * @param start the lower bound of the range of document library file versions
1935             * @param end the upper bound of the range of document library file versions (not inclusive)
1936             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1937             * @return the ordered range of document library file versions
1938             * @throws SystemException if a system exception occurred
1939             */
1940            public List<DLFileVersion> findAll(int start, int end,
1941                    OrderByComparator orderByComparator) throws SystemException {
1942                    FinderPath finderPath = null;
1943                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1944    
1945                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1946                                    (orderByComparator == null)) {
1947                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1948                            finderArgs = FINDER_ARGS_EMPTY;
1949                    }
1950                    else {
1951                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1952                            finderArgs = new Object[] { start, end, orderByComparator };
1953                    }
1954    
1955                    List<DLFileVersion> list = (List<DLFileVersion>)FinderCacheUtil.getResult(finderPath,
1956                                    finderArgs, this);
1957    
1958                    if (list == null) {
1959                            StringBundler query = null;
1960                            String sql = null;
1961    
1962                            if (orderByComparator != null) {
1963                                    query = new StringBundler(2 +
1964                                                    (orderByComparator.getOrderByFields().length * 3));
1965    
1966                                    query.append(_SQL_SELECT_DLFILEVERSION);
1967    
1968                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1969                                            orderByComparator);
1970    
1971                                    sql = query.toString();
1972                            }
1973                            else {
1974                                    sql = _SQL_SELECT_DLFILEVERSION.concat(DLFileVersionModelImpl.ORDER_BY_JPQL);
1975                            }
1976    
1977                            Session session = null;
1978    
1979                            try {
1980                                    session = openSession();
1981    
1982                                    Query q = session.createQuery(sql);
1983    
1984                                    if (orderByComparator == null) {
1985                                            list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1986                                                            start, end, false);
1987    
1988                                            Collections.sort(list);
1989                                    }
1990                                    else {
1991                                            list = (List<DLFileVersion>)QueryUtil.list(q, getDialect(),
1992                                                            start, end);
1993                                    }
1994                            }
1995                            catch (Exception e) {
1996                                    throw processException(e);
1997                            }
1998                            finally {
1999                                    if (list == null) {
2000                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2001                                    }
2002                                    else {
2003                                            cacheResult(list);
2004    
2005                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2006                                    }
2007    
2008                                    closeSession(session);
2009                            }
2010                    }
2011    
2012                    return list;
2013            }
2014    
2015            /**
2016             * Removes all the document library file versions where fileEntryId = &#63; from the database.
2017             *
2018             * @param fileEntryId the file entry ID
2019             * @throws SystemException if a system exception occurred
2020             */
2021            public void removeByFileEntryId(long fileEntryId) throws SystemException {
2022                    for (DLFileVersion dlFileVersion : findByFileEntryId(fileEntryId)) {
2023                            remove(dlFileVersion);
2024                    }
2025            }
2026    
2027            /**
2028             * Removes the document library file version where fileEntryId = &#63; and version = &#63; from the database.
2029             *
2030             * @param fileEntryId the file entry ID
2031             * @param version the version
2032             * @throws SystemException if a system exception occurred
2033             */
2034            public void removeByF_V(long fileEntryId, String version)
2035                    throws NoSuchFileVersionException, SystemException {
2036                    DLFileVersion dlFileVersion = findByF_V(fileEntryId, version);
2037    
2038                    remove(dlFileVersion);
2039            }
2040    
2041            /**
2042             * Removes all the document library file versions where fileEntryId = &#63; and status = &#63; from the database.
2043             *
2044             * @param fileEntryId the file entry ID
2045             * @param status the status
2046             * @throws SystemException if a system exception occurred
2047             */
2048            public void removeByF_S(long fileEntryId, int status)
2049                    throws SystemException {
2050                    for (DLFileVersion dlFileVersion : findByF_S(fileEntryId, status)) {
2051                            remove(dlFileVersion);
2052                    }
2053            }
2054    
2055            /**
2056             * Removes all the document library file versions where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
2057             *
2058             * @param groupId the group ID
2059             * @param folderId the folder ID
2060             * @param status the status
2061             * @throws SystemException if a system exception occurred
2062             */
2063            public void removeByG_F_S(long groupId, long folderId, int status)
2064                    throws SystemException {
2065                    for (DLFileVersion dlFileVersion : findByG_F_S(groupId, folderId, status)) {
2066                            remove(dlFileVersion);
2067                    }
2068            }
2069    
2070            /**
2071             * Removes all the document library file versions from the database.
2072             *
2073             * @throws SystemException if a system exception occurred
2074             */
2075            public void removeAll() throws SystemException {
2076                    for (DLFileVersion dlFileVersion : findAll()) {
2077                            remove(dlFileVersion);
2078                    }
2079            }
2080    
2081            /**
2082             * Returns the number of document library file versions where fileEntryId = &#63;.
2083             *
2084             * @param fileEntryId the file entry ID
2085             * @return the number of matching document library file versions
2086             * @throws SystemException if a system exception occurred
2087             */
2088            public int countByFileEntryId(long fileEntryId) throws SystemException {
2089                    Object[] finderArgs = new Object[] { fileEntryId };
2090    
2091                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2092                                    finderArgs, this);
2093    
2094                    if (count == null) {
2095                            StringBundler query = new StringBundler(2);
2096    
2097                            query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
2098    
2099                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
2100    
2101                            String sql = query.toString();
2102    
2103                            Session session = null;
2104    
2105                            try {
2106                                    session = openSession();
2107    
2108                                    Query q = session.createQuery(sql);
2109    
2110                                    QueryPos qPos = QueryPos.getInstance(q);
2111    
2112                                    qPos.add(fileEntryId);
2113    
2114                                    count = (Long)q.uniqueResult();
2115                            }
2116                            catch (Exception e) {
2117                                    throw processException(e);
2118                            }
2119                            finally {
2120                                    if (count == null) {
2121                                            count = Long.valueOf(0);
2122                                    }
2123    
2124                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2125                                            finderArgs, count);
2126    
2127                                    closeSession(session);
2128                            }
2129                    }
2130    
2131                    return count.intValue();
2132            }
2133    
2134            /**
2135             * Returns the number of document library file versions where fileEntryId = &#63; and version = &#63;.
2136             *
2137             * @param fileEntryId the file entry ID
2138             * @param version the version
2139             * @return the number of matching document library file versions
2140             * @throws SystemException if a system exception occurred
2141             */
2142            public int countByF_V(long fileEntryId, String version)
2143                    throws SystemException {
2144                    Object[] finderArgs = new Object[] { fileEntryId, version };
2145    
2146                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_V,
2147                                    finderArgs, this);
2148    
2149                    if (count == null) {
2150                            StringBundler query = new StringBundler(3);
2151    
2152                            query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
2153    
2154                            query.append(_FINDER_COLUMN_F_V_FILEENTRYID_2);
2155    
2156                            if (version == null) {
2157                                    query.append(_FINDER_COLUMN_F_V_VERSION_1);
2158                            }
2159                            else {
2160                                    if (version.equals(StringPool.BLANK)) {
2161                                            query.append(_FINDER_COLUMN_F_V_VERSION_3);
2162                                    }
2163                                    else {
2164                                            query.append(_FINDER_COLUMN_F_V_VERSION_2);
2165                                    }
2166                            }
2167    
2168                            String sql = query.toString();
2169    
2170                            Session session = null;
2171    
2172                            try {
2173                                    session = openSession();
2174    
2175                                    Query q = session.createQuery(sql);
2176    
2177                                    QueryPos qPos = QueryPos.getInstance(q);
2178    
2179                                    qPos.add(fileEntryId);
2180    
2181                                    if (version != null) {
2182                                            qPos.add(version);
2183                                    }
2184    
2185                                    count = (Long)q.uniqueResult();
2186                            }
2187                            catch (Exception e) {
2188                                    throw processException(e);
2189                            }
2190                            finally {
2191                                    if (count == null) {
2192                                            count = Long.valueOf(0);
2193                                    }
2194    
2195                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_V, finderArgs,
2196                                            count);
2197    
2198                                    closeSession(session);
2199                            }
2200                    }
2201    
2202                    return count.intValue();
2203            }
2204    
2205            /**
2206             * Returns the number of document library file versions where fileEntryId = &#63; and status = &#63;.
2207             *
2208             * @param fileEntryId the file entry ID
2209             * @param status the status
2210             * @return the number of matching document library file versions
2211             * @throws SystemException if a system exception occurred
2212             */
2213            public int countByF_S(long fileEntryId, int status)
2214                    throws SystemException {
2215                    Object[] finderArgs = new Object[] { fileEntryId, status };
2216    
2217                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_S,
2218                                    finderArgs, this);
2219    
2220                    if (count == null) {
2221                            StringBundler query = new StringBundler(3);
2222    
2223                            query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
2224    
2225                            query.append(_FINDER_COLUMN_F_S_FILEENTRYID_2);
2226    
2227                            query.append(_FINDER_COLUMN_F_S_STATUS_2);
2228    
2229                            String sql = query.toString();
2230    
2231                            Session session = null;
2232    
2233                            try {
2234                                    session = openSession();
2235    
2236                                    Query q = session.createQuery(sql);
2237    
2238                                    QueryPos qPos = QueryPos.getInstance(q);
2239    
2240                                    qPos.add(fileEntryId);
2241    
2242                                    qPos.add(status);
2243    
2244                                    count = (Long)q.uniqueResult();
2245                            }
2246                            catch (Exception e) {
2247                                    throw processException(e);
2248                            }
2249                            finally {
2250                                    if (count == null) {
2251                                            count = Long.valueOf(0);
2252                                    }
2253    
2254                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_S, finderArgs,
2255                                            count);
2256    
2257                                    closeSession(session);
2258                            }
2259                    }
2260    
2261                    return count.intValue();
2262            }
2263    
2264            /**
2265             * Returns the number of document library file versions where groupId = &#63; and folderId = &#63; and status = &#63;.
2266             *
2267             * @param groupId the group ID
2268             * @param folderId the folder ID
2269             * @param status the status
2270             * @return the number of matching document library file versions
2271             * @throws SystemException if a system exception occurred
2272             */
2273            public int countByG_F_S(long groupId, long folderId, int status)
2274                    throws SystemException {
2275                    Object[] finderArgs = new Object[] { groupId, folderId, status };
2276    
2277                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_S,
2278                                    finderArgs, this);
2279    
2280                    if (count == null) {
2281                            StringBundler query = new StringBundler(4);
2282    
2283                            query.append(_SQL_COUNT_DLFILEVERSION_WHERE);
2284    
2285                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
2286    
2287                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
2288    
2289                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
2290    
2291                            String sql = query.toString();
2292    
2293                            Session session = null;
2294    
2295                            try {
2296                                    session = openSession();
2297    
2298                                    Query q = session.createQuery(sql);
2299    
2300                                    QueryPos qPos = QueryPos.getInstance(q);
2301    
2302                                    qPos.add(groupId);
2303    
2304                                    qPos.add(folderId);
2305    
2306                                    qPos.add(status);
2307    
2308                                    count = (Long)q.uniqueResult();
2309                            }
2310                            catch (Exception e) {
2311                                    throw processException(e);
2312                            }
2313                            finally {
2314                                    if (count == null) {
2315                                            count = Long.valueOf(0);
2316                                    }
2317    
2318                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F_S,
2319                                            finderArgs, count);
2320    
2321                                    closeSession(session);
2322                            }
2323                    }
2324    
2325                    return count.intValue();
2326            }
2327    
2328            /**
2329             * Returns the number of document library file versions.
2330             *
2331             * @return the number of document library file versions
2332             * @throws SystemException if a system exception occurred
2333             */
2334            public int countAll() throws SystemException {
2335                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2336                                    FINDER_ARGS_EMPTY, this);
2337    
2338                    if (count == null) {
2339                            Session session = null;
2340    
2341                            try {
2342                                    session = openSession();
2343    
2344                                    Query q = session.createQuery(_SQL_COUNT_DLFILEVERSION);
2345    
2346                                    count = (Long)q.uniqueResult();
2347                            }
2348                            catch (Exception e) {
2349                                    throw processException(e);
2350                            }
2351                            finally {
2352                                    if (count == null) {
2353                                            count = Long.valueOf(0);
2354                                    }
2355    
2356                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2357                                            FINDER_ARGS_EMPTY, count);
2358    
2359                                    closeSession(session);
2360                            }
2361                    }
2362    
2363                    return count.intValue();
2364            }
2365    
2366            /**
2367             * Initializes the document library file version persistence.
2368             */
2369            public void afterPropertiesSet() {
2370                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2371                                            com.liferay.portal.util.PropsUtil.get(
2372                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileVersion")));
2373    
2374                    if (listenerClassNames.length > 0) {
2375                            try {
2376                                    List<ModelListener<DLFileVersion>> listenersList = new ArrayList<ModelListener<DLFileVersion>>();
2377    
2378                                    for (String listenerClassName : listenerClassNames) {
2379                                            listenersList.add((ModelListener<DLFileVersion>)InstanceFactory.newInstance(
2380                                                            listenerClassName));
2381                                    }
2382    
2383                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2384                            }
2385                            catch (Exception e) {
2386                                    _log.error(e);
2387                            }
2388                    }
2389            }
2390    
2391            public void destroy() {
2392                    EntityCacheUtil.removeCache(DLFileVersionImpl.class.getName());
2393                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2394                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2395            }
2396    
2397            @BeanReference(type = DLContentPersistence.class)
2398            protected DLContentPersistence dlContentPersistence;
2399            @BeanReference(type = DLFileEntryPersistence.class)
2400            protected DLFileEntryPersistence dlFileEntryPersistence;
2401            @BeanReference(type = DLFileEntryMetadataPersistence.class)
2402            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
2403            @BeanReference(type = DLFileEntryTypePersistence.class)
2404            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
2405            @BeanReference(type = DLFileRankPersistence.class)
2406            protected DLFileRankPersistence dlFileRankPersistence;
2407            @BeanReference(type = DLFileShortcutPersistence.class)
2408            protected DLFileShortcutPersistence dlFileShortcutPersistence;
2409            @BeanReference(type = DLFileVersionPersistence.class)
2410            protected DLFileVersionPersistence dlFileVersionPersistence;
2411            @BeanReference(type = DLFolderPersistence.class)
2412            protected DLFolderPersistence dlFolderPersistence;
2413            @BeanReference(type = DLSyncPersistence.class)
2414            protected DLSyncPersistence dlSyncPersistence;
2415            @BeanReference(type = ResourcePersistence.class)
2416            protected ResourcePersistence resourcePersistence;
2417            @BeanReference(type = UserPersistence.class)
2418            protected UserPersistence userPersistence;
2419            private static final String _SQL_SELECT_DLFILEVERSION = "SELECT dlFileVersion FROM DLFileVersion dlFileVersion";
2420            private static final String _SQL_SELECT_DLFILEVERSION_WHERE = "SELECT dlFileVersion FROM DLFileVersion dlFileVersion WHERE ";
2421            private static final String _SQL_COUNT_DLFILEVERSION = "SELECT COUNT(dlFileVersion) FROM DLFileVersion dlFileVersion";
2422            private static final String _SQL_COUNT_DLFILEVERSION_WHERE = "SELECT COUNT(dlFileVersion) FROM DLFileVersion dlFileVersion WHERE ";
2423            private static final String _FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2 = "dlFileVersion.fileEntryId = ?";
2424            private static final String _FINDER_COLUMN_F_V_FILEENTRYID_2 = "dlFileVersion.fileEntryId = ? AND ";
2425            private static final String _FINDER_COLUMN_F_V_VERSION_1 = "dlFileVersion.version IS NULL";
2426            private static final String _FINDER_COLUMN_F_V_VERSION_2 = "dlFileVersion.version = ?";
2427            private static final String _FINDER_COLUMN_F_V_VERSION_3 = "(dlFileVersion.version IS NULL OR dlFileVersion.version = ?)";
2428            private static final String _FINDER_COLUMN_F_S_FILEENTRYID_2 = "dlFileVersion.fileEntryId = ? AND ";
2429            private static final String _FINDER_COLUMN_F_S_STATUS_2 = "dlFileVersion.status = ?";
2430            private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "dlFileVersion.groupId = ? AND ";
2431            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "dlFileVersion.folderId = ? AND ";
2432            private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "dlFileVersion.status = ?";
2433            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileVersion.";
2434            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileVersion exists with the primary key ";
2435            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileVersion exists with the key {";
2436            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2437            private static Log _log = LogFactoryUtil.getLog(DLFileVersionPersistenceImpl.class);
2438            private static DLFileVersion _nullDLFileVersion = new DLFileVersionImpl() {
2439                            @Override
2440                            public Object clone() {
2441                                    return this;
2442                            }
2443    
2444                            @Override
2445                            public CacheModel<DLFileVersion> toCacheModel() {
2446                                    return _nullDLFileVersionCacheModel;
2447                            }
2448                    };
2449    
2450            private static CacheModel<DLFileVersion> _nullDLFileVersionCacheModel = new CacheModel<DLFileVersion>() {
2451                            public DLFileVersion toEntityModel() {
2452                                    return _nullDLFileVersion;
2453                            }
2454                    };
2455    }