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