001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.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.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.service.persistence.UserPersistence;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException;
044    import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata;
045    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataImpl;
046    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataModelImpl;
047    import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructureLinkPersistence;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    
055    /**
056     * The persistence implementation for the document library file entry metadata service.
057     *
058     * <p>
059     * Caching information and settings can be found in <code>portal.properties</code>
060     * </p>
061     *
062     * @author Brian Wing Shun Chan
063     * @see DLFileEntryMetadataPersistence
064     * @see DLFileEntryMetadataUtil
065     * @generated
066     */
067    public class DLFileEntryMetadataPersistenceImpl extends BasePersistenceImpl<DLFileEntryMetadata>
068            implements DLFileEntryMetadataPersistence {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link DLFileEntryMetadataUtil} to access the document library file entry metadata persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
073             */
074            public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryMetadataImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List1";
077            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List2";
079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
080                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
081                            DLFileEntryMetadataImpl.class,
082                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
083                            new String[] {
084                                    String.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_UUID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
090                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
091                            DLFileEntryMetadataImpl.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
093                            new String[] { String.class.getName() },
094                            DLFileEntryMetadataModelImpl.UUID_COLUMN_BITMASK);
095            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
096                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
098                            new String[] { String.class.getName() });
099            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYTYPEID =
100                    new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
101                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
102                            DLFileEntryMetadataImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileEntryTypeId",
104                            new String[] {
105                                    Long.class.getName(),
106                                    
107                            "java.lang.Integer", "java.lang.Integer",
108                                    "com.liferay.portal.kernel.util.OrderByComparator"
109                            });
110            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID =
111                    new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
112                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
113                            DLFileEntryMetadataImpl.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileEntryTypeId",
115                            new String[] { Long.class.getName() },
116                            DLFileEntryMetadataModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK);
117            public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYTYPEID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
118                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
119                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
120                            "countByFileEntryTypeId", new String[] { Long.class.getName() });
121            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID =
122                    new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
123                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
124                            DLFileEntryMetadataImpl.class,
125                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileEntryId",
126                            new String[] {
127                                    Long.class.getName(),
128                                    
129                            "java.lang.Integer", "java.lang.Integer",
130                                    "com.liferay.portal.kernel.util.OrderByComparator"
131                            });
132            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID =
133                    new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
134                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
135                            DLFileEntryMetadataImpl.class,
136                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileEntryId",
137                            new String[] { Long.class.getName() },
138                            DLFileEntryMetadataModelImpl.FILEENTRYID_COLUMN_BITMASK);
139            public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
140                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
141                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFileEntryId",
142                            new String[] { Long.class.getName() });
143            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEVERSIONID =
144                    new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
145                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
146                            DLFileEntryMetadataImpl.class,
147                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileVersionId",
148                            new String[] {
149                                    Long.class.getName(),
150                                    
151                            "java.lang.Integer", "java.lang.Integer",
152                                    "com.liferay.portal.kernel.util.OrderByComparator"
153                            });
154            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID =
155                    new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
156                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
157                            DLFileEntryMetadataImpl.class,
158                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileVersionId",
159                            new String[] { Long.class.getName() },
160                            DLFileEntryMetadataModelImpl.FILEVERSIONID_COLUMN_BITMASK);
161            public static final FinderPath FINDER_PATH_COUNT_BY_FILEVERSIONID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
162                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFileVersionId",
164                            new String[] { Long.class.getName() });
165            public static final FinderPath FINDER_PATH_FETCH_BY_D_F = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
166                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
167                            DLFileEntryMetadataImpl.class, FINDER_CLASS_NAME_ENTITY,
168                            "fetchByD_F",
169                            new String[] { Long.class.getName(), Long.class.getName() },
170                            DLFileEntryMetadataModelImpl.DDMSTRUCTUREID_COLUMN_BITMASK |
171                            DLFileEntryMetadataModelImpl.FILEVERSIONID_COLUMN_BITMASK);
172            public static final FinderPath FINDER_PATH_COUNT_BY_D_F = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
173                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
174                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByD_F",
175                            new String[] { Long.class.getName(), Long.class.getName() });
176            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
177                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
178                            DLFileEntryMetadataImpl.class,
179                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
180            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
181                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
182                            DLFileEntryMetadataImpl.class,
183                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
184            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
185                            DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
186                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
187    
188            /**
189             * Caches the document library file entry metadata in the entity cache if it is enabled.
190             *
191             * @param dlFileEntryMetadata the document library file entry metadata
192             */
193            public void cacheResult(DLFileEntryMetadata dlFileEntryMetadata) {
194                    EntityCacheUtil.putResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
195                            DLFileEntryMetadataImpl.class, dlFileEntryMetadata.getPrimaryKey(),
196                            dlFileEntryMetadata);
197    
198                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F,
199                            new Object[] {
200                                    Long.valueOf(dlFileEntryMetadata.getDDMStructureId()),
201                                    Long.valueOf(dlFileEntryMetadata.getFileVersionId())
202                            }, dlFileEntryMetadata);
203    
204                    dlFileEntryMetadata.resetOriginalValues();
205            }
206    
207            /**
208             * Caches the document library file entry metadatas in the entity cache if it is enabled.
209             *
210             * @param dlFileEntryMetadatas the document library file entry metadatas
211             */
212            public void cacheResult(List<DLFileEntryMetadata> dlFileEntryMetadatas) {
213                    for (DLFileEntryMetadata dlFileEntryMetadata : dlFileEntryMetadatas) {
214                            if (EntityCacheUtil.getResult(
215                                                    DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
216                                                    DLFileEntryMetadataImpl.class,
217                                                    dlFileEntryMetadata.getPrimaryKey()) == null) {
218                                    cacheResult(dlFileEntryMetadata);
219                            }
220                            else {
221                                    dlFileEntryMetadata.resetOriginalValues();
222                            }
223                    }
224            }
225    
226            /**
227             * Clears the cache for all document library file entry metadatas.
228             *
229             * <p>
230             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
231             * </p>
232             */
233            @Override
234            public void clearCache() {
235                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
236                            CacheRegistryUtil.clear(DLFileEntryMetadataImpl.class.getName());
237                    }
238    
239                    EntityCacheUtil.clearCache(DLFileEntryMetadataImpl.class.getName());
240    
241                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
242                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
243                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
244            }
245    
246            /**
247             * Clears the cache for the document library file entry metadata.
248             *
249             * <p>
250             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
251             * </p>
252             */
253            @Override
254            public void clearCache(DLFileEntryMetadata dlFileEntryMetadata) {
255                    EntityCacheUtil.removeResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
256                            DLFileEntryMetadataImpl.class, dlFileEntryMetadata.getPrimaryKey());
257    
258                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
259                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
260    
261                    clearUniqueFindersCache(dlFileEntryMetadata);
262            }
263    
264            @Override
265            public void clearCache(List<DLFileEntryMetadata> dlFileEntryMetadatas) {
266                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
267                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
268    
269                    for (DLFileEntryMetadata dlFileEntryMetadata : dlFileEntryMetadatas) {
270                            EntityCacheUtil.removeResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
271                                    DLFileEntryMetadataImpl.class,
272                                    dlFileEntryMetadata.getPrimaryKey());
273    
274                            clearUniqueFindersCache(dlFileEntryMetadata);
275                    }
276            }
277    
278            protected void clearUniqueFindersCache(
279                    DLFileEntryMetadata dlFileEntryMetadata) {
280                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_D_F,
281                            new Object[] {
282                                    Long.valueOf(dlFileEntryMetadata.getDDMStructureId()),
283                                    Long.valueOf(dlFileEntryMetadata.getFileVersionId())
284                            });
285            }
286    
287            /**
288             * Creates a new document library file entry metadata with the primary key. Does not add the document library file entry metadata to the database.
289             *
290             * @param fileEntryMetadataId the primary key for the new document library file entry metadata
291             * @return the new document library file entry metadata
292             */
293            public DLFileEntryMetadata create(long fileEntryMetadataId) {
294                    DLFileEntryMetadata dlFileEntryMetadata = new DLFileEntryMetadataImpl();
295    
296                    dlFileEntryMetadata.setNew(true);
297                    dlFileEntryMetadata.setPrimaryKey(fileEntryMetadataId);
298    
299                    String uuid = PortalUUIDUtil.generate();
300    
301                    dlFileEntryMetadata.setUuid(uuid);
302    
303                    return dlFileEntryMetadata;
304            }
305    
306            /**
307             * Removes the document library file entry metadata with the primary key from the database. Also notifies the appropriate model listeners.
308             *
309             * @param fileEntryMetadataId the primary key of the document library file entry metadata
310             * @return the document library file entry metadata that was removed
311             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a document library file entry metadata with the primary key could not be found
312             * @throws SystemException if a system exception occurred
313             */
314            public DLFileEntryMetadata remove(long fileEntryMetadataId)
315                    throws NoSuchFileEntryMetadataException, SystemException {
316                    return remove(Long.valueOf(fileEntryMetadataId));
317            }
318    
319            /**
320             * Removes the document library file entry metadata with the primary key from the database. Also notifies the appropriate model listeners.
321             *
322             * @param primaryKey the primary key of the document library file entry metadata
323             * @return the document library file entry metadata that was removed
324             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a document library file entry metadata with the primary key could not be found
325             * @throws SystemException if a system exception occurred
326             */
327            @Override
328            public DLFileEntryMetadata remove(Serializable primaryKey)
329                    throws NoSuchFileEntryMetadataException, SystemException {
330                    Session session = null;
331    
332                    try {
333                            session = openSession();
334    
335                            DLFileEntryMetadata dlFileEntryMetadata = (DLFileEntryMetadata)session.get(DLFileEntryMetadataImpl.class,
336                                            primaryKey);
337    
338                            if (dlFileEntryMetadata == null) {
339                                    if (_log.isWarnEnabled()) {
340                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
341                                    }
342    
343                                    throw new NoSuchFileEntryMetadataException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
344                                            primaryKey);
345                            }
346    
347                            return remove(dlFileEntryMetadata);
348                    }
349                    catch (NoSuchFileEntryMetadataException nsee) {
350                            throw nsee;
351                    }
352                    catch (Exception e) {
353                            throw processException(e);
354                    }
355                    finally {
356                            closeSession(session);
357                    }
358            }
359    
360            @Override
361            protected DLFileEntryMetadata removeImpl(
362                    DLFileEntryMetadata dlFileEntryMetadata) throws SystemException {
363                    dlFileEntryMetadata = toUnwrappedModel(dlFileEntryMetadata);
364    
365                    Session session = null;
366    
367                    try {
368                            session = openSession();
369    
370                            if (dlFileEntryMetadata.isCachedModel()) {
371                                    dlFileEntryMetadata = (DLFileEntryMetadata)session.get(DLFileEntryMetadataImpl.class,
372                                                    dlFileEntryMetadata.getPrimaryKeyObj());
373                            }
374    
375                            session.delete(dlFileEntryMetadata);
376                    }
377                    catch (Exception e) {
378                            throw processException(e);
379                    }
380                    finally {
381                            closeSession(session);
382                    }
383    
384                    clearCache(dlFileEntryMetadata);
385    
386                    return dlFileEntryMetadata;
387            }
388    
389            @Override
390            public DLFileEntryMetadata updateImpl(
391                    com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata dlFileEntryMetadata)
392                    throws SystemException {
393                    dlFileEntryMetadata = toUnwrappedModel(dlFileEntryMetadata);
394    
395                    boolean isNew = dlFileEntryMetadata.isNew();
396    
397                    DLFileEntryMetadataModelImpl dlFileEntryMetadataModelImpl = (DLFileEntryMetadataModelImpl)dlFileEntryMetadata;
398    
399                    if (Validator.isNull(dlFileEntryMetadata.getUuid())) {
400                            String uuid = PortalUUIDUtil.generate();
401    
402                            dlFileEntryMetadata.setUuid(uuid);
403                    }
404    
405                    Session session = null;
406    
407                    try {
408                            session = openSession();
409    
410                            if (dlFileEntryMetadata.isNew()) {
411                                    session.save(dlFileEntryMetadata);
412    
413                                    dlFileEntryMetadata.setNew(false);
414                            }
415                            else {
416                                    session.merge(dlFileEntryMetadata);
417                            }
418                    }
419                    catch (Exception e) {
420                            throw processException(e);
421                    }
422                    finally {
423                            closeSession(session);
424                    }
425    
426                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
427    
428                    if (isNew || !DLFileEntryMetadataModelImpl.COLUMN_BITMASK_ENABLED) {
429                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
430                    }
431    
432                    else {
433                            if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
434                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
435                                    Object[] args = new Object[] {
436                                                    dlFileEntryMetadataModelImpl.getOriginalUuid()
437                                            };
438    
439                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
440                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
441                                            args);
442    
443                                    args = new Object[] { dlFileEntryMetadataModelImpl.getUuid() };
444    
445                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
446                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
447                                            args);
448                            }
449    
450                            if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
451                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID.getColumnBitmask()) != 0) {
452                                    Object[] args = new Object[] {
453                                                    Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileEntryTypeId())
454                                            };
455    
456                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
457                                            args);
458                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
459                                            args);
460    
461                                    args = new Object[] {
462                                                    Long.valueOf(dlFileEntryMetadataModelImpl.getFileEntryTypeId())
463                                            };
464    
465                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
466                                            args);
467                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
468                                            args);
469                            }
470    
471                            if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
472                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID.getColumnBitmask()) != 0) {
473                                    Object[] args = new Object[] {
474                                                    Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileEntryId())
475                                            };
476    
477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
478                                            args);
479                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
480                                            args);
481    
482                                    args = new Object[] {
483                                                    Long.valueOf(dlFileEntryMetadataModelImpl.getFileEntryId())
484                                            };
485    
486                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
487                                            args);
488                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
489                                            args);
490                            }
491    
492                            if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
493                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID.getColumnBitmask()) != 0) {
494                                    Object[] args = new Object[] {
495                                                    Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileVersionId())
496                                            };
497    
498                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEVERSIONID,
499                                            args);
500                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID,
501                                            args);
502    
503                                    args = new Object[] {
504                                                    Long.valueOf(dlFileEntryMetadataModelImpl.getFileVersionId())
505                                            };
506    
507                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEVERSIONID,
508                                            args);
509                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID,
510                                            args);
511                            }
512                    }
513    
514                    EntityCacheUtil.putResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
515                            DLFileEntryMetadataImpl.class, dlFileEntryMetadata.getPrimaryKey(),
516                            dlFileEntryMetadata);
517    
518                    if (isNew) {
519                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F,
520                                    new Object[] {
521                                            Long.valueOf(dlFileEntryMetadata.getDDMStructureId()),
522                                            Long.valueOf(dlFileEntryMetadata.getFileVersionId())
523                                    }, dlFileEntryMetadata);
524                    }
525                    else {
526                            if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
527                                            FINDER_PATH_FETCH_BY_D_F.getColumnBitmask()) != 0) {
528                                    Object[] args = new Object[] {
529                                                    Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalDDMStructureId()),
530                                                    Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileVersionId())
531                                            };
532    
533                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_D_F, args);
534    
535                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_D_F, args);
536    
537                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F,
538                                            new Object[] {
539                                                    Long.valueOf(dlFileEntryMetadata.getDDMStructureId()),
540                                                    Long.valueOf(dlFileEntryMetadata.getFileVersionId())
541                                            }, dlFileEntryMetadata);
542                            }
543                    }
544    
545                    return dlFileEntryMetadata;
546            }
547    
548            protected DLFileEntryMetadata toUnwrappedModel(
549                    DLFileEntryMetadata dlFileEntryMetadata) {
550                    if (dlFileEntryMetadata instanceof DLFileEntryMetadataImpl) {
551                            return dlFileEntryMetadata;
552                    }
553    
554                    DLFileEntryMetadataImpl dlFileEntryMetadataImpl = new DLFileEntryMetadataImpl();
555    
556                    dlFileEntryMetadataImpl.setNew(dlFileEntryMetadata.isNew());
557                    dlFileEntryMetadataImpl.setPrimaryKey(dlFileEntryMetadata.getPrimaryKey());
558    
559                    dlFileEntryMetadataImpl.setUuid(dlFileEntryMetadata.getUuid());
560                    dlFileEntryMetadataImpl.setFileEntryMetadataId(dlFileEntryMetadata.getFileEntryMetadataId());
561                    dlFileEntryMetadataImpl.setDDMStorageId(dlFileEntryMetadata.getDDMStorageId());
562                    dlFileEntryMetadataImpl.setDDMStructureId(dlFileEntryMetadata.getDDMStructureId());
563                    dlFileEntryMetadataImpl.setFileEntryTypeId(dlFileEntryMetadata.getFileEntryTypeId());
564                    dlFileEntryMetadataImpl.setFileEntryId(dlFileEntryMetadata.getFileEntryId());
565                    dlFileEntryMetadataImpl.setFileVersionId(dlFileEntryMetadata.getFileVersionId());
566    
567                    return dlFileEntryMetadataImpl;
568            }
569    
570            /**
571             * Returns the document library file entry metadata with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
572             *
573             * @param primaryKey the primary key of the document library file entry metadata
574             * @return the document library file entry metadata
575             * @throws com.liferay.portal.NoSuchModelException if a document library file entry metadata with the primary key could not be found
576             * @throws SystemException if a system exception occurred
577             */
578            @Override
579            public DLFileEntryMetadata findByPrimaryKey(Serializable primaryKey)
580                    throws NoSuchModelException, SystemException {
581                    return findByPrimaryKey(((Long)primaryKey).longValue());
582            }
583    
584            /**
585             * Returns the document library file entry metadata with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException} if it could not be found.
586             *
587             * @param fileEntryMetadataId the primary key of the document library file entry metadata
588             * @return the document library file entry metadata
589             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a document library file entry metadata with the primary key could not be found
590             * @throws SystemException if a system exception occurred
591             */
592            public DLFileEntryMetadata findByPrimaryKey(long fileEntryMetadataId)
593                    throws NoSuchFileEntryMetadataException, SystemException {
594                    DLFileEntryMetadata dlFileEntryMetadata = fetchByPrimaryKey(fileEntryMetadataId);
595    
596                    if (dlFileEntryMetadata == null) {
597                            if (_log.isWarnEnabled()) {
598                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
599                                            fileEntryMetadataId);
600                            }
601    
602                            throw new NoSuchFileEntryMetadataException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
603                                    fileEntryMetadataId);
604                    }
605    
606                    return dlFileEntryMetadata;
607            }
608    
609            /**
610             * Returns the document library file entry metadata with the primary key or returns <code>null</code> if it could not be found.
611             *
612             * @param primaryKey the primary key of the document library file entry metadata
613             * @return the document library file entry metadata, or <code>null</code> if a document library file entry metadata with the primary key could not be found
614             * @throws SystemException if a system exception occurred
615             */
616            @Override
617            public DLFileEntryMetadata fetchByPrimaryKey(Serializable primaryKey)
618                    throws SystemException {
619                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
620            }
621    
622            /**
623             * Returns the document library file entry metadata with the primary key or returns <code>null</code> if it could not be found.
624             *
625             * @param fileEntryMetadataId the primary key of the document library file entry metadata
626             * @return the document library file entry metadata, or <code>null</code> if a document library file entry metadata with the primary key could not be found
627             * @throws SystemException if a system exception occurred
628             */
629            public DLFileEntryMetadata fetchByPrimaryKey(long fileEntryMetadataId)
630                    throws SystemException {
631                    DLFileEntryMetadata dlFileEntryMetadata = (DLFileEntryMetadata)EntityCacheUtil.getResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
632                                    DLFileEntryMetadataImpl.class, fileEntryMetadataId);
633    
634                    if (dlFileEntryMetadata == _nullDLFileEntryMetadata) {
635                            return null;
636                    }
637    
638                    if (dlFileEntryMetadata == null) {
639                            Session session = null;
640    
641                            boolean hasException = false;
642    
643                            try {
644                                    session = openSession();
645    
646                                    dlFileEntryMetadata = (DLFileEntryMetadata)session.get(DLFileEntryMetadataImpl.class,
647                                                    Long.valueOf(fileEntryMetadataId));
648                            }
649                            catch (Exception e) {
650                                    hasException = true;
651    
652                                    throw processException(e);
653                            }
654                            finally {
655                                    if (dlFileEntryMetadata != null) {
656                                            cacheResult(dlFileEntryMetadata);
657                                    }
658                                    else if (!hasException) {
659                                            EntityCacheUtil.putResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
660                                                    DLFileEntryMetadataImpl.class, fileEntryMetadataId,
661                                                    _nullDLFileEntryMetadata);
662                                    }
663    
664                                    closeSession(session);
665                            }
666                    }
667    
668                    return dlFileEntryMetadata;
669            }
670    
671            /**
672             * Returns all the document library file entry metadatas where uuid = &#63;.
673             *
674             * @param uuid the uuid
675             * @return the matching document library file entry metadatas
676             * @throws SystemException if a system exception occurred
677             */
678            public List<DLFileEntryMetadata> findByUuid(String uuid)
679                    throws SystemException {
680                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
681            }
682    
683            /**
684             * Returns a range of all the document library file entry metadatas where uuid = &#63;.
685             *
686             * <p>
687             * 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.
688             * </p>
689             *
690             * @param uuid the uuid
691             * @param start the lower bound of the range of document library file entry metadatas
692             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
693             * @return the range of matching document library file entry metadatas
694             * @throws SystemException if a system exception occurred
695             */
696            public List<DLFileEntryMetadata> findByUuid(String uuid, int start, int end)
697                    throws SystemException {
698                    return findByUuid(uuid, start, end, null);
699            }
700    
701            /**
702             * Returns an ordered range of all the document library file entry metadatas where uuid = &#63;.
703             *
704             * <p>
705             * 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.
706             * </p>
707             *
708             * @param uuid the uuid
709             * @param start the lower bound of the range of document library file entry metadatas
710             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
711             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
712             * @return the ordered range of matching document library file entry metadatas
713             * @throws SystemException if a system exception occurred
714             */
715            public List<DLFileEntryMetadata> findByUuid(String uuid, int start,
716                    int end, OrderByComparator orderByComparator) throws SystemException {
717                    FinderPath finderPath = null;
718                    Object[] finderArgs = null;
719    
720                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
721                                    (orderByComparator == null)) {
722                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
723                            finderArgs = new Object[] { uuid };
724                    }
725                    else {
726                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
727                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
728                    }
729    
730                    List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
731                                    finderArgs, this);
732    
733                    if ((list != null) && !list.isEmpty()) {
734                            for (DLFileEntryMetadata dlFileEntryMetadata : list) {
735                                    if (!Validator.equals(uuid, dlFileEntryMetadata.getUuid())) {
736                                            list = null;
737    
738                                            break;
739                                    }
740                            }
741                    }
742    
743                    if (list == null) {
744                            StringBundler query = null;
745    
746                            if (orderByComparator != null) {
747                                    query = new StringBundler(3 +
748                                                    (orderByComparator.getOrderByFields().length * 3));
749                            }
750                            else {
751                                    query = new StringBundler(2);
752                            }
753    
754                            query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
755    
756                            if (uuid == null) {
757                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
758                            }
759                            else {
760                                    if (uuid.equals(StringPool.BLANK)) {
761                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
762                                    }
763                                    else {
764                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
765                                    }
766                            }
767    
768                            if (orderByComparator != null) {
769                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
770                                            orderByComparator);
771                            }
772    
773                            String sql = query.toString();
774    
775                            Session session = null;
776    
777                            try {
778                                    session = openSession();
779    
780                                    Query q = session.createQuery(sql);
781    
782                                    QueryPos qPos = QueryPos.getInstance(q);
783    
784                                    if (uuid != null) {
785                                            qPos.add(uuid);
786                                    }
787    
788                                    list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
789                                                    getDialect(), start, end);
790                            }
791                            catch (Exception e) {
792                                    throw processException(e);
793                            }
794                            finally {
795                                    if (list == null) {
796                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
797                                    }
798                                    else {
799                                            cacheResult(list);
800    
801                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
802                                    }
803    
804                                    closeSession(session);
805                            }
806                    }
807    
808                    return list;
809            }
810    
811            /**
812             * Returns the first document library file entry metadata in the ordered set where uuid = &#63;.
813             *
814             * @param uuid the uuid
815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
816             * @return the first matching document library file entry metadata
817             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
818             * @throws SystemException if a system exception occurred
819             */
820            public DLFileEntryMetadata findByUuid_First(String uuid,
821                    OrderByComparator orderByComparator)
822                    throws NoSuchFileEntryMetadataException, SystemException {
823                    DLFileEntryMetadata dlFileEntryMetadata = fetchByUuid_First(uuid,
824                                    orderByComparator);
825    
826                    if (dlFileEntryMetadata != null) {
827                            return dlFileEntryMetadata;
828                    }
829    
830                    StringBundler msg = new StringBundler(4);
831    
832                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
833    
834                    msg.append("uuid=");
835                    msg.append(uuid);
836    
837                    msg.append(StringPool.CLOSE_CURLY_BRACE);
838    
839                    throw new NoSuchFileEntryMetadataException(msg.toString());
840            }
841    
842            /**
843             * Returns the first document library file entry metadata in the ordered set where uuid = &#63;.
844             *
845             * @param uuid the uuid
846             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
847             * @return the first matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
848             * @throws SystemException if a system exception occurred
849             */
850            public DLFileEntryMetadata fetchByUuid_First(String uuid,
851                    OrderByComparator orderByComparator) throws SystemException {
852                    List<DLFileEntryMetadata> list = findByUuid(uuid, 0, 1,
853                                    orderByComparator);
854    
855                    if (!list.isEmpty()) {
856                            return list.get(0);
857                    }
858    
859                    return null;
860            }
861    
862            /**
863             * Returns the last document library file entry metadata in the ordered set where uuid = &#63;.
864             *
865             * @param uuid the uuid
866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
867             * @return the last matching document library file entry metadata
868             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
869             * @throws SystemException if a system exception occurred
870             */
871            public DLFileEntryMetadata findByUuid_Last(String uuid,
872                    OrderByComparator orderByComparator)
873                    throws NoSuchFileEntryMetadataException, SystemException {
874                    DLFileEntryMetadata dlFileEntryMetadata = fetchByUuid_Last(uuid,
875                                    orderByComparator);
876    
877                    if (dlFileEntryMetadata != null) {
878                            return dlFileEntryMetadata;
879                    }
880    
881                    StringBundler msg = new StringBundler(4);
882    
883                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
884    
885                    msg.append("uuid=");
886                    msg.append(uuid);
887    
888                    msg.append(StringPool.CLOSE_CURLY_BRACE);
889    
890                    throw new NoSuchFileEntryMetadataException(msg.toString());
891            }
892    
893            /**
894             * Returns the last document library file entry metadata in the ordered set where uuid = &#63;.
895             *
896             * @param uuid the uuid
897             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
898             * @return the last matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
899             * @throws SystemException if a system exception occurred
900             */
901            public DLFileEntryMetadata fetchByUuid_Last(String uuid,
902                    OrderByComparator orderByComparator) throws SystemException {
903                    int count = countByUuid(uuid);
904    
905                    List<DLFileEntryMetadata> list = findByUuid(uuid, count - 1, count,
906                                    orderByComparator);
907    
908                    if (!list.isEmpty()) {
909                            return list.get(0);
910                    }
911    
912                    return null;
913            }
914    
915            /**
916             * Returns the document library file entry metadatas before and after the current document library file entry metadata in the ordered set where uuid = &#63;.
917             *
918             * @param fileEntryMetadataId the primary key of the current document library file entry metadata
919             * @param uuid the uuid
920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
921             * @return the previous, current, and next document library file entry metadata
922             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a document library file entry metadata with the primary key could not be found
923             * @throws SystemException if a system exception occurred
924             */
925            public DLFileEntryMetadata[] findByUuid_PrevAndNext(
926                    long fileEntryMetadataId, String uuid,
927                    OrderByComparator orderByComparator)
928                    throws NoSuchFileEntryMetadataException, SystemException {
929                    DLFileEntryMetadata dlFileEntryMetadata = findByPrimaryKey(fileEntryMetadataId);
930    
931                    Session session = null;
932    
933                    try {
934                            session = openSession();
935    
936                            DLFileEntryMetadata[] array = new DLFileEntryMetadataImpl[3];
937    
938                            array[0] = getByUuid_PrevAndNext(session, dlFileEntryMetadata,
939                                            uuid, orderByComparator, true);
940    
941                            array[1] = dlFileEntryMetadata;
942    
943                            array[2] = getByUuid_PrevAndNext(session, dlFileEntryMetadata,
944                                            uuid, orderByComparator, false);
945    
946                            return array;
947                    }
948                    catch (Exception e) {
949                            throw processException(e);
950                    }
951                    finally {
952                            closeSession(session);
953                    }
954            }
955    
956            protected DLFileEntryMetadata getByUuid_PrevAndNext(Session session,
957                    DLFileEntryMetadata dlFileEntryMetadata, String uuid,
958                    OrderByComparator orderByComparator, boolean previous) {
959                    StringBundler query = null;
960    
961                    if (orderByComparator != null) {
962                            query = new StringBundler(6 +
963                                            (orderByComparator.getOrderByFields().length * 6));
964                    }
965                    else {
966                            query = new StringBundler(3);
967                    }
968    
969                    query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
970    
971                    if (uuid == null) {
972                            query.append(_FINDER_COLUMN_UUID_UUID_1);
973                    }
974                    else {
975                            if (uuid.equals(StringPool.BLANK)) {
976                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
977                            }
978                            else {
979                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
980                            }
981                    }
982    
983                    if (orderByComparator != null) {
984                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
985    
986                            if (orderByConditionFields.length > 0) {
987                                    query.append(WHERE_AND);
988                            }
989    
990                            for (int i = 0; i < orderByConditionFields.length; i++) {
991                                    query.append(_ORDER_BY_ENTITY_ALIAS);
992                                    query.append(orderByConditionFields[i]);
993    
994                                    if ((i + 1) < orderByConditionFields.length) {
995                                            if (orderByComparator.isAscending() ^ previous) {
996                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
997                                            }
998                                            else {
999                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1000                                            }
1001                                    }
1002                                    else {
1003                                            if (orderByComparator.isAscending() ^ previous) {
1004                                                    query.append(WHERE_GREATER_THAN);
1005                                            }
1006                                            else {
1007                                                    query.append(WHERE_LESSER_THAN);
1008                                            }
1009                                    }
1010                            }
1011    
1012                            query.append(ORDER_BY_CLAUSE);
1013    
1014                            String[] orderByFields = orderByComparator.getOrderByFields();
1015    
1016                            for (int i = 0; i < orderByFields.length; i++) {
1017                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1018                                    query.append(orderByFields[i]);
1019    
1020                                    if ((i + 1) < orderByFields.length) {
1021                                            if (orderByComparator.isAscending() ^ previous) {
1022                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1023                                            }
1024                                            else {
1025                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1026                                            }
1027                                    }
1028                                    else {
1029                                            if (orderByComparator.isAscending() ^ previous) {
1030                                                    query.append(ORDER_BY_ASC);
1031                                            }
1032                                            else {
1033                                                    query.append(ORDER_BY_DESC);
1034                                            }
1035                                    }
1036                            }
1037                    }
1038    
1039                    String sql = query.toString();
1040    
1041                    Query q = session.createQuery(sql);
1042    
1043                    q.setFirstResult(0);
1044                    q.setMaxResults(2);
1045    
1046                    QueryPos qPos = QueryPos.getInstance(q);
1047    
1048                    if (uuid != null) {
1049                            qPos.add(uuid);
1050                    }
1051    
1052                    if (orderByComparator != null) {
1053                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryMetadata);
1054    
1055                            for (Object value : values) {
1056                                    qPos.add(value);
1057                            }
1058                    }
1059    
1060                    List<DLFileEntryMetadata> list = q.list();
1061    
1062                    if (list.size() == 2) {
1063                            return list.get(1);
1064                    }
1065                    else {
1066                            return null;
1067                    }
1068            }
1069    
1070            /**
1071             * Returns all the document library file entry metadatas where fileEntryTypeId = &#63;.
1072             *
1073             * @param fileEntryTypeId the file entry type ID
1074             * @return the matching document library file entry metadatas
1075             * @throws SystemException if a system exception occurred
1076             */
1077            public List<DLFileEntryMetadata> findByFileEntryTypeId(long fileEntryTypeId)
1078                    throws SystemException {
1079                    return findByFileEntryTypeId(fileEntryTypeId, QueryUtil.ALL_POS,
1080                            QueryUtil.ALL_POS, null);
1081            }
1082    
1083            /**
1084             * Returns a range of all the document library file entry metadatas where fileEntryTypeId = &#63;.
1085             *
1086             * <p>
1087             * 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.
1088             * </p>
1089             *
1090             * @param fileEntryTypeId the file entry type ID
1091             * @param start the lower bound of the range of document library file entry metadatas
1092             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
1093             * @return the range of matching document library file entry metadatas
1094             * @throws SystemException if a system exception occurred
1095             */
1096            public List<DLFileEntryMetadata> findByFileEntryTypeId(
1097                    long fileEntryTypeId, int start, int end) throws SystemException {
1098                    return findByFileEntryTypeId(fileEntryTypeId, start, end, null);
1099            }
1100    
1101            /**
1102             * Returns an ordered range of all the document library file entry metadatas where fileEntryTypeId = &#63;.
1103             *
1104             * <p>
1105             * 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.
1106             * </p>
1107             *
1108             * @param fileEntryTypeId the file entry type ID
1109             * @param start the lower bound of the range of document library file entry metadatas
1110             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
1111             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1112             * @return the ordered range of matching document library file entry metadatas
1113             * @throws SystemException if a system exception occurred
1114             */
1115            public List<DLFileEntryMetadata> findByFileEntryTypeId(
1116                    long fileEntryTypeId, int start, int end,
1117                    OrderByComparator orderByComparator) throws SystemException {
1118                    FinderPath finderPath = null;
1119                    Object[] finderArgs = null;
1120    
1121                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1122                                    (orderByComparator == null)) {
1123                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID;
1124                            finderArgs = new Object[] { fileEntryTypeId };
1125                    }
1126                    else {
1127                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYTYPEID;
1128                            finderArgs = new Object[] {
1129                                            fileEntryTypeId,
1130                                            
1131                                            start, end, orderByComparator
1132                                    };
1133                    }
1134    
1135                    List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
1136                                    finderArgs, this);
1137    
1138                    if ((list != null) && !list.isEmpty()) {
1139                            for (DLFileEntryMetadata dlFileEntryMetadata : list) {
1140                                    if ((fileEntryTypeId != dlFileEntryMetadata.getFileEntryTypeId())) {
1141                                            list = null;
1142    
1143                                            break;
1144                                    }
1145                            }
1146                    }
1147    
1148                    if (list == null) {
1149                            StringBundler query = null;
1150    
1151                            if (orderByComparator != null) {
1152                                    query = new StringBundler(3 +
1153                                                    (orderByComparator.getOrderByFields().length * 3));
1154                            }
1155                            else {
1156                                    query = new StringBundler(2);
1157                            }
1158    
1159                            query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1160    
1161                            query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
1162    
1163                            if (orderByComparator != null) {
1164                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1165                                            orderByComparator);
1166                            }
1167    
1168                            String sql = query.toString();
1169    
1170                            Session session = null;
1171    
1172                            try {
1173                                    session = openSession();
1174    
1175                                    Query q = session.createQuery(sql);
1176    
1177                                    QueryPos qPos = QueryPos.getInstance(q);
1178    
1179                                    qPos.add(fileEntryTypeId);
1180    
1181                                    list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
1182                                                    getDialect(), start, end);
1183                            }
1184                            catch (Exception e) {
1185                                    throw processException(e);
1186                            }
1187                            finally {
1188                                    if (list == null) {
1189                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1190                                    }
1191                                    else {
1192                                            cacheResult(list);
1193    
1194                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1195                                    }
1196    
1197                                    closeSession(session);
1198                            }
1199                    }
1200    
1201                    return list;
1202            }
1203    
1204            /**
1205             * Returns the first document library file entry metadata in the ordered set where fileEntryTypeId = &#63;.
1206             *
1207             * @param fileEntryTypeId the file entry type ID
1208             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1209             * @return the first matching document library file entry metadata
1210             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
1211             * @throws SystemException if a system exception occurred
1212             */
1213            public DLFileEntryMetadata findByFileEntryTypeId_First(
1214                    long fileEntryTypeId, OrderByComparator orderByComparator)
1215                    throws NoSuchFileEntryMetadataException, SystemException {
1216                    DLFileEntryMetadata dlFileEntryMetadata = fetchByFileEntryTypeId_First(fileEntryTypeId,
1217                                    orderByComparator);
1218    
1219                    if (dlFileEntryMetadata != null) {
1220                            return dlFileEntryMetadata;
1221                    }
1222    
1223                    StringBundler msg = new StringBundler(4);
1224    
1225                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1226    
1227                    msg.append("fileEntryTypeId=");
1228                    msg.append(fileEntryTypeId);
1229    
1230                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1231    
1232                    throw new NoSuchFileEntryMetadataException(msg.toString());
1233            }
1234    
1235            /**
1236             * Returns the first document library file entry metadata in the ordered set where fileEntryTypeId = &#63;.
1237             *
1238             * @param fileEntryTypeId the file entry type ID
1239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1240             * @return the first matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
1241             * @throws SystemException if a system exception occurred
1242             */
1243            public DLFileEntryMetadata fetchByFileEntryTypeId_First(
1244                    long fileEntryTypeId, OrderByComparator orderByComparator)
1245                    throws SystemException {
1246                    List<DLFileEntryMetadata> list = findByFileEntryTypeId(fileEntryTypeId,
1247                                    0, 1, orderByComparator);
1248    
1249                    if (!list.isEmpty()) {
1250                            return list.get(0);
1251                    }
1252    
1253                    return null;
1254            }
1255    
1256            /**
1257             * Returns the last document library file entry metadata in the ordered set where fileEntryTypeId = &#63;.
1258             *
1259             * @param fileEntryTypeId the file entry type ID
1260             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1261             * @return the last matching document library file entry metadata
1262             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
1263             * @throws SystemException if a system exception occurred
1264             */
1265            public DLFileEntryMetadata findByFileEntryTypeId_Last(
1266                    long fileEntryTypeId, OrderByComparator orderByComparator)
1267                    throws NoSuchFileEntryMetadataException, SystemException {
1268                    DLFileEntryMetadata dlFileEntryMetadata = fetchByFileEntryTypeId_Last(fileEntryTypeId,
1269                                    orderByComparator);
1270    
1271                    if (dlFileEntryMetadata != null) {
1272                            return dlFileEntryMetadata;
1273                    }
1274    
1275                    StringBundler msg = new StringBundler(4);
1276    
1277                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1278    
1279                    msg.append("fileEntryTypeId=");
1280                    msg.append(fileEntryTypeId);
1281    
1282                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1283    
1284                    throw new NoSuchFileEntryMetadataException(msg.toString());
1285            }
1286    
1287            /**
1288             * Returns the last document library file entry metadata in the ordered set where fileEntryTypeId = &#63;.
1289             *
1290             * @param fileEntryTypeId the file entry type ID
1291             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1292             * @return the last matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
1293             * @throws SystemException if a system exception occurred
1294             */
1295            public DLFileEntryMetadata fetchByFileEntryTypeId_Last(
1296                    long fileEntryTypeId, OrderByComparator orderByComparator)
1297                    throws SystemException {
1298                    int count = countByFileEntryTypeId(fileEntryTypeId);
1299    
1300                    List<DLFileEntryMetadata> list = findByFileEntryTypeId(fileEntryTypeId,
1301                                    count - 1, count, orderByComparator);
1302    
1303                    if (!list.isEmpty()) {
1304                            return list.get(0);
1305                    }
1306    
1307                    return null;
1308            }
1309    
1310            /**
1311             * Returns the document library file entry metadatas before and after the current document library file entry metadata in the ordered set where fileEntryTypeId = &#63;.
1312             *
1313             * @param fileEntryMetadataId the primary key of the current document library file entry metadata
1314             * @param fileEntryTypeId the file entry type ID
1315             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1316             * @return the previous, current, and next document library file entry metadata
1317             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a document library file entry metadata with the primary key could not be found
1318             * @throws SystemException if a system exception occurred
1319             */
1320            public DLFileEntryMetadata[] findByFileEntryTypeId_PrevAndNext(
1321                    long fileEntryMetadataId, long fileEntryTypeId,
1322                    OrderByComparator orderByComparator)
1323                    throws NoSuchFileEntryMetadataException, SystemException {
1324                    DLFileEntryMetadata dlFileEntryMetadata = findByPrimaryKey(fileEntryMetadataId);
1325    
1326                    Session session = null;
1327    
1328                    try {
1329                            session = openSession();
1330    
1331                            DLFileEntryMetadata[] array = new DLFileEntryMetadataImpl[3];
1332    
1333                            array[0] = getByFileEntryTypeId_PrevAndNext(session,
1334                                            dlFileEntryMetadata, fileEntryTypeId, orderByComparator,
1335                                            true);
1336    
1337                            array[1] = dlFileEntryMetadata;
1338    
1339                            array[2] = getByFileEntryTypeId_PrevAndNext(session,
1340                                            dlFileEntryMetadata, fileEntryTypeId, orderByComparator,
1341                                            false);
1342    
1343                            return array;
1344                    }
1345                    catch (Exception e) {
1346                            throw processException(e);
1347                    }
1348                    finally {
1349                            closeSession(session);
1350                    }
1351            }
1352    
1353            protected DLFileEntryMetadata getByFileEntryTypeId_PrevAndNext(
1354                    Session session, DLFileEntryMetadata dlFileEntryMetadata,
1355                    long fileEntryTypeId, OrderByComparator orderByComparator,
1356                    boolean previous) {
1357                    StringBundler query = null;
1358    
1359                    if (orderByComparator != null) {
1360                            query = new StringBundler(6 +
1361                                            (orderByComparator.getOrderByFields().length * 6));
1362                    }
1363                    else {
1364                            query = new StringBundler(3);
1365                    }
1366    
1367                    query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1368    
1369                    query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
1370    
1371                    if (orderByComparator != null) {
1372                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1373    
1374                            if (orderByConditionFields.length > 0) {
1375                                    query.append(WHERE_AND);
1376                            }
1377    
1378                            for (int i = 0; i < orderByConditionFields.length; i++) {
1379                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1380                                    query.append(orderByConditionFields[i]);
1381    
1382                                    if ((i + 1) < orderByConditionFields.length) {
1383                                            if (orderByComparator.isAscending() ^ previous) {
1384                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1385                                            }
1386                                            else {
1387                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1388                                            }
1389                                    }
1390                                    else {
1391                                            if (orderByComparator.isAscending() ^ previous) {
1392                                                    query.append(WHERE_GREATER_THAN);
1393                                            }
1394                                            else {
1395                                                    query.append(WHERE_LESSER_THAN);
1396                                            }
1397                                    }
1398                            }
1399    
1400                            query.append(ORDER_BY_CLAUSE);
1401    
1402                            String[] orderByFields = orderByComparator.getOrderByFields();
1403    
1404                            for (int i = 0; i < orderByFields.length; i++) {
1405                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1406                                    query.append(orderByFields[i]);
1407    
1408                                    if ((i + 1) < orderByFields.length) {
1409                                            if (orderByComparator.isAscending() ^ previous) {
1410                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1411                                            }
1412                                            else {
1413                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1414                                            }
1415                                    }
1416                                    else {
1417                                            if (orderByComparator.isAscending() ^ previous) {
1418                                                    query.append(ORDER_BY_ASC);
1419                                            }
1420                                            else {
1421                                                    query.append(ORDER_BY_DESC);
1422                                            }
1423                                    }
1424                            }
1425                    }
1426    
1427                    String sql = query.toString();
1428    
1429                    Query q = session.createQuery(sql);
1430    
1431                    q.setFirstResult(0);
1432                    q.setMaxResults(2);
1433    
1434                    QueryPos qPos = QueryPos.getInstance(q);
1435    
1436                    qPos.add(fileEntryTypeId);
1437    
1438                    if (orderByComparator != null) {
1439                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryMetadata);
1440    
1441                            for (Object value : values) {
1442                                    qPos.add(value);
1443                            }
1444                    }
1445    
1446                    List<DLFileEntryMetadata> list = q.list();
1447    
1448                    if (list.size() == 2) {
1449                            return list.get(1);
1450                    }
1451                    else {
1452                            return null;
1453                    }
1454            }
1455    
1456            /**
1457             * Returns all the document library file entry metadatas where fileEntryId = &#63;.
1458             *
1459             * @param fileEntryId the file entry ID
1460             * @return the matching document library file entry metadatas
1461             * @throws SystemException if a system exception occurred
1462             */
1463            public List<DLFileEntryMetadata> findByFileEntryId(long fileEntryId)
1464                    throws SystemException {
1465                    return findByFileEntryId(fileEntryId, QueryUtil.ALL_POS,
1466                            QueryUtil.ALL_POS, null);
1467            }
1468    
1469            /**
1470             * Returns a range of all the document library file entry metadatas where fileEntryId = &#63;.
1471             *
1472             * <p>
1473             * 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.
1474             * </p>
1475             *
1476             * @param fileEntryId the file entry ID
1477             * @param start the lower bound of the range of document library file entry metadatas
1478             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
1479             * @return the range of matching document library file entry metadatas
1480             * @throws SystemException if a system exception occurred
1481             */
1482            public List<DLFileEntryMetadata> findByFileEntryId(long fileEntryId,
1483                    int start, int end) throws SystemException {
1484                    return findByFileEntryId(fileEntryId, start, end, null);
1485            }
1486    
1487            /**
1488             * Returns an ordered range of all the document library file entry metadatas where fileEntryId = &#63;.
1489             *
1490             * <p>
1491             * 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.
1492             * </p>
1493             *
1494             * @param fileEntryId the file entry ID
1495             * @param start the lower bound of the range of document library file entry metadatas
1496             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
1497             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1498             * @return the ordered range of matching document library file entry metadatas
1499             * @throws SystemException if a system exception occurred
1500             */
1501            public List<DLFileEntryMetadata> findByFileEntryId(long fileEntryId,
1502                    int start, int end, OrderByComparator orderByComparator)
1503                    throws SystemException {
1504                    FinderPath finderPath = null;
1505                    Object[] finderArgs = null;
1506    
1507                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1508                                    (orderByComparator == null)) {
1509                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID;
1510                            finderArgs = new Object[] { fileEntryId };
1511                    }
1512                    else {
1513                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID;
1514                            finderArgs = new Object[] { fileEntryId, start, end, orderByComparator };
1515                    }
1516    
1517                    List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
1518                                    finderArgs, this);
1519    
1520                    if ((list != null) && !list.isEmpty()) {
1521                            for (DLFileEntryMetadata dlFileEntryMetadata : list) {
1522                                    if ((fileEntryId != dlFileEntryMetadata.getFileEntryId())) {
1523                                            list = null;
1524    
1525                                            break;
1526                                    }
1527                            }
1528                    }
1529    
1530                    if (list == null) {
1531                            StringBundler query = null;
1532    
1533                            if (orderByComparator != null) {
1534                                    query = new StringBundler(3 +
1535                                                    (orderByComparator.getOrderByFields().length * 3));
1536                            }
1537                            else {
1538                                    query = new StringBundler(2);
1539                            }
1540    
1541                            query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1542    
1543                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1544    
1545                            if (orderByComparator != null) {
1546                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1547                                            orderByComparator);
1548                            }
1549    
1550                            String sql = query.toString();
1551    
1552                            Session session = null;
1553    
1554                            try {
1555                                    session = openSession();
1556    
1557                                    Query q = session.createQuery(sql);
1558    
1559                                    QueryPos qPos = QueryPos.getInstance(q);
1560    
1561                                    qPos.add(fileEntryId);
1562    
1563                                    list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
1564                                                    getDialect(), start, end);
1565                            }
1566                            catch (Exception e) {
1567                                    throw processException(e);
1568                            }
1569                            finally {
1570                                    if (list == null) {
1571                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1572                                    }
1573                                    else {
1574                                            cacheResult(list);
1575    
1576                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1577                                    }
1578    
1579                                    closeSession(session);
1580                            }
1581                    }
1582    
1583                    return list;
1584            }
1585    
1586            /**
1587             * Returns the first document library file entry metadata in the ordered set where fileEntryId = &#63;.
1588             *
1589             * @param fileEntryId the file entry ID
1590             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1591             * @return the first matching document library file entry metadata
1592             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
1593             * @throws SystemException if a system exception occurred
1594             */
1595            public DLFileEntryMetadata findByFileEntryId_First(long fileEntryId,
1596                    OrderByComparator orderByComparator)
1597                    throws NoSuchFileEntryMetadataException, SystemException {
1598                    DLFileEntryMetadata dlFileEntryMetadata = fetchByFileEntryId_First(fileEntryId,
1599                                    orderByComparator);
1600    
1601                    if (dlFileEntryMetadata != null) {
1602                            return dlFileEntryMetadata;
1603                    }
1604    
1605                    StringBundler msg = new StringBundler(4);
1606    
1607                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1608    
1609                    msg.append("fileEntryId=");
1610                    msg.append(fileEntryId);
1611    
1612                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1613    
1614                    throw new NoSuchFileEntryMetadataException(msg.toString());
1615            }
1616    
1617            /**
1618             * Returns the first document library file entry metadata in the ordered set where fileEntryId = &#63;.
1619             *
1620             * @param fileEntryId the file entry ID
1621             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1622             * @return the first matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
1623             * @throws SystemException if a system exception occurred
1624             */
1625            public DLFileEntryMetadata fetchByFileEntryId_First(long fileEntryId,
1626                    OrderByComparator orderByComparator) throws SystemException {
1627                    List<DLFileEntryMetadata> list = findByFileEntryId(fileEntryId, 0, 1,
1628                                    orderByComparator);
1629    
1630                    if (!list.isEmpty()) {
1631                            return list.get(0);
1632                    }
1633    
1634                    return null;
1635            }
1636    
1637            /**
1638             * Returns the last document library file entry metadata in the ordered set where fileEntryId = &#63;.
1639             *
1640             * @param fileEntryId the file entry ID
1641             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1642             * @return the last matching document library file entry metadata
1643             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
1644             * @throws SystemException if a system exception occurred
1645             */
1646            public DLFileEntryMetadata findByFileEntryId_Last(long fileEntryId,
1647                    OrderByComparator orderByComparator)
1648                    throws NoSuchFileEntryMetadataException, SystemException {
1649                    DLFileEntryMetadata dlFileEntryMetadata = fetchByFileEntryId_Last(fileEntryId,
1650                                    orderByComparator);
1651    
1652                    if (dlFileEntryMetadata != null) {
1653                            return dlFileEntryMetadata;
1654                    }
1655    
1656                    StringBundler msg = new StringBundler(4);
1657    
1658                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1659    
1660                    msg.append("fileEntryId=");
1661                    msg.append(fileEntryId);
1662    
1663                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1664    
1665                    throw new NoSuchFileEntryMetadataException(msg.toString());
1666            }
1667    
1668            /**
1669             * Returns the last document library file entry metadata in the ordered set where fileEntryId = &#63;.
1670             *
1671             * @param fileEntryId the file entry ID
1672             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1673             * @return the last matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
1674             * @throws SystemException if a system exception occurred
1675             */
1676            public DLFileEntryMetadata fetchByFileEntryId_Last(long fileEntryId,
1677                    OrderByComparator orderByComparator) throws SystemException {
1678                    int count = countByFileEntryId(fileEntryId);
1679    
1680                    List<DLFileEntryMetadata> list = findByFileEntryId(fileEntryId,
1681                                    count - 1, count, orderByComparator);
1682    
1683                    if (!list.isEmpty()) {
1684                            return list.get(0);
1685                    }
1686    
1687                    return null;
1688            }
1689    
1690            /**
1691             * Returns the document library file entry metadatas before and after the current document library file entry metadata in the ordered set where fileEntryId = &#63;.
1692             *
1693             * @param fileEntryMetadataId the primary key of the current document library file entry metadata
1694             * @param fileEntryId the file entry ID
1695             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1696             * @return the previous, current, and next document library file entry metadata
1697             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a document library file entry metadata with the primary key could not be found
1698             * @throws SystemException if a system exception occurred
1699             */
1700            public DLFileEntryMetadata[] findByFileEntryId_PrevAndNext(
1701                    long fileEntryMetadataId, long fileEntryId,
1702                    OrderByComparator orderByComparator)
1703                    throws NoSuchFileEntryMetadataException, SystemException {
1704                    DLFileEntryMetadata dlFileEntryMetadata = findByPrimaryKey(fileEntryMetadataId);
1705    
1706                    Session session = null;
1707    
1708                    try {
1709                            session = openSession();
1710    
1711                            DLFileEntryMetadata[] array = new DLFileEntryMetadataImpl[3];
1712    
1713                            array[0] = getByFileEntryId_PrevAndNext(session,
1714                                            dlFileEntryMetadata, fileEntryId, orderByComparator, true);
1715    
1716                            array[1] = dlFileEntryMetadata;
1717    
1718                            array[2] = getByFileEntryId_PrevAndNext(session,
1719                                            dlFileEntryMetadata, fileEntryId, orderByComparator, false);
1720    
1721                            return array;
1722                    }
1723                    catch (Exception e) {
1724                            throw processException(e);
1725                    }
1726                    finally {
1727                            closeSession(session);
1728                    }
1729            }
1730    
1731            protected DLFileEntryMetadata getByFileEntryId_PrevAndNext(
1732                    Session session, DLFileEntryMetadata dlFileEntryMetadata,
1733                    long fileEntryId, OrderByComparator orderByComparator, boolean previous) {
1734                    StringBundler query = null;
1735    
1736                    if (orderByComparator != null) {
1737                            query = new StringBundler(6 +
1738                                            (orderByComparator.getOrderByFields().length * 6));
1739                    }
1740                    else {
1741                            query = new StringBundler(3);
1742                    }
1743    
1744                    query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1745    
1746                    query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1747    
1748                    if (orderByComparator != null) {
1749                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1750    
1751                            if (orderByConditionFields.length > 0) {
1752                                    query.append(WHERE_AND);
1753                            }
1754    
1755                            for (int i = 0; i < orderByConditionFields.length; i++) {
1756                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1757                                    query.append(orderByConditionFields[i]);
1758    
1759                                    if ((i + 1) < orderByConditionFields.length) {
1760                                            if (orderByComparator.isAscending() ^ previous) {
1761                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1762                                            }
1763                                            else {
1764                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1765                                            }
1766                                    }
1767                                    else {
1768                                            if (orderByComparator.isAscending() ^ previous) {
1769                                                    query.append(WHERE_GREATER_THAN);
1770                                            }
1771                                            else {
1772                                                    query.append(WHERE_LESSER_THAN);
1773                                            }
1774                                    }
1775                            }
1776    
1777                            query.append(ORDER_BY_CLAUSE);
1778    
1779                            String[] orderByFields = orderByComparator.getOrderByFields();
1780    
1781                            for (int i = 0; i < orderByFields.length; i++) {
1782                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1783                                    query.append(orderByFields[i]);
1784    
1785                                    if ((i + 1) < orderByFields.length) {
1786                                            if (orderByComparator.isAscending() ^ previous) {
1787                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1788                                            }
1789                                            else {
1790                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1791                                            }
1792                                    }
1793                                    else {
1794                                            if (orderByComparator.isAscending() ^ previous) {
1795                                                    query.append(ORDER_BY_ASC);
1796                                            }
1797                                            else {
1798                                                    query.append(ORDER_BY_DESC);
1799                                            }
1800                                    }
1801                            }
1802                    }
1803    
1804                    String sql = query.toString();
1805    
1806                    Query q = session.createQuery(sql);
1807    
1808                    q.setFirstResult(0);
1809                    q.setMaxResults(2);
1810    
1811                    QueryPos qPos = QueryPos.getInstance(q);
1812    
1813                    qPos.add(fileEntryId);
1814    
1815                    if (orderByComparator != null) {
1816                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryMetadata);
1817    
1818                            for (Object value : values) {
1819                                    qPos.add(value);
1820                            }
1821                    }
1822    
1823                    List<DLFileEntryMetadata> list = q.list();
1824    
1825                    if (list.size() == 2) {
1826                            return list.get(1);
1827                    }
1828                    else {
1829                            return null;
1830                    }
1831            }
1832    
1833            /**
1834             * Returns all the document library file entry metadatas where fileVersionId = &#63;.
1835             *
1836             * @param fileVersionId the file version ID
1837             * @return the matching document library file entry metadatas
1838             * @throws SystemException if a system exception occurred
1839             */
1840            public List<DLFileEntryMetadata> findByFileVersionId(long fileVersionId)
1841                    throws SystemException {
1842                    return findByFileVersionId(fileVersionId, QueryUtil.ALL_POS,
1843                            QueryUtil.ALL_POS, null);
1844            }
1845    
1846            /**
1847             * Returns a range of all the document library file entry metadatas where fileVersionId = &#63;.
1848             *
1849             * <p>
1850             * 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.
1851             * </p>
1852             *
1853             * @param fileVersionId the file version ID
1854             * @param start the lower bound of the range of document library file entry metadatas
1855             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
1856             * @return the range of matching document library file entry metadatas
1857             * @throws SystemException if a system exception occurred
1858             */
1859            public List<DLFileEntryMetadata> findByFileVersionId(long fileVersionId,
1860                    int start, int end) throws SystemException {
1861                    return findByFileVersionId(fileVersionId, start, end, null);
1862            }
1863    
1864            /**
1865             * Returns an ordered range of all the document library file entry metadatas where fileVersionId = &#63;.
1866             *
1867             * <p>
1868             * 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.
1869             * </p>
1870             *
1871             * @param fileVersionId the file version ID
1872             * @param start the lower bound of the range of document library file entry metadatas
1873             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
1874             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1875             * @return the ordered range of matching document library file entry metadatas
1876             * @throws SystemException if a system exception occurred
1877             */
1878            public List<DLFileEntryMetadata> findByFileVersionId(long fileVersionId,
1879                    int start, int end, OrderByComparator orderByComparator)
1880                    throws SystemException {
1881                    FinderPath finderPath = null;
1882                    Object[] finderArgs = null;
1883    
1884                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1885                                    (orderByComparator == null)) {
1886                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID;
1887                            finderArgs = new Object[] { fileVersionId };
1888                    }
1889                    else {
1890                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEVERSIONID;
1891                            finderArgs = new Object[] {
1892                                            fileVersionId,
1893                                            
1894                                            start, end, orderByComparator
1895                                    };
1896                    }
1897    
1898                    List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
1899                                    finderArgs, this);
1900    
1901                    if ((list != null) && !list.isEmpty()) {
1902                            for (DLFileEntryMetadata dlFileEntryMetadata : list) {
1903                                    if ((fileVersionId != dlFileEntryMetadata.getFileVersionId())) {
1904                                            list = null;
1905    
1906                                            break;
1907                                    }
1908                            }
1909                    }
1910    
1911                    if (list == null) {
1912                            StringBundler query = null;
1913    
1914                            if (orderByComparator != null) {
1915                                    query = new StringBundler(3 +
1916                                                    (orderByComparator.getOrderByFields().length * 3));
1917                            }
1918                            else {
1919                                    query = new StringBundler(2);
1920                            }
1921    
1922                            query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1923    
1924                            query.append(_FINDER_COLUMN_FILEVERSIONID_FILEVERSIONID_2);
1925    
1926                            if (orderByComparator != null) {
1927                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1928                                            orderByComparator);
1929                            }
1930    
1931                            String sql = query.toString();
1932    
1933                            Session session = null;
1934    
1935                            try {
1936                                    session = openSession();
1937    
1938                                    Query q = session.createQuery(sql);
1939    
1940                                    QueryPos qPos = QueryPos.getInstance(q);
1941    
1942                                    qPos.add(fileVersionId);
1943    
1944                                    list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
1945                                                    getDialect(), start, end);
1946                            }
1947                            catch (Exception e) {
1948                                    throw processException(e);
1949                            }
1950                            finally {
1951                                    if (list == null) {
1952                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1953                                    }
1954                                    else {
1955                                            cacheResult(list);
1956    
1957                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1958                                    }
1959    
1960                                    closeSession(session);
1961                            }
1962                    }
1963    
1964                    return list;
1965            }
1966    
1967            /**
1968             * Returns the first document library file entry metadata in the ordered set where fileVersionId = &#63;.
1969             *
1970             * @param fileVersionId the file version ID
1971             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1972             * @return the first matching document library file entry metadata
1973             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
1974             * @throws SystemException if a system exception occurred
1975             */
1976            public DLFileEntryMetadata findByFileVersionId_First(long fileVersionId,
1977                    OrderByComparator orderByComparator)
1978                    throws NoSuchFileEntryMetadataException, SystemException {
1979                    DLFileEntryMetadata dlFileEntryMetadata = fetchByFileVersionId_First(fileVersionId,
1980                                    orderByComparator);
1981    
1982                    if (dlFileEntryMetadata != null) {
1983                            return dlFileEntryMetadata;
1984                    }
1985    
1986                    StringBundler msg = new StringBundler(4);
1987    
1988                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1989    
1990                    msg.append("fileVersionId=");
1991                    msg.append(fileVersionId);
1992    
1993                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1994    
1995                    throw new NoSuchFileEntryMetadataException(msg.toString());
1996            }
1997    
1998            /**
1999             * Returns the first document library file entry metadata in the ordered set where fileVersionId = &#63;.
2000             *
2001             * @param fileVersionId the file version ID
2002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2003             * @return the first matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
2004             * @throws SystemException if a system exception occurred
2005             */
2006            public DLFileEntryMetadata fetchByFileVersionId_First(long fileVersionId,
2007                    OrderByComparator orderByComparator) throws SystemException {
2008                    List<DLFileEntryMetadata> list = findByFileVersionId(fileVersionId, 0,
2009                                    1, orderByComparator);
2010    
2011                    if (!list.isEmpty()) {
2012                            return list.get(0);
2013                    }
2014    
2015                    return null;
2016            }
2017    
2018            /**
2019             * Returns the last document library file entry metadata in the ordered set where fileVersionId = &#63;.
2020             *
2021             * @param fileVersionId the file version ID
2022             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2023             * @return the last matching document library file entry metadata
2024             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
2025             * @throws SystemException if a system exception occurred
2026             */
2027            public DLFileEntryMetadata findByFileVersionId_Last(long fileVersionId,
2028                    OrderByComparator orderByComparator)
2029                    throws NoSuchFileEntryMetadataException, SystemException {
2030                    DLFileEntryMetadata dlFileEntryMetadata = fetchByFileVersionId_Last(fileVersionId,
2031                                    orderByComparator);
2032    
2033                    if (dlFileEntryMetadata != null) {
2034                            return dlFileEntryMetadata;
2035                    }
2036    
2037                    StringBundler msg = new StringBundler(4);
2038    
2039                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2040    
2041                    msg.append("fileVersionId=");
2042                    msg.append(fileVersionId);
2043    
2044                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2045    
2046                    throw new NoSuchFileEntryMetadataException(msg.toString());
2047            }
2048    
2049            /**
2050             * Returns the last document library file entry metadata in the ordered set where fileVersionId = &#63;.
2051             *
2052             * @param fileVersionId the file version ID
2053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2054             * @return the last matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
2055             * @throws SystemException if a system exception occurred
2056             */
2057            public DLFileEntryMetadata fetchByFileVersionId_Last(long fileVersionId,
2058                    OrderByComparator orderByComparator) throws SystemException {
2059                    int count = countByFileVersionId(fileVersionId);
2060    
2061                    List<DLFileEntryMetadata> list = findByFileVersionId(fileVersionId,
2062                                    count - 1, count, orderByComparator);
2063    
2064                    if (!list.isEmpty()) {
2065                            return list.get(0);
2066                    }
2067    
2068                    return null;
2069            }
2070    
2071            /**
2072             * Returns the document library file entry metadatas before and after the current document library file entry metadata in the ordered set where fileVersionId = &#63;.
2073             *
2074             * @param fileEntryMetadataId the primary key of the current document library file entry metadata
2075             * @param fileVersionId the file version ID
2076             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2077             * @return the previous, current, and next document library file entry metadata
2078             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a document library file entry metadata with the primary key could not be found
2079             * @throws SystemException if a system exception occurred
2080             */
2081            public DLFileEntryMetadata[] findByFileVersionId_PrevAndNext(
2082                    long fileEntryMetadataId, long fileVersionId,
2083                    OrderByComparator orderByComparator)
2084                    throws NoSuchFileEntryMetadataException, SystemException {
2085                    DLFileEntryMetadata dlFileEntryMetadata = findByPrimaryKey(fileEntryMetadataId);
2086    
2087                    Session session = null;
2088    
2089                    try {
2090                            session = openSession();
2091    
2092                            DLFileEntryMetadata[] array = new DLFileEntryMetadataImpl[3];
2093    
2094                            array[0] = getByFileVersionId_PrevAndNext(session,
2095                                            dlFileEntryMetadata, fileVersionId, orderByComparator, true);
2096    
2097                            array[1] = dlFileEntryMetadata;
2098    
2099                            array[2] = getByFileVersionId_PrevAndNext(session,
2100                                            dlFileEntryMetadata, fileVersionId, orderByComparator, false);
2101    
2102                            return array;
2103                    }
2104                    catch (Exception e) {
2105                            throw processException(e);
2106                    }
2107                    finally {
2108                            closeSession(session);
2109                    }
2110            }
2111    
2112            protected DLFileEntryMetadata getByFileVersionId_PrevAndNext(
2113                    Session session, DLFileEntryMetadata dlFileEntryMetadata,
2114                    long fileVersionId, OrderByComparator orderByComparator,
2115                    boolean previous) {
2116                    StringBundler query = null;
2117    
2118                    if (orderByComparator != null) {
2119                            query = new StringBundler(6 +
2120                                            (orderByComparator.getOrderByFields().length * 6));
2121                    }
2122                    else {
2123                            query = new StringBundler(3);
2124                    }
2125    
2126                    query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
2127    
2128                    query.append(_FINDER_COLUMN_FILEVERSIONID_FILEVERSIONID_2);
2129    
2130                    if (orderByComparator != null) {
2131                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2132    
2133                            if (orderByConditionFields.length > 0) {
2134                                    query.append(WHERE_AND);
2135                            }
2136    
2137                            for (int i = 0; i < orderByConditionFields.length; i++) {
2138                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2139                                    query.append(orderByConditionFields[i]);
2140    
2141                                    if ((i + 1) < orderByConditionFields.length) {
2142                                            if (orderByComparator.isAscending() ^ previous) {
2143                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2144                                            }
2145                                            else {
2146                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2147                                            }
2148                                    }
2149                                    else {
2150                                            if (orderByComparator.isAscending() ^ previous) {
2151                                                    query.append(WHERE_GREATER_THAN);
2152                                            }
2153                                            else {
2154                                                    query.append(WHERE_LESSER_THAN);
2155                                            }
2156                                    }
2157                            }
2158    
2159                            query.append(ORDER_BY_CLAUSE);
2160    
2161                            String[] orderByFields = orderByComparator.getOrderByFields();
2162    
2163                            for (int i = 0; i < orderByFields.length; i++) {
2164                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2165                                    query.append(orderByFields[i]);
2166    
2167                                    if ((i + 1) < orderByFields.length) {
2168                                            if (orderByComparator.isAscending() ^ previous) {
2169                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2170                                            }
2171                                            else {
2172                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2173                                            }
2174                                    }
2175                                    else {
2176                                            if (orderByComparator.isAscending() ^ previous) {
2177                                                    query.append(ORDER_BY_ASC);
2178                                            }
2179                                            else {
2180                                                    query.append(ORDER_BY_DESC);
2181                                            }
2182                                    }
2183                            }
2184                    }
2185    
2186                    String sql = query.toString();
2187    
2188                    Query q = session.createQuery(sql);
2189    
2190                    q.setFirstResult(0);
2191                    q.setMaxResults(2);
2192    
2193                    QueryPos qPos = QueryPos.getInstance(q);
2194    
2195                    qPos.add(fileVersionId);
2196    
2197                    if (orderByComparator != null) {
2198                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryMetadata);
2199    
2200                            for (Object value : values) {
2201                                    qPos.add(value);
2202                            }
2203                    }
2204    
2205                    List<DLFileEntryMetadata> list = q.list();
2206    
2207                    if (list.size() == 2) {
2208                            return list.get(1);
2209                    }
2210                    else {
2211                            return null;
2212                    }
2213            }
2214    
2215            /**
2216             * Returns the document library file entry metadata where DDMStructureId = &#63; and fileVersionId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException} if it could not be found.
2217             *
2218             * @param DDMStructureId the d d m structure ID
2219             * @param fileVersionId the file version ID
2220             * @return the matching document library file entry metadata
2221             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException if a matching document library file entry metadata could not be found
2222             * @throws SystemException if a system exception occurred
2223             */
2224            public DLFileEntryMetadata findByD_F(long DDMStructureId, long fileVersionId)
2225                    throws NoSuchFileEntryMetadataException, SystemException {
2226                    DLFileEntryMetadata dlFileEntryMetadata = fetchByD_F(DDMStructureId,
2227                                    fileVersionId);
2228    
2229                    if (dlFileEntryMetadata == null) {
2230                            StringBundler msg = new StringBundler(6);
2231    
2232                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2233    
2234                            msg.append("DDMStructureId=");
2235                            msg.append(DDMStructureId);
2236    
2237                            msg.append(", fileVersionId=");
2238                            msg.append(fileVersionId);
2239    
2240                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2241    
2242                            if (_log.isWarnEnabled()) {
2243                                    _log.warn(msg.toString());
2244                            }
2245    
2246                            throw new NoSuchFileEntryMetadataException(msg.toString());
2247                    }
2248    
2249                    return dlFileEntryMetadata;
2250            }
2251    
2252            /**
2253             * Returns the document library file entry metadata where DDMStructureId = &#63; and fileVersionId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2254             *
2255             * @param DDMStructureId the d d m structure ID
2256             * @param fileVersionId the file version ID
2257             * @return the matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
2258             * @throws SystemException if a system exception occurred
2259             */
2260            public DLFileEntryMetadata fetchByD_F(long DDMStructureId,
2261                    long fileVersionId) throws SystemException {
2262                    return fetchByD_F(DDMStructureId, fileVersionId, true);
2263            }
2264    
2265            /**
2266             * Returns the document library file entry metadata where DDMStructureId = &#63; and fileVersionId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2267             *
2268             * @param DDMStructureId the d d m structure ID
2269             * @param fileVersionId the file version ID
2270             * @param retrieveFromCache whether to use the finder cache
2271             * @return the matching document library file entry metadata, or <code>null</code> if a matching document library file entry metadata could not be found
2272             * @throws SystemException if a system exception occurred
2273             */
2274            public DLFileEntryMetadata fetchByD_F(long DDMStructureId,
2275                    long fileVersionId, boolean retrieveFromCache)
2276                    throws SystemException {
2277                    Object[] finderArgs = new Object[] { DDMStructureId, fileVersionId };
2278    
2279                    Object result = null;
2280    
2281                    if (retrieveFromCache) {
2282                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_D_F,
2283                                            finderArgs, this);
2284                    }
2285    
2286                    if (result instanceof DLFileEntryMetadata) {
2287                            DLFileEntryMetadata dlFileEntryMetadata = (DLFileEntryMetadata)result;
2288    
2289                            if ((DDMStructureId != dlFileEntryMetadata.getDDMStructureId()) ||
2290                                            (fileVersionId != dlFileEntryMetadata.getFileVersionId())) {
2291                                    result = null;
2292                            }
2293                    }
2294    
2295                    if (result == null) {
2296                            StringBundler query = new StringBundler(3);
2297    
2298                            query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
2299    
2300                            query.append(_FINDER_COLUMN_D_F_DDMSTRUCTUREID_2);
2301    
2302                            query.append(_FINDER_COLUMN_D_F_FILEVERSIONID_2);
2303    
2304                            String sql = query.toString();
2305    
2306                            Session session = null;
2307    
2308                            try {
2309                                    session = openSession();
2310    
2311                                    Query q = session.createQuery(sql);
2312    
2313                                    QueryPos qPos = QueryPos.getInstance(q);
2314    
2315                                    qPos.add(DDMStructureId);
2316    
2317                                    qPos.add(fileVersionId);
2318    
2319                                    List<DLFileEntryMetadata> list = q.list();
2320    
2321                                    result = list;
2322    
2323                                    DLFileEntryMetadata dlFileEntryMetadata = null;
2324    
2325                                    if (list.isEmpty()) {
2326                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F,
2327                                                    finderArgs, list);
2328                                    }
2329                                    else {
2330                                            dlFileEntryMetadata = list.get(0);
2331    
2332                                            cacheResult(dlFileEntryMetadata);
2333    
2334                                            if ((dlFileEntryMetadata.getDDMStructureId() != DDMStructureId) ||
2335                                                            (dlFileEntryMetadata.getFileVersionId() != fileVersionId)) {
2336                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F,
2337                                                            finderArgs, dlFileEntryMetadata);
2338                                            }
2339                                    }
2340    
2341                                    return dlFileEntryMetadata;
2342                            }
2343                            catch (Exception e) {
2344                                    throw processException(e);
2345                            }
2346                            finally {
2347                                    if (result == null) {
2348                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_D_F,
2349                                                    finderArgs);
2350                                    }
2351    
2352                                    closeSession(session);
2353                            }
2354                    }
2355                    else {
2356                            if (result instanceof List<?>) {
2357                                    return null;
2358                            }
2359                            else {
2360                                    return (DLFileEntryMetadata)result;
2361                            }
2362                    }
2363            }
2364    
2365            /**
2366             * Returns all the document library file entry metadatas.
2367             *
2368             * @return the document library file entry metadatas
2369             * @throws SystemException if a system exception occurred
2370             */
2371            public List<DLFileEntryMetadata> findAll() throws SystemException {
2372                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2373            }
2374    
2375            /**
2376             * Returns a range of all the document library file entry metadatas.
2377             *
2378             * <p>
2379             * 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.
2380             * </p>
2381             *
2382             * @param start the lower bound of the range of document library file entry metadatas
2383             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
2384             * @return the range of document library file entry metadatas
2385             * @throws SystemException if a system exception occurred
2386             */
2387            public List<DLFileEntryMetadata> findAll(int start, int end)
2388                    throws SystemException {
2389                    return findAll(start, end, null);
2390            }
2391    
2392            /**
2393             * Returns an ordered range of all the document library file entry metadatas.
2394             *
2395             * <p>
2396             * 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.
2397             * </p>
2398             *
2399             * @param start the lower bound of the range of document library file entry metadatas
2400             * @param end the upper bound of the range of document library file entry metadatas (not inclusive)
2401             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2402             * @return the ordered range of document library file entry metadatas
2403             * @throws SystemException if a system exception occurred
2404             */
2405            public List<DLFileEntryMetadata> findAll(int start, int end,
2406                    OrderByComparator orderByComparator) throws SystemException {
2407                    FinderPath finderPath = null;
2408                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2409    
2410                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2411                                    (orderByComparator == null)) {
2412                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2413                            finderArgs = FINDER_ARGS_EMPTY;
2414                    }
2415                    else {
2416                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2417                            finderArgs = new Object[] { start, end, orderByComparator };
2418                    }
2419    
2420                    List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
2421                                    finderArgs, this);
2422    
2423                    if (list == null) {
2424                            StringBundler query = null;
2425                            String sql = null;
2426    
2427                            if (orderByComparator != null) {
2428                                    query = new StringBundler(2 +
2429                                                    (orderByComparator.getOrderByFields().length * 3));
2430    
2431                                    query.append(_SQL_SELECT_DLFILEENTRYMETADATA);
2432    
2433                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2434                                            orderByComparator);
2435    
2436                                    sql = query.toString();
2437                            }
2438                            else {
2439                                    sql = _SQL_SELECT_DLFILEENTRYMETADATA;
2440                            }
2441    
2442                            Session session = null;
2443    
2444                            try {
2445                                    session = openSession();
2446    
2447                                    Query q = session.createQuery(sql);
2448    
2449                                    if (orderByComparator == null) {
2450                                            list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
2451                                                            getDialect(), start, end, false);
2452    
2453                                            Collections.sort(list);
2454                                    }
2455                                    else {
2456                                            list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
2457                                                            getDialect(), start, end);
2458                                    }
2459                            }
2460                            catch (Exception e) {
2461                                    throw processException(e);
2462                            }
2463                            finally {
2464                                    if (list == null) {
2465                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2466                                    }
2467                                    else {
2468                                            cacheResult(list);
2469    
2470                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2471                                    }
2472    
2473                                    closeSession(session);
2474                            }
2475                    }
2476    
2477                    return list;
2478            }
2479    
2480            /**
2481             * Removes all the document library file entry metadatas where uuid = &#63; from the database.
2482             *
2483             * @param uuid the uuid
2484             * @throws SystemException if a system exception occurred
2485             */
2486            public void removeByUuid(String uuid) throws SystemException {
2487                    for (DLFileEntryMetadata dlFileEntryMetadata : findByUuid(uuid)) {
2488                            remove(dlFileEntryMetadata);
2489                    }
2490            }
2491    
2492            /**
2493             * Removes all the document library file entry metadatas where fileEntryTypeId = &#63; from the database.
2494             *
2495             * @param fileEntryTypeId the file entry type ID
2496             * @throws SystemException if a system exception occurred
2497             */
2498            public void removeByFileEntryTypeId(long fileEntryTypeId)
2499                    throws SystemException {
2500                    for (DLFileEntryMetadata dlFileEntryMetadata : findByFileEntryTypeId(
2501                                    fileEntryTypeId)) {
2502                            remove(dlFileEntryMetadata);
2503                    }
2504            }
2505    
2506            /**
2507             * Removes all the document library file entry metadatas where fileEntryId = &#63; from the database.
2508             *
2509             * @param fileEntryId the file entry ID
2510             * @throws SystemException if a system exception occurred
2511             */
2512            public void removeByFileEntryId(long fileEntryId) throws SystemException {
2513                    for (DLFileEntryMetadata dlFileEntryMetadata : findByFileEntryId(
2514                                    fileEntryId)) {
2515                            remove(dlFileEntryMetadata);
2516                    }
2517            }
2518    
2519            /**
2520             * Removes all the document library file entry metadatas where fileVersionId = &#63; from the database.
2521             *
2522             * @param fileVersionId the file version ID
2523             * @throws SystemException if a system exception occurred
2524             */
2525            public void removeByFileVersionId(long fileVersionId)
2526                    throws SystemException {
2527                    for (DLFileEntryMetadata dlFileEntryMetadata : findByFileVersionId(
2528                                    fileVersionId)) {
2529                            remove(dlFileEntryMetadata);
2530                    }
2531            }
2532    
2533            /**
2534             * Removes the document library file entry metadata where DDMStructureId = &#63; and fileVersionId = &#63; from the database.
2535             *
2536             * @param DDMStructureId the d d m structure ID
2537             * @param fileVersionId the file version ID
2538             * @return the document library file entry metadata that was removed
2539             * @throws SystemException if a system exception occurred
2540             */
2541            public DLFileEntryMetadata removeByD_F(long DDMStructureId,
2542                    long fileVersionId)
2543                    throws NoSuchFileEntryMetadataException, SystemException {
2544                    DLFileEntryMetadata dlFileEntryMetadata = findByD_F(DDMStructureId,
2545                                    fileVersionId);
2546    
2547                    return remove(dlFileEntryMetadata);
2548            }
2549    
2550            /**
2551             * Removes all the document library file entry metadatas from the database.
2552             *
2553             * @throws SystemException if a system exception occurred
2554             */
2555            public void removeAll() throws SystemException {
2556                    for (DLFileEntryMetadata dlFileEntryMetadata : findAll()) {
2557                            remove(dlFileEntryMetadata);
2558                    }
2559            }
2560    
2561            /**
2562             * Returns the number of document library file entry metadatas where uuid = &#63;.
2563             *
2564             * @param uuid the uuid
2565             * @return the number of matching document library file entry metadatas
2566             * @throws SystemException if a system exception occurred
2567             */
2568            public int countByUuid(String uuid) throws SystemException {
2569                    Object[] finderArgs = new Object[] { uuid };
2570    
2571                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2572                                    finderArgs, this);
2573    
2574                    if (count == null) {
2575                            StringBundler query = new StringBundler(2);
2576    
2577                            query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2578    
2579                            if (uuid == null) {
2580                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
2581                            }
2582                            else {
2583                                    if (uuid.equals(StringPool.BLANK)) {
2584                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
2585                                    }
2586                                    else {
2587                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
2588                                    }
2589                            }
2590    
2591                            String sql = query.toString();
2592    
2593                            Session session = null;
2594    
2595                            try {
2596                                    session = openSession();
2597    
2598                                    Query q = session.createQuery(sql);
2599    
2600                                    QueryPos qPos = QueryPos.getInstance(q);
2601    
2602                                    if (uuid != null) {
2603                                            qPos.add(uuid);
2604                                    }
2605    
2606                                    count = (Long)q.uniqueResult();
2607                            }
2608                            catch (Exception e) {
2609                                    throw processException(e);
2610                            }
2611                            finally {
2612                                    if (count == null) {
2613                                            count = Long.valueOf(0);
2614                                    }
2615    
2616                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2617                                            finderArgs, count);
2618    
2619                                    closeSession(session);
2620                            }
2621                    }
2622    
2623                    return count.intValue();
2624            }
2625    
2626            /**
2627             * Returns the number of document library file entry metadatas where fileEntryTypeId = &#63;.
2628             *
2629             * @param fileEntryTypeId the file entry type ID
2630             * @return the number of matching document library file entry metadatas
2631             * @throws SystemException if a system exception occurred
2632             */
2633            public int countByFileEntryTypeId(long fileEntryTypeId)
2634                    throws SystemException {
2635                    Object[] finderArgs = new Object[] { fileEntryTypeId };
2636    
2637                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
2638                                    finderArgs, this);
2639    
2640                    if (count == null) {
2641                            StringBundler query = new StringBundler(2);
2642    
2643                            query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2644    
2645                            query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
2646    
2647                            String sql = query.toString();
2648    
2649                            Session session = null;
2650    
2651                            try {
2652                                    session = openSession();
2653    
2654                                    Query q = session.createQuery(sql);
2655    
2656                                    QueryPos qPos = QueryPos.getInstance(q);
2657    
2658                                    qPos.add(fileEntryTypeId);
2659    
2660                                    count = (Long)q.uniqueResult();
2661                            }
2662                            catch (Exception e) {
2663                                    throw processException(e);
2664                            }
2665                            finally {
2666                                    if (count == null) {
2667                                            count = Long.valueOf(0);
2668                                    }
2669    
2670                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
2671                                            finderArgs, count);
2672    
2673                                    closeSession(session);
2674                            }
2675                    }
2676    
2677                    return count.intValue();
2678            }
2679    
2680            /**
2681             * Returns the number of document library file entry metadatas where fileEntryId = &#63;.
2682             *
2683             * @param fileEntryId the file entry ID
2684             * @return the number of matching document library file entry metadatas
2685             * @throws SystemException if a system exception occurred
2686             */
2687            public int countByFileEntryId(long fileEntryId) throws SystemException {
2688                    Object[] finderArgs = new Object[] { fileEntryId };
2689    
2690                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2691                                    finderArgs, this);
2692    
2693                    if (count == null) {
2694                            StringBundler query = new StringBundler(2);
2695    
2696                            query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2697    
2698                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
2699    
2700                            String sql = query.toString();
2701    
2702                            Session session = null;
2703    
2704                            try {
2705                                    session = openSession();
2706    
2707                                    Query q = session.createQuery(sql);
2708    
2709                                    QueryPos qPos = QueryPos.getInstance(q);
2710    
2711                                    qPos.add(fileEntryId);
2712    
2713                                    count = (Long)q.uniqueResult();
2714                            }
2715                            catch (Exception e) {
2716                                    throw processException(e);
2717                            }
2718                            finally {
2719                                    if (count == null) {
2720                                            count = Long.valueOf(0);
2721                                    }
2722    
2723                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2724                                            finderArgs, count);
2725    
2726                                    closeSession(session);
2727                            }
2728                    }
2729    
2730                    return count.intValue();
2731            }
2732    
2733            /**
2734             * Returns the number of document library file entry metadatas where fileVersionId = &#63;.
2735             *
2736             * @param fileVersionId the file version ID
2737             * @return the number of matching document library file entry metadatas
2738             * @throws SystemException if a system exception occurred
2739             */
2740            public int countByFileVersionId(long fileVersionId)
2741                    throws SystemException {
2742                    Object[] finderArgs = new Object[] { fileVersionId };
2743    
2744                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEVERSIONID,
2745                                    finderArgs, this);
2746    
2747                    if (count == null) {
2748                            StringBundler query = new StringBundler(2);
2749    
2750                            query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2751    
2752                            query.append(_FINDER_COLUMN_FILEVERSIONID_FILEVERSIONID_2);
2753    
2754                            String sql = query.toString();
2755    
2756                            Session session = null;
2757    
2758                            try {
2759                                    session = openSession();
2760    
2761                                    Query q = session.createQuery(sql);
2762    
2763                                    QueryPos qPos = QueryPos.getInstance(q);
2764    
2765                                    qPos.add(fileVersionId);
2766    
2767                                    count = (Long)q.uniqueResult();
2768                            }
2769                            catch (Exception e) {
2770                                    throw processException(e);
2771                            }
2772                            finally {
2773                                    if (count == null) {
2774                                            count = Long.valueOf(0);
2775                                    }
2776    
2777                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEVERSIONID,
2778                                            finderArgs, count);
2779    
2780                                    closeSession(session);
2781                            }
2782                    }
2783    
2784                    return count.intValue();
2785            }
2786    
2787            /**
2788             * Returns the number of document library file entry metadatas where DDMStructureId = &#63; and fileVersionId = &#63;.
2789             *
2790             * @param DDMStructureId the d d m structure ID
2791             * @param fileVersionId the file version ID
2792             * @return the number of matching document library file entry metadatas
2793             * @throws SystemException if a system exception occurred
2794             */
2795            public int countByD_F(long DDMStructureId, long fileVersionId)
2796                    throws SystemException {
2797                    Object[] finderArgs = new Object[] { DDMStructureId, fileVersionId };
2798    
2799                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_D_F,
2800                                    finderArgs, this);
2801    
2802                    if (count == null) {
2803                            StringBundler query = new StringBundler(3);
2804    
2805                            query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2806    
2807                            query.append(_FINDER_COLUMN_D_F_DDMSTRUCTUREID_2);
2808    
2809                            query.append(_FINDER_COLUMN_D_F_FILEVERSIONID_2);
2810    
2811                            String sql = query.toString();
2812    
2813                            Session session = null;
2814    
2815                            try {
2816                                    session = openSession();
2817    
2818                                    Query q = session.createQuery(sql);
2819    
2820                                    QueryPos qPos = QueryPos.getInstance(q);
2821    
2822                                    qPos.add(DDMStructureId);
2823    
2824                                    qPos.add(fileVersionId);
2825    
2826                                    count = (Long)q.uniqueResult();
2827                            }
2828                            catch (Exception e) {
2829                                    throw processException(e);
2830                            }
2831                            finally {
2832                                    if (count == null) {
2833                                            count = Long.valueOf(0);
2834                                    }
2835    
2836                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_D_F, finderArgs,
2837                                            count);
2838    
2839                                    closeSession(session);
2840                            }
2841                    }
2842    
2843                    return count.intValue();
2844            }
2845    
2846            /**
2847             * Returns the number of document library file entry metadatas.
2848             *
2849             * @return the number of document library file entry metadatas
2850             * @throws SystemException if a system exception occurred
2851             */
2852            public int countAll() throws SystemException {
2853                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2854                                    FINDER_ARGS_EMPTY, this);
2855    
2856                    if (count == null) {
2857                            Session session = null;
2858    
2859                            try {
2860                                    session = openSession();
2861    
2862                                    Query q = session.createQuery(_SQL_COUNT_DLFILEENTRYMETADATA);
2863    
2864                                    count = (Long)q.uniqueResult();
2865                            }
2866                            catch (Exception e) {
2867                                    throw processException(e);
2868                            }
2869                            finally {
2870                                    if (count == null) {
2871                                            count = Long.valueOf(0);
2872                                    }
2873    
2874                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2875                                            FINDER_ARGS_EMPTY, count);
2876    
2877                                    closeSession(session);
2878                            }
2879                    }
2880    
2881                    return count.intValue();
2882            }
2883    
2884            /**
2885             * Initializes the document library file entry metadata persistence.
2886             */
2887            public void afterPropertiesSet() {
2888                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2889                                            com.liferay.portal.util.PropsUtil.get(
2890                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata")));
2891    
2892                    if (listenerClassNames.length > 0) {
2893                            try {
2894                                    List<ModelListener<DLFileEntryMetadata>> listenersList = new ArrayList<ModelListener<DLFileEntryMetadata>>();
2895    
2896                                    for (String listenerClassName : listenerClassNames) {
2897                                            listenersList.add((ModelListener<DLFileEntryMetadata>)InstanceFactory.newInstance(
2898                                                            listenerClassName));
2899                                    }
2900    
2901                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2902                            }
2903                            catch (Exception e) {
2904                                    _log.error(e);
2905                            }
2906                    }
2907            }
2908    
2909            public void destroy() {
2910                    EntityCacheUtil.removeCache(DLFileEntryMetadataImpl.class.getName());
2911                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2912                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2913            }
2914    
2915            @BeanReference(type = DLContentPersistence.class)
2916            protected DLContentPersistence dlContentPersistence;
2917            @BeanReference(type = DLFileEntryPersistence.class)
2918            protected DLFileEntryPersistence dlFileEntryPersistence;
2919            @BeanReference(type = DLFileEntryMetadataPersistence.class)
2920            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
2921            @BeanReference(type = DLFileEntryTypePersistence.class)
2922            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
2923            @BeanReference(type = DLFileRankPersistence.class)
2924            protected DLFileRankPersistence dlFileRankPersistence;
2925            @BeanReference(type = DLFileShortcutPersistence.class)
2926            protected DLFileShortcutPersistence dlFileShortcutPersistence;
2927            @BeanReference(type = DLFileVersionPersistence.class)
2928            protected DLFileVersionPersistence dlFileVersionPersistence;
2929            @BeanReference(type = DLFolderPersistence.class)
2930            protected DLFolderPersistence dlFolderPersistence;
2931            @BeanReference(type = DLSyncPersistence.class)
2932            protected DLSyncPersistence dlSyncPersistence;
2933            @BeanReference(type = UserPersistence.class)
2934            protected UserPersistence userPersistence;
2935            @BeanReference(type = DDMStructureLinkPersistence.class)
2936            protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
2937            private static final String _SQL_SELECT_DLFILEENTRYMETADATA = "SELECT dlFileEntryMetadata FROM DLFileEntryMetadata dlFileEntryMetadata";
2938            private static final String _SQL_SELECT_DLFILEENTRYMETADATA_WHERE = "SELECT dlFileEntryMetadata FROM DLFileEntryMetadata dlFileEntryMetadata WHERE ";
2939            private static final String _SQL_COUNT_DLFILEENTRYMETADATA = "SELECT COUNT(dlFileEntryMetadata) FROM DLFileEntryMetadata dlFileEntryMetadata";
2940            private static final String _SQL_COUNT_DLFILEENTRYMETADATA_WHERE = "SELECT COUNT(dlFileEntryMetadata) FROM DLFileEntryMetadata dlFileEntryMetadata WHERE ";
2941            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntryMetadata.uuid IS NULL";
2942            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntryMetadata.uuid = ?";
2943            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntryMetadata.uuid IS NULL OR dlFileEntryMetadata.uuid = ?)";
2944            private static final String _FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2 =
2945                    "dlFileEntryMetadata.fileEntryTypeId = ?";
2946            private static final String _FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2 = "dlFileEntryMetadata.fileEntryId = ?";
2947            private static final String _FINDER_COLUMN_FILEVERSIONID_FILEVERSIONID_2 = "dlFileEntryMetadata.fileVersionId = ?";
2948            private static final String _FINDER_COLUMN_D_F_DDMSTRUCTUREID_2 = "dlFileEntryMetadata.DDMStructureId = ? AND ";
2949            private static final String _FINDER_COLUMN_D_F_FILEVERSIONID_2 = "dlFileEntryMetadata.fileVersionId = ?";
2950            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntryMetadata.";
2951            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntryMetadata exists with the primary key ";
2952            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntryMetadata exists with the key {";
2953            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2954            private static Log _log = LogFactoryUtil.getLog(DLFileEntryMetadataPersistenceImpl.class);
2955            private static DLFileEntryMetadata _nullDLFileEntryMetadata = new DLFileEntryMetadataImpl() {
2956                            @Override
2957                            public Object clone() {
2958                                    return this;
2959                            }
2960    
2961                            @Override
2962                            public CacheModel<DLFileEntryMetadata> toCacheModel() {
2963                                    return _nullDLFileEntryMetadataCacheModel;
2964                            }
2965                    };
2966    
2967            private static CacheModel<DLFileEntryMetadata> _nullDLFileEntryMetadataCacheModel =
2968                    new CacheModel<DLFileEntryMetadata>() {
2969                            public DLFileEntryMetadata toEntityModel() {
2970                                    return _nullDLFileEntryMetadata;
2971                            }
2972                    };
2973    }