001
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.BatchSessionUtil;
041 import com.liferay.portal.service.persistence.ResourcePersistence;
042 import com.liferay.portal.service.persistence.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.documentlibrary.NoSuchFileEntryMetadataException;
046 import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata;
047 import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataImpl;
048 import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataModelImpl;
049 import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructureLinkPersistence;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.List;
056
057
069 public class DLFileEntryMetadataPersistenceImpl extends BasePersistenceImpl<DLFileEntryMetadata>
070 implements DLFileEntryMetadataPersistence {
071
076 public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryMetadataImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List1";
079 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List2";
081 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
082 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
083 DLFileEntryMetadataImpl.class,
084 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
085 new String[] {
086 String.class.getName(),
087
088 "java.lang.Integer", "java.lang.Integer",
089 "com.liferay.portal.kernel.util.OrderByComparator"
090 });
091 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
092 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
093 DLFileEntryMetadataImpl.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
095 new String[] { String.class.getName() },
096 DLFileEntryMetadataModelImpl.UUID_COLUMN_BITMASK);
097 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
098 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
100 new String[] { String.class.getName() });
101 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYTYPEID =
102 new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
103 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
104 DLFileEntryMetadataImpl.class,
105 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileEntryTypeId",
106 new String[] {
107 Long.class.getName(),
108
109 "java.lang.Integer", "java.lang.Integer",
110 "com.liferay.portal.kernel.util.OrderByComparator"
111 });
112 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID =
113 new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
114 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
115 DLFileEntryMetadataImpl.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileEntryTypeId",
117 new String[] { Long.class.getName() },
118 DLFileEntryMetadataModelImpl.FILEENTRYTYPEID_COLUMN_BITMASK);
119 public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYTYPEID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
120 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
122 "countByFileEntryTypeId", new String[] { Long.class.getName() });
123 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID =
124 new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
125 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
126 DLFileEntryMetadataImpl.class,
127 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileEntryId",
128 new String[] {
129 Long.class.getName(),
130
131 "java.lang.Integer", "java.lang.Integer",
132 "com.liferay.portal.kernel.util.OrderByComparator"
133 });
134 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID =
135 new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
136 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
137 DLFileEntryMetadataImpl.class,
138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileEntryId",
139 new String[] { Long.class.getName() },
140 DLFileEntryMetadataModelImpl.FILEENTRYID_COLUMN_BITMASK);
141 public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
142 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
143 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFileEntryId",
144 new String[] { Long.class.getName() });
145 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEVERSIONID =
146 new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
147 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
148 DLFileEntryMetadataImpl.class,
149 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileVersionId",
150 new String[] {
151 Long.class.getName(),
152
153 "java.lang.Integer", "java.lang.Integer",
154 "com.liferay.portal.kernel.util.OrderByComparator"
155 });
156 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID =
157 new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
158 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
159 DLFileEntryMetadataImpl.class,
160 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileVersionId",
161 new String[] { Long.class.getName() },
162 DLFileEntryMetadataModelImpl.FILEVERSIONID_COLUMN_BITMASK);
163 public static final FinderPath FINDER_PATH_COUNT_BY_FILEVERSIONID = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
164 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
165 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFileVersionId",
166 new String[] { Long.class.getName() });
167 public static final FinderPath FINDER_PATH_FETCH_BY_D_F = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
168 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
169 DLFileEntryMetadataImpl.class, FINDER_CLASS_NAME_ENTITY,
170 "fetchByD_F",
171 new String[] { Long.class.getName(), Long.class.getName() },
172 DLFileEntryMetadataModelImpl.DDMSTRUCTUREID_COLUMN_BITMASK |
173 DLFileEntryMetadataModelImpl.FILEVERSIONID_COLUMN_BITMASK);
174 public static final FinderPath FINDER_PATH_COUNT_BY_D_F = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
175 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
176 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByD_F",
177 new String[] { Long.class.getName(), Long.class.getName() });
178 public static final FinderPath FINDER_PATH_FETCH_BY_F_V = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
179 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
180 DLFileEntryMetadataImpl.class, FINDER_CLASS_NAME_ENTITY,
181 "fetchByF_V",
182 new String[] { Long.class.getName(), Long.class.getName() },
183 DLFileEntryMetadataModelImpl.FILEENTRYID_COLUMN_BITMASK |
184 DLFileEntryMetadataModelImpl.FILEVERSIONID_COLUMN_BITMASK);
185 public static final FinderPath FINDER_PATH_COUNT_BY_F_V = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
186 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
187 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByF_V",
188 new String[] { Long.class.getName(), Long.class.getName() });
189 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
190 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
191 DLFileEntryMetadataImpl.class,
192 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
193 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
194 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED,
195 DLFileEntryMetadataImpl.class,
196 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
197 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
198 DLFileEntryMetadataModelImpl.FINDER_CACHE_ENABLED, Long.class,
199 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
200
201
206 public void cacheResult(DLFileEntryMetadata dlFileEntryMetadata) {
207 EntityCacheUtil.putResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
208 DLFileEntryMetadataImpl.class, dlFileEntryMetadata.getPrimaryKey(),
209 dlFileEntryMetadata);
210
211 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F,
212 new Object[] {
213 Long.valueOf(dlFileEntryMetadata.getDDMStructureId()),
214 Long.valueOf(dlFileEntryMetadata.getFileVersionId())
215 }, dlFileEntryMetadata);
216
217 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
218 new Object[] {
219 Long.valueOf(dlFileEntryMetadata.getFileEntryId()),
220 Long.valueOf(dlFileEntryMetadata.getFileVersionId())
221 }, dlFileEntryMetadata);
222
223 dlFileEntryMetadata.resetOriginalValues();
224 }
225
226
231 public void cacheResult(List<DLFileEntryMetadata> dlFileEntryMetadatas) {
232 for (DLFileEntryMetadata dlFileEntryMetadata : dlFileEntryMetadatas) {
233 if (EntityCacheUtil.getResult(
234 DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
235 DLFileEntryMetadataImpl.class,
236 dlFileEntryMetadata.getPrimaryKey()) == null) {
237 cacheResult(dlFileEntryMetadata);
238 }
239 else {
240 dlFileEntryMetadata.resetOriginalValues();
241 }
242 }
243 }
244
245
252 @Override
253 public void clearCache() {
254 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
255 CacheRegistryUtil.clear(DLFileEntryMetadataImpl.class.getName());
256 }
257
258 EntityCacheUtil.clearCache(DLFileEntryMetadataImpl.class.getName());
259
260 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
261 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
262 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
263 }
264
265
272 @Override
273 public void clearCache(DLFileEntryMetadata dlFileEntryMetadata) {
274 EntityCacheUtil.removeResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
275 DLFileEntryMetadataImpl.class, dlFileEntryMetadata.getPrimaryKey());
276
277 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
278 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
279
280 clearUniqueFindersCache(dlFileEntryMetadata);
281 }
282
283 @Override
284 public void clearCache(List<DLFileEntryMetadata> dlFileEntryMetadatas) {
285 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
286 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
287
288 for (DLFileEntryMetadata dlFileEntryMetadata : dlFileEntryMetadatas) {
289 EntityCacheUtil.removeResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
290 DLFileEntryMetadataImpl.class,
291 dlFileEntryMetadata.getPrimaryKey());
292
293 clearUniqueFindersCache(dlFileEntryMetadata);
294 }
295 }
296
297 protected void cacheUniqueFindersCache(
298 DLFileEntryMetadata dlFileEntryMetadata) {
299 if (dlFileEntryMetadata.isNew()) {
300 Object[] args = new Object[] {
301 Long.valueOf(dlFileEntryMetadata.getDDMStructureId()),
302 Long.valueOf(dlFileEntryMetadata.getFileVersionId())
303 };
304
305 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_D_F, args,
306 Long.valueOf(1));
307 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F, args,
308 dlFileEntryMetadata);
309
310 args = new Object[] {
311 Long.valueOf(dlFileEntryMetadata.getFileEntryId()),
312 Long.valueOf(dlFileEntryMetadata.getFileVersionId())
313 };
314
315 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_V, args,
316 Long.valueOf(1));
317 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V, args,
318 dlFileEntryMetadata);
319 }
320 else {
321 DLFileEntryMetadataModelImpl dlFileEntryMetadataModelImpl = (DLFileEntryMetadataModelImpl)dlFileEntryMetadata;
322
323 if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
324 FINDER_PATH_FETCH_BY_D_F.getColumnBitmask()) != 0) {
325 Object[] args = new Object[] {
326 Long.valueOf(dlFileEntryMetadata.getDDMStructureId()),
327 Long.valueOf(dlFileEntryMetadata.getFileVersionId())
328 };
329
330 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_D_F, args,
331 Long.valueOf(1));
332 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F, args,
333 dlFileEntryMetadata);
334 }
335
336 if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
337 FINDER_PATH_FETCH_BY_F_V.getColumnBitmask()) != 0) {
338 Object[] args = new Object[] {
339 Long.valueOf(dlFileEntryMetadata.getFileEntryId()),
340 Long.valueOf(dlFileEntryMetadata.getFileVersionId())
341 };
342
343 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_V, args,
344 Long.valueOf(1));
345 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V, args,
346 dlFileEntryMetadata);
347 }
348 }
349 }
350
351 protected void clearUniqueFindersCache(
352 DLFileEntryMetadata dlFileEntryMetadata) {
353 DLFileEntryMetadataModelImpl dlFileEntryMetadataModelImpl = (DLFileEntryMetadataModelImpl)dlFileEntryMetadata;
354
355 Object[] args = new Object[] {
356 Long.valueOf(dlFileEntryMetadata.getDDMStructureId()),
357 Long.valueOf(dlFileEntryMetadata.getFileVersionId())
358 };
359
360 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_D_F, args);
361 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_D_F, args);
362
363 if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
364 FINDER_PATH_FETCH_BY_D_F.getColumnBitmask()) != 0) {
365 args = new Object[] {
366 Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalDDMStructureId()),
367 Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileVersionId())
368 };
369
370 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_D_F, args);
371 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_D_F, args);
372 }
373
374 args = new Object[] {
375 Long.valueOf(dlFileEntryMetadata.getFileEntryId()),
376 Long.valueOf(dlFileEntryMetadata.getFileVersionId())
377 };
378
379 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_V, args);
380 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V, args);
381
382 if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
383 FINDER_PATH_FETCH_BY_F_V.getColumnBitmask()) != 0) {
384 args = new Object[] {
385 Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileEntryId()),
386 Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileVersionId())
387 };
388
389 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_F_V, args);
390 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V, args);
391 }
392 }
393
394
400 public DLFileEntryMetadata create(long fileEntryMetadataId) {
401 DLFileEntryMetadata dlFileEntryMetadata = new DLFileEntryMetadataImpl();
402
403 dlFileEntryMetadata.setNew(true);
404 dlFileEntryMetadata.setPrimaryKey(fileEntryMetadataId);
405
406 String uuid = PortalUUIDUtil.generate();
407
408 dlFileEntryMetadata.setUuid(uuid);
409
410 return dlFileEntryMetadata;
411 }
412
413
421 public DLFileEntryMetadata remove(long fileEntryMetadataId)
422 throws NoSuchFileEntryMetadataException, SystemException {
423 return remove(Long.valueOf(fileEntryMetadataId));
424 }
425
426
434 @Override
435 public DLFileEntryMetadata remove(Serializable primaryKey)
436 throws NoSuchFileEntryMetadataException, SystemException {
437 Session session = null;
438
439 try {
440 session = openSession();
441
442 DLFileEntryMetadata dlFileEntryMetadata = (DLFileEntryMetadata)session.get(DLFileEntryMetadataImpl.class,
443 primaryKey);
444
445 if (dlFileEntryMetadata == null) {
446 if (_log.isWarnEnabled()) {
447 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
448 }
449
450 throw new NoSuchFileEntryMetadataException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
451 primaryKey);
452 }
453
454 return remove(dlFileEntryMetadata);
455 }
456 catch (NoSuchFileEntryMetadataException nsee) {
457 throw nsee;
458 }
459 catch (Exception e) {
460 throw processException(e);
461 }
462 finally {
463 closeSession(session);
464 }
465 }
466
467 @Override
468 protected DLFileEntryMetadata removeImpl(
469 DLFileEntryMetadata dlFileEntryMetadata) throws SystemException {
470 dlFileEntryMetadata = toUnwrappedModel(dlFileEntryMetadata);
471
472 Session session = null;
473
474 try {
475 session = openSession();
476
477 BatchSessionUtil.delete(session, dlFileEntryMetadata);
478 }
479 catch (Exception e) {
480 throw processException(e);
481 }
482 finally {
483 closeSession(session);
484 }
485
486 clearCache(dlFileEntryMetadata);
487
488 return dlFileEntryMetadata;
489 }
490
491 @Override
492 public DLFileEntryMetadata updateImpl(
493 com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata dlFileEntryMetadata,
494 boolean merge) throws SystemException {
495 dlFileEntryMetadata = toUnwrappedModel(dlFileEntryMetadata);
496
497 boolean isNew = dlFileEntryMetadata.isNew();
498
499 DLFileEntryMetadataModelImpl dlFileEntryMetadataModelImpl = (DLFileEntryMetadataModelImpl)dlFileEntryMetadata;
500
501 if (Validator.isNull(dlFileEntryMetadata.getUuid())) {
502 String uuid = PortalUUIDUtil.generate();
503
504 dlFileEntryMetadata.setUuid(uuid);
505 }
506
507 Session session = null;
508
509 try {
510 session = openSession();
511
512 BatchSessionUtil.update(session, dlFileEntryMetadata, merge);
513
514 dlFileEntryMetadata.setNew(false);
515 }
516 catch (Exception e) {
517 throw processException(e);
518 }
519 finally {
520 closeSession(session);
521 }
522
523 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
524
525 if (isNew || !DLFileEntryMetadataModelImpl.COLUMN_BITMASK_ENABLED) {
526 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
527 }
528
529 else {
530 if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
531 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
532 Object[] args = new Object[] {
533 dlFileEntryMetadataModelImpl.getOriginalUuid()
534 };
535
536 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
537 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
538 args);
539
540 args = new Object[] { dlFileEntryMetadataModelImpl.getUuid() };
541
542 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
543 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
544 args);
545 }
546
547 if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
548 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID.getColumnBitmask()) != 0) {
549 Object[] args = new Object[] {
550 Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileEntryTypeId())
551 };
552
553 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
554 args);
555 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
556 args);
557
558 args = new Object[] {
559 Long.valueOf(dlFileEntryMetadataModelImpl.getFileEntryTypeId())
560 };
561
562 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
563 args);
564 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID,
565 args);
566 }
567
568 if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
569 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID.getColumnBitmask()) != 0) {
570 Object[] args = new Object[] {
571 Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileEntryId())
572 };
573
574 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
575 args);
576 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
577 args);
578
579 args = new Object[] {
580 Long.valueOf(dlFileEntryMetadataModelImpl.getFileEntryId())
581 };
582
583 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
584 args);
585 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
586 args);
587 }
588
589 if ((dlFileEntryMetadataModelImpl.getColumnBitmask() &
590 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID.getColumnBitmask()) != 0) {
591 Object[] args = new Object[] {
592 Long.valueOf(dlFileEntryMetadataModelImpl.getOriginalFileVersionId())
593 };
594
595 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEVERSIONID,
596 args);
597 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID,
598 args);
599
600 args = new Object[] {
601 Long.valueOf(dlFileEntryMetadataModelImpl.getFileVersionId())
602 };
603
604 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEVERSIONID,
605 args);
606 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID,
607 args);
608 }
609 }
610
611 EntityCacheUtil.putResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
612 DLFileEntryMetadataImpl.class, dlFileEntryMetadata.getPrimaryKey(),
613 dlFileEntryMetadata);
614
615 clearUniqueFindersCache(dlFileEntryMetadata);
616 cacheUniqueFindersCache(dlFileEntryMetadata);
617
618 return dlFileEntryMetadata;
619 }
620
621 protected DLFileEntryMetadata toUnwrappedModel(
622 DLFileEntryMetadata dlFileEntryMetadata) {
623 if (dlFileEntryMetadata instanceof DLFileEntryMetadataImpl) {
624 return dlFileEntryMetadata;
625 }
626
627 DLFileEntryMetadataImpl dlFileEntryMetadataImpl = new DLFileEntryMetadataImpl();
628
629 dlFileEntryMetadataImpl.setNew(dlFileEntryMetadata.isNew());
630 dlFileEntryMetadataImpl.setPrimaryKey(dlFileEntryMetadata.getPrimaryKey());
631
632 dlFileEntryMetadataImpl.setUuid(dlFileEntryMetadata.getUuid());
633 dlFileEntryMetadataImpl.setFileEntryMetadataId(dlFileEntryMetadata.getFileEntryMetadataId());
634 dlFileEntryMetadataImpl.setDDMStorageId(dlFileEntryMetadata.getDDMStorageId());
635 dlFileEntryMetadataImpl.setDDMStructureId(dlFileEntryMetadata.getDDMStructureId());
636 dlFileEntryMetadataImpl.setFileEntryTypeId(dlFileEntryMetadata.getFileEntryTypeId());
637 dlFileEntryMetadataImpl.setFileEntryId(dlFileEntryMetadata.getFileEntryId());
638 dlFileEntryMetadataImpl.setFileVersionId(dlFileEntryMetadata.getFileVersionId());
639
640 return dlFileEntryMetadataImpl;
641 }
642
643
651 @Override
652 public DLFileEntryMetadata findByPrimaryKey(Serializable primaryKey)
653 throws NoSuchModelException, SystemException {
654 return findByPrimaryKey(((Long)primaryKey).longValue());
655 }
656
657
665 public DLFileEntryMetadata findByPrimaryKey(long fileEntryMetadataId)
666 throws NoSuchFileEntryMetadataException, SystemException {
667 DLFileEntryMetadata dlFileEntryMetadata = fetchByPrimaryKey(fileEntryMetadataId);
668
669 if (dlFileEntryMetadata == null) {
670 if (_log.isWarnEnabled()) {
671 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
672 fileEntryMetadataId);
673 }
674
675 throw new NoSuchFileEntryMetadataException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
676 fileEntryMetadataId);
677 }
678
679 return dlFileEntryMetadata;
680 }
681
682
689 @Override
690 public DLFileEntryMetadata fetchByPrimaryKey(Serializable primaryKey)
691 throws SystemException {
692 return fetchByPrimaryKey(((Long)primaryKey).longValue());
693 }
694
695
702 public DLFileEntryMetadata fetchByPrimaryKey(long fileEntryMetadataId)
703 throws SystemException {
704 DLFileEntryMetadata dlFileEntryMetadata = (DLFileEntryMetadata)EntityCacheUtil.getResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
705 DLFileEntryMetadataImpl.class, fileEntryMetadataId);
706
707 if (dlFileEntryMetadata == _nullDLFileEntryMetadata) {
708 return null;
709 }
710
711 if (dlFileEntryMetadata == null) {
712 Session session = null;
713
714 boolean hasException = false;
715
716 try {
717 session = openSession();
718
719 dlFileEntryMetadata = (DLFileEntryMetadata)session.get(DLFileEntryMetadataImpl.class,
720 Long.valueOf(fileEntryMetadataId));
721 }
722 catch (Exception e) {
723 hasException = true;
724
725 throw processException(e);
726 }
727 finally {
728 if (dlFileEntryMetadata != null) {
729 cacheResult(dlFileEntryMetadata);
730 }
731 else if (!hasException) {
732 EntityCacheUtil.putResult(DLFileEntryMetadataModelImpl.ENTITY_CACHE_ENABLED,
733 DLFileEntryMetadataImpl.class, fileEntryMetadataId,
734 _nullDLFileEntryMetadata);
735 }
736
737 closeSession(session);
738 }
739 }
740
741 return dlFileEntryMetadata;
742 }
743
744
751 public List<DLFileEntryMetadata> findByUuid(String uuid)
752 throws SystemException {
753 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
754 }
755
756
769 public List<DLFileEntryMetadata> findByUuid(String uuid, int start, int end)
770 throws SystemException {
771 return findByUuid(uuid, start, end, null);
772 }
773
774
788 public List<DLFileEntryMetadata> findByUuid(String uuid, int start,
789 int end, OrderByComparator orderByComparator) throws SystemException {
790 FinderPath finderPath = null;
791 Object[] finderArgs = null;
792
793 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
794 (orderByComparator == null)) {
795 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
796 finderArgs = new Object[] { uuid };
797 }
798 else {
799 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
800 finderArgs = new Object[] { uuid, start, end, orderByComparator };
801 }
802
803 List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
804 finderArgs, this);
805
806 if ((list != null) && !list.isEmpty()) {
807 for (DLFileEntryMetadata dlFileEntryMetadata : list) {
808 if (!Validator.equals(uuid, dlFileEntryMetadata.getUuid())) {
809 list = null;
810
811 break;
812 }
813 }
814 }
815
816 if (list == null) {
817 StringBundler query = null;
818
819 if (orderByComparator != null) {
820 query = new StringBundler(3 +
821 (orderByComparator.getOrderByFields().length * 3));
822 }
823 else {
824 query = new StringBundler(2);
825 }
826
827 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
828
829 if (uuid == null) {
830 query.append(_FINDER_COLUMN_UUID_UUID_1);
831 }
832 else {
833 if (uuid.equals(StringPool.BLANK)) {
834 query.append(_FINDER_COLUMN_UUID_UUID_3);
835 }
836 else {
837 query.append(_FINDER_COLUMN_UUID_UUID_2);
838 }
839 }
840
841 if (orderByComparator != null) {
842 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
843 orderByComparator);
844 }
845
846 String sql = query.toString();
847
848 Session session = null;
849
850 try {
851 session = openSession();
852
853 Query q = session.createQuery(sql);
854
855 QueryPos qPos = QueryPos.getInstance(q);
856
857 if (uuid != null) {
858 qPos.add(uuid);
859 }
860
861 list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
862 getDialect(), start, end);
863 }
864 catch (Exception e) {
865 throw processException(e);
866 }
867 finally {
868 if (list == null) {
869 FinderCacheUtil.removeResult(finderPath, finderArgs);
870 }
871 else {
872 cacheResult(list);
873
874 FinderCacheUtil.putResult(finderPath, finderArgs, list);
875 }
876
877 closeSession(session);
878 }
879 }
880
881 return list;
882 }
883
884
893 public DLFileEntryMetadata findByUuid_First(String uuid,
894 OrderByComparator orderByComparator)
895 throws NoSuchFileEntryMetadataException, SystemException {
896 DLFileEntryMetadata dlFileEntryMetadata = fetchByUuid_First(uuid,
897 orderByComparator);
898
899 if (dlFileEntryMetadata != null) {
900 return dlFileEntryMetadata;
901 }
902
903 StringBundler msg = new StringBundler(4);
904
905 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
906
907 msg.append("uuid=");
908 msg.append(uuid);
909
910 msg.append(StringPool.CLOSE_CURLY_BRACE);
911
912 throw new NoSuchFileEntryMetadataException(msg.toString());
913 }
914
915
923 public DLFileEntryMetadata fetchByUuid_First(String uuid,
924 OrderByComparator orderByComparator) throws SystemException {
925 List<DLFileEntryMetadata> list = findByUuid(uuid, 0, 1,
926 orderByComparator);
927
928 if (!list.isEmpty()) {
929 return list.get(0);
930 }
931
932 return null;
933 }
934
935
944 public DLFileEntryMetadata findByUuid_Last(String uuid,
945 OrderByComparator orderByComparator)
946 throws NoSuchFileEntryMetadataException, SystemException {
947 DLFileEntryMetadata dlFileEntryMetadata = fetchByUuid_Last(uuid,
948 orderByComparator);
949
950 if (dlFileEntryMetadata != null) {
951 return dlFileEntryMetadata;
952 }
953
954 StringBundler msg = new StringBundler(4);
955
956 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
957
958 msg.append("uuid=");
959 msg.append(uuid);
960
961 msg.append(StringPool.CLOSE_CURLY_BRACE);
962
963 throw new NoSuchFileEntryMetadataException(msg.toString());
964 }
965
966
974 public DLFileEntryMetadata fetchByUuid_Last(String uuid,
975 OrderByComparator orderByComparator) throws SystemException {
976 int count = countByUuid(uuid);
977
978 List<DLFileEntryMetadata> list = findByUuid(uuid, count - 1, count,
979 orderByComparator);
980
981 if (!list.isEmpty()) {
982 return list.get(0);
983 }
984
985 return null;
986 }
987
988
998 public DLFileEntryMetadata[] findByUuid_PrevAndNext(
999 long fileEntryMetadataId, String uuid,
1000 OrderByComparator orderByComparator)
1001 throws NoSuchFileEntryMetadataException, SystemException {
1002 DLFileEntryMetadata dlFileEntryMetadata = findByPrimaryKey(fileEntryMetadataId);
1003
1004 Session session = null;
1005
1006 try {
1007 session = openSession();
1008
1009 DLFileEntryMetadata[] array = new DLFileEntryMetadataImpl[3];
1010
1011 array[0] = getByUuid_PrevAndNext(session, dlFileEntryMetadata,
1012 uuid, orderByComparator, true);
1013
1014 array[1] = dlFileEntryMetadata;
1015
1016 array[2] = getByUuid_PrevAndNext(session, dlFileEntryMetadata,
1017 uuid, orderByComparator, false);
1018
1019 return array;
1020 }
1021 catch (Exception e) {
1022 throw processException(e);
1023 }
1024 finally {
1025 closeSession(session);
1026 }
1027 }
1028
1029 protected DLFileEntryMetadata getByUuid_PrevAndNext(Session session,
1030 DLFileEntryMetadata dlFileEntryMetadata, String uuid,
1031 OrderByComparator orderByComparator, boolean previous) {
1032 StringBundler query = null;
1033
1034 if (orderByComparator != null) {
1035 query = new StringBundler(6 +
1036 (orderByComparator.getOrderByFields().length * 6));
1037 }
1038 else {
1039 query = new StringBundler(3);
1040 }
1041
1042 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1043
1044 if (uuid == null) {
1045 query.append(_FINDER_COLUMN_UUID_UUID_1);
1046 }
1047 else {
1048 if (uuid.equals(StringPool.BLANK)) {
1049 query.append(_FINDER_COLUMN_UUID_UUID_3);
1050 }
1051 else {
1052 query.append(_FINDER_COLUMN_UUID_UUID_2);
1053 }
1054 }
1055
1056 if (orderByComparator != null) {
1057 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1058
1059 if (orderByConditionFields.length > 0) {
1060 query.append(WHERE_AND);
1061 }
1062
1063 for (int i = 0; i < orderByConditionFields.length; i++) {
1064 query.append(_ORDER_BY_ENTITY_ALIAS);
1065 query.append(orderByConditionFields[i]);
1066
1067 if ((i + 1) < orderByConditionFields.length) {
1068 if (orderByComparator.isAscending() ^ previous) {
1069 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1070 }
1071 else {
1072 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1073 }
1074 }
1075 else {
1076 if (orderByComparator.isAscending() ^ previous) {
1077 query.append(WHERE_GREATER_THAN);
1078 }
1079 else {
1080 query.append(WHERE_LESSER_THAN);
1081 }
1082 }
1083 }
1084
1085 query.append(ORDER_BY_CLAUSE);
1086
1087 String[] orderByFields = orderByComparator.getOrderByFields();
1088
1089 for (int i = 0; i < orderByFields.length; i++) {
1090 query.append(_ORDER_BY_ENTITY_ALIAS);
1091 query.append(orderByFields[i]);
1092
1093 if ((i + 1) < orderByFields.length) {
1094 if (orderByComparator.isAscending() ^ previous) {
1095 query.append(ORDER_BY_ASC_HAS_NEXT);
1096 }
1097 else {
1098 query.append(ORDER_BY_DESC_HAS_NEXT);
1099 }
1100 }
1101 else {
1102 if (orderByComparator.isAscending() ^ previous) {
1103 query.append(ORDER_BY_ASC);
1104 }
1105 else {
1106 query.append(ORDER_BY_DESC);
1107 }
1108 }
1109 }
1110 }
1111
1112 String sql = query.toString();
1113
1114 Query q = session.createQuery(sql);
1115
1116 q.setFirstResult(0);
1117 q.setMaxResults(2);
1118
1119 QueryPos qPos = QueryPos.getInstance(q);
1120
1121 if (uuid != null) {
1122 qPos.add(uuid);
1123 }
1124
1125 if (orderByComparator != null) {
1126 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryMetadata);
1127
1128 for (Object value : values) {
1129 qPos.add(value);
1130 }
1131 }
1132
1133 List<DLFileEntryMetadata> list = q.list();
1134
1135 if (list.size() == 2) {
1136 return list.get(1);
1137 }
1138 else {
1139 return null;
1140 }
1141 }
1142
1143
1150 public List<DLFileEntryMetadata> findByFileEntryTypeId(long fileEntryTypeId)
1151 throws SystemException {
1152 return findByFileEntryTypeId(fileEntryTypeId, QueryUtil.ALL_POS,
1153 QueryUtil.ALL_POS, null);
1154 }
1155
1156
1169 public List<DLFileEntryMetadata> findByFileEntryTypeId(
1170 long fileEntryTypeId, int start, int end) throws SystemException {
1171 return findByFileEntryTypeId(fileEntryTypeId, start, end, null);
1172 }
1173
1174
1188 public List<DLFileEntryMetadata> findByFileEntryTypeId(
1189 long fileEntryTypeId, int start, int end,
1190 OrderByComparator orderByComparator) throws SystemException {
1191 FinderPath finderPath = null;
1192 Object[] finderArgs = null;
1193
1194 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1195 (orderByComparator == null)) {
1196 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYTYPEID;
1197 finderArgs = new Object[] { fileEntryTypeId };
1198 }
1199 else {
1200 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYTYPEID;
1201 finderArgs = new Object[] {
1202 fileEntryTypeId,
1203
1204 start, end, orderByComparator
1205 };
1206 }
1207
1208 List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
1209 finderArgs, this);
1210
1211 if ((list != null) && !list.isEmpty()) {
1212 for (DLFileEntryMetadata dlFileEntryMetadata : list) {
1213 if ((fileEntryTypeId != dlFileEntryMetadata.getFileEntryTypeId())) {
1214 list = null;
1215
1216 break;
1217 }
1218 }
1219 }
1220
1221 if (list == null) {
1222 StringBundler query = null;
1223
1224 if (orderByComparator != null) {
1225 query = new StringBundler(3 +
1226 (orderByComparator.getOrderByFields().length * 3));
1227 }
1228 else {
1229 query = new StringBundler(2);
1230 }
1231
1232 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1233
1234 query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
1235
1236 if (orderByComparator != null) {
1237 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1238 orderByComparator);
1239 }
1240
1241 String sql = query.toString();
1242
1243 Session session = null;
1244
1245 try {
1246 session = openSession();
1247
1248 Query q = session.createQuery(sql);
1249
1250 QueryPos qPos = QueryPos.getInstance(q);
1251
1252 qPos.add(fileEntryTypeId);
1253
1254 list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
1255 getDialect(), start, end);
1256 }
1257 catch (Exception e) {
1258 throw processException(e);
1259 }
1260 finally {
1261 if (list == null) {
1262 FinderCacheUtil.removeResult(finderPath, finderArgs);
1263 }
1264 else {
1265 cacheResult(list);
1266
1267 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1268 }
1269
1270 closeSession(session);
1271 }
1272 }
1273
1274 return list;
1275 }
1276
1277
1286 public DLFileEntryMetadata findByFileEntryTypeId_First(
1287 long fileEntryTypeId, OrderByComparator orderByComparator)
1288 throws NoSuchFileEntryMetadataException, SystemException {
1289 DLFileEntryMetadata dlFileEntryMetadata = fetchByFileEntryTypeId_First(fileEntryTypeId,
1290 orderByComparator);
1291
1292 if (dlFileEntryMetadata != null) {
1293 return dlFileEntryMetadata;
1294 }
1295
1296 StringBundler msg = new StringBundler(4);
1297
1298 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1299
1300 msg.append("fileEntryTypeId=");
1301 msg.append(fileEntryTypeId);
1302
1303 msg.append(StringPool.CLOSE_CURLY_BRACE);
1304
1305 throw new NoSuchFileEntryMetadataException(msg.toString());
1306 }
1307
1308
1316 public DLFileEntryMetadata fetchByFileEntryTypeId_First(
1317 long fileEntryTypeId, OrderByComparator orderByComparator)
1318 throws SystemException {
1319 List<DLFileEntryMetadata> list = findByFileEntryTypeId(fileEntryTypeId,
1320 0, 1, orderByComparator);
1321
1322 if (!list.isEmpty()) {
1323 return list.get(0);
1324 }
1325
1326 return null;
1327 }
1328
1329
1338 public DLFileEntryMetadata findByFileEntryTypeId_Last(
1339 long fileEntryTypeId, OrderByComparator orderByComparator)
1340 throws NoSuchFileEntryMetadataException, SystemException {
1341 DLFileEntryMetadata dlFileEntryMetadata = fetchByFileEntryTypeId_Last(fileEntryTypeId,
1342 orderByComparator);
1343
1344 if (dlFileEntryMetadata != null) {
1345 return dlFileEntryMetadata;
1346 }
1347
1348 StringBundler msg = new StringBundler(4);
1349
1350 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1351
1352 msg.append("fileEntryTypeId=");
1353 msg.append(fileEntryTypeId);
1354
1355 msg.append(StringPool.CLOSE_CURLY_BRACE);
1356
1357 throw new NoSuchFileEntryMetadataException(msg.toString());
1358 }
1359
1360
1368 public DLFileEntryMetadata fetchByFileEntryTypeId_Last(
1369 long fileEntryTypeId, OrderByComparator orderByComparator)
1370 throws SystemException {
1371 int count = countByFileEntryTypeId(fileEntryTypeId);
1372
1373 List<DLFileEntryMetadata> list = findByFileEntryTypeId(fileEntryTypeId,
1374 count - 1, count, orderByComparator);
1375
1376 if (!list.isEmpty()) {
1377 return list.get(0);
1378 }
1379
1380 return null;
1381 }
1382
1383
1393 public DLFileEntryMetadata[] findByFileEntryTypeId_PrevAndNext(
1394 long fileEntryMetadataId, long fileEntryTypeId,
1395 OrderByComparator orderByComparator)
1396 throws NoSuchFileEntryMetadataException, SystemException {
1397 DLFileEntryMetadata dlFileEntryMetadata = findByPrimaryKey(fileEntryMetadataId);
1398
1399 Session session = null;
1400
1401 try {
1402 session = openSession();
1403
1404 DLFileEntryMetadata[] array = new DLFileEntryMetadataImpl[3];
1405
1406 array[0] = getByFileEntryTypeId_PrevAndNext(session,
1407 dlFileEntryMetadata, fileEntryTypeId, orderByComparator,
1408 true);
1409
1410 array[1] = dlFileEntryMetadata;
1411
1412 array[2] = getByFileEntryTypeId_PrevAndNext(session,
1413 dlFileEntryMetadata, fileEntryTypeId, orderByComparator,
1414 false);
1415
1416 return array;
1417 }
1418 catch (Exception e) {
1419 throw processException(e);
1420 }
1421 finally {
1422 closeSession(session);
1423 }
1424 }
1425
1426 protected DLFileEntryMetadata getByFileEntryTypeId_PrevAndNext(
1427 Session session, DLFileEntryMetadata dlFileEntryMetadata,
1428 long fileEntryTypeId, OrderByComparator orderByComparator,
1429 boolean previous) {
1430 StringBundler query = null;
1431
1432 if (orderByComparator != null) {
1433 query = new StringBundler(6 +
1434 (orderByComparator.getOrderByFields().length * 6));
1435 }
1436 else {
1437 query = new StringBundler(3);
1438 }
1439
1440 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1441
1442 query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
1443
1444 if (orderByComparator != null) {
1445 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1446
1447 if (orderByConditionFields.length > 0) {
1448 query.append(WHERE_AND);
1449 }
1450
1451 for (int i = 0; i < orderByConditionFields.length; i++) {
1452 query.append(_ORDER_BY_ENTITY_ALIAS);
1453 query.append(orderByConditionFields[i]);
1454
1455 if ((i + 1) < orderByConditionFields.length) {
1456 if (orderByComparator.isAscending() ^ previous) {
1457 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1458 }
1459 else {
1460 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1461 }
1462 }
1463 else {
1464 if (orderByComparator.isAscending() ^ previous) {
1465 query.append(WHERE_GREATER_THAN);
1466 }
1467 else {
1468 query.append(WHERE_LESSER_THAN);
1469 }
1470 }
1471 }
1472
1473 query.append(ORDER_BY_CLAUSE);
1474
1475 String[] orderByFields = orderByComparator.getOrderByFields();
1476
1477 for (int i = 0; i < orderByFields.length; i++) {
1478 query.append(_ORDER_BY_ENTITY_ALIAS);
1479 query.append(orderByFields[i]);
1480
1481 if ((i + 1) < orderByFields.length) {
1482 if (orderByComparator.isAscending() ^ previous) {
1483 query.append(ORDER_BY_ASC_HAS_NEXT);
1484 }
1485 else {
1486 query.append(ORDER_BY_DESC_HAS_NEXT);
1487 }
1488 }
1489 else {
1490 if (orderByComparator.isAscending() ^ previous) {
1491 query.append(ORDER_BY_ASC);
1492 }
1493 else {
1494 query.append(ORDER_BY_DESC);
1495 }
1496 }
1497 }
1498 }
1499
1500 String sql = query.toString();
1501
1502 Query q = session.createQuery(sql);
1503
1504 q.setFirstResult(0);
1505 q.setMaxResults(2);
1506
1507 QueryPos qPos = QueryPos.getInstance(q);
1508
1509 qPos.add(fileEntryTypeId);
1510
1511 if (orderByComparator != null) {
1512 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryMetadata);
1513
1514 for (Object value : values) {
1515 qPos.add(value);
1516 }
1517 }
1518
1519 List<DLFileEntryMetadata> list = q.list();
1520
1521 if (list.size() == 2) {
1522 return list.get(1);
1523 }
1524 else {
1525 return null;
1526 }
1527 }
1528
1529
1536 public List<DLFileEntryMetadata> findByFileEntryId(long fileEntryId)
1537 throws SystemException {
1538 return findByFileEntryId(fileEntryId, QueryUtil.ALL_POS,
1539 QueryUtil.ALL_POS, null);
1540 }
1541
1542
1555 public List<DLFileEntryMetadata> findByFileEntryId(long fileEntryId,
1556 int start, int end) throws SystemException {
1557 return findByFileEntryId(fileEntryId, start, end, null);
1558 }
1559
1560
1574 public List<DLFileEntryMetadata> findByFileEntryId(long fileEntryId,
1575 int start, int end, OrderByComparator orderByComparator)
1576 throws SystemException {
1577 FinderPath finderPath = null;
1578 Object[] finderArgs = null;
1579
1580 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1581 (orderByComparator == null)) {
1582 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID;
1583 finderArgs = new Object[] { fileEntryId };
1584 }
1585 else {
1586 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID;
1587 finderArgs = new Object[] { fileEntryId, start, end, orderByComparator };
1588 }
1589
1590 List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
1591 finderArgs, this);
1592
1593 if ((list != null) && !list.isEmpty()) {
1594 for (DLFileEntryMetadata dlFileEntryMetadata : list) {
1595 if ((fileEntryId != dlFileEntryMetadata.getFileEntryId())) {
1596 list = null;
1597
1598 break;
1599 }
1600 }
1601 }
1602
1603 if (list == null) {
1604 StringBundler query = null;
1605
1606 if (orderByComparator != null) {
1607 query = new StringBundler(3 +
1608 (orderByComparator.getOrderByFields().length * 3));
1609 }
1610 else {
1611 query = new StringBundler(2);
1612 }
1613
1614 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1615
1616 query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1617
1618 if (orderByComparator != null) {
1619 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1620 orderByComparator);
1621 }
1622
1623 String sql = query.toString();
1624
1625 Session session = null;
1626
1627 try {
1628 session = openSession();
1629
1630 Query q = session.createQuery(sql);
1631
1632 QueryPos qPos = QueryPos.getInstance(q);
1633
1634 qPos.add(fileEntryId);
1635
1636 list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
1637 getDialect(), start, end);
1638 }
1639 catch (Exception e) {
1640 throw processException(e);
1641 }
1642 finally {
1643 if (list == null) {
1644 FinderCacheUtil.removeResult(finderPath, finderArgs);
1645 }
1646 else {
1647 cacheResult(list);
1648
1649 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1650 }
1651
1652 closeSession(session);
1653 }
1654 }
1655
1656 return list;
1657 }
1658
1659
1668 public DLFileEntryMetadata findByFileEntryId_First(long fileEntryId,
1669 OrderByComparator orderByComparator)
1670 throws NoSuchFileEntryMetadataException, SystemException {
1671 DLFileEntryMetadata dlFileEntryMetadata = fetchByFileEntryId_First(fileEntryId,
1672 orderByComparator);
1673
1674 if (dlFileEntryMetadata != null) {
1675 return dlFileEntryMetadata;
1676 }
1677
1678 StringBundler msg = new StringBundler(4);
1679
1680 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1681
1682 msg.append("fileEntryId=");
1683 msg.append(fileEntryId);
1684
1685 msg.append(StringPool.CLOSE_CURLY_BRACE);
1686
1687 throw new NoSuchFileEntryMetadataException(msg.toString());
1688 }
1689
1690
1698 public DLFileEntryMetadata fetchByFileEntryId_First(long fileEntryId,
1699 OrderByComparator orderByComparator) throws SystemException {
1700 List<DLFileEntryMetadata> list = findByFileEntryId(fileEntryId, 0, 1,
1701 orderByComparator);
1702
1703 if (!list.isEmpty()) {
1704 return list.get(0);
1705 }
1706
1707 return null;
1708 }
1709
1710
1719 public DLFileEntryMetadata findByFileEntryId_Last(long fileEntryId,
1720 OrderByComparator orderByComparator)
1721 throws NoSuchFileEntryMetadataException, SystemException {
1722 DLFileEntryMetadata dlFileEntryMetadata = fetchByFileEntryId_Last(fileEntryId,
1723 orderByComparator);
1724
1725 if (dlFileEntryMetadata != null) {
1726 return dlFileEntryMetadata;
1727 }
1728
1729 StringBundler msg = new StringBundler(4);
1730
1731 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1732
1733 msg.append("fileEntryId=");
1734 msg.append(fileEntryId);
1735
1736 msg.append(StringPool.CLOSE_CURLY_BRACE);
1737
1738 throw new NoSuchFileEntryMetadataException(msg.toString());
1739 }
1740
1741
1749 public DLFileEntryMetadata fetchByFileEntryId_Last(long fileEntryId,
1750 OrderByComparator orderByComparator) throws SystemException {
1751 int count = countByFileEntryId(fileEntryId);
1752
1753 List<DLFileEntryMetadata> list = findByFileEntryId(fileEntryId,
1754 count - 1, count, orderByComparator);
1755
1756 if (!list.isEmpty()) {
1757 return list.get(0);
1758 }
1759
1760 return null;
1761 }
1762
1763
1773 public DLFileEntryMetadata[] findByFileEntryId_PrevAndNext(
1774 long fileEntryMetadataId, long fileEntryId,
1775 OrderByComparator orderByComparator)
1776 throws NoSuchFileEntryMetadataException, SystemException {
1777 DLFileEntryMetadata dlFileEntryMetadata = findByPrimaryKey(fileEntryMetadataId);
1778
1779 Session session = null;
1780
1781 try {
1782 session = openSession();
1783
1784 DLFileEntryMetadata[] array = new DLFileEntryMetadataImpl[3];
1785
1786 array[0] = getByFileEntryId_PrevAndNext(session,
1787 dlFileEntryMetadata, fileEntryId, orderByComparator, true);
1788
1789 array[1] = dlFileEntryMetadata;
1790
1791 array[2] = getByFileEntryId_PrevAndNext(session,
1792 dlFileEntryMetadata, fileEntryId, orderByComparator, false);
1793
1794 return array;
1795 }
1796 catch (Exception e) {
1797 throw processException(e);
1798 }
1799 finally {
1800 closeSession(session);
1801 }
1802 }
1803
1804 protected DLFileEntryMetadata getByFileEntryId_PrevAndNext(
1805 Session session, DLFileEntryMetadata dlFileEntryMetadata,
1806 long fileEntryId, OrderByComparator orderByComparator, boolean previous) {
1807 StringBundler query = null;
1808
1809 if (orderByComparator != null) {
1810 query = new StringBundler(6 +
1811 (orderByComparator.getOrderByFields().length * 6));
1812 }
1813 else {
1814 query = new StringBundler(3);
1815 }
1816
1817 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1818
1819 query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1820
1821 if (orderByComparator != null) {
1822 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1823
1824 if (orderByConditionFields.length > 0) {
1825 query.append(WHERE_AND);
1826 }
1827
1828 for (int i = 0; i < orderByConditionFields.length; i++) {
1829 query.append(_ORDER_BY_ENTITY_ALIAS);
1830 query.append(orderByConditionFields[i]);
1831
1832 if ((i + 1) < orderByConditionFields.length) {
1833 if (orderByComparator.isAscending() ^ previous) {
1834 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1835 }
1836 else {
1837 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1838 }
1839 }
1840 else {
1841 if (orderByComparator.isAscending() ^ previous) {
1842 query.append(WHERE_GREATER_THAN);
1843 }
1844 else {
1845 query.append(WHERE_LESSER_THAN);
1846 }
1847 }
1848 }
1849
1850 query.append(ORDER_BY_CLAUSE);
1851
1852 String[] orderByFields = orderByComparator.getOrderByFields();
1853
1854 for (int i = 0; i < orderByFields.length; i++) {
1855 query.append(_ORDER_BY_ENTITY_ALIAS);
1856 query.append(orderByFields[i]);
1857
1858 if ((i + 1) < orderByFields.length) {
1859 if (orderByComparator.isAscending() ^ previous) {
1860 query.append(ORDER_BY_ASC_HAS_NEXT);
1861 }
1862 else {
1863 query.append(ORDER_BY_DESC_HAS_NEXT);
1864 }
1865 }
1866 else {
1867 if (orderByComparator.isAscending() ^ previous) {
1868 query.append(ORDER_BY_ASC);
1869 }
1870 else {
1871 query.append(ORDER_BY_DESC);
1872 }
1873 }
1874 }
1875 }
1876
1877 String sql = query.toString();
1878
1879 Query q = session.createQuery(sql);
1880
1881 q.setFirstResult(0);
1882 q.setMaxResults(2);
1883
1884 QueryPos qPos = QueryPos.getInstance(q);
1885
1886 qPos.add(fileEntryId);
1887
1888 if (orderByComparator != null) {
1889 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryMetadata);
1890
1891 for (Object value : values) {
1892 qPos.add(value);
1893 }
1894 }
1895
1896 List<DLFileEntryMetadata> list = q.list();
1897
1898 if (list.size() == 2) {
1899 return list.get(1);
1900 }
1901 else {
1902 return null;
1903 }
1904 }
1905
1906
1913 public List<DLFileEntryMetadata> findByFileVersionId(long fileVersionId)
1914 throws SystemException {
1915 return findByFileVersionId(fileVersionId, QueryUtil.ALL_POS,
1916 QueryUtil.ALL_POS, null);
1917 }
1918
1919
1932 public List<DLFileEntryMetadata> findByFileVersionId(long fileVersionId,
1933 int start, int end) throws SystemException {
1934 return findByFileVersionId(fileVersionId, start, end, null);
1935 }
1936
1937
1951 public List<DLFileEntryMetadata> findByFileVersionId(long fileVersionId,
1952 int start, int end, OrderByComparator orderByComparator)
1953 throws SystemException {
1954 FinderPath finderPath = null;
1955 Object[] finderArgs = null;
1956
1957 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1958 (orderByComparator == null)) {
1959 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEVERSIONID;
1960 finderArgs = new Object[] { fileVersionId };
1961 }
1962 else {
1963 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEVERSIONID;
1964 finderArgs = new Object[] {
1965 fileVersionId,
1966
1967 start, end, orderByComparator
1968 };
1969 }
1970
1971 List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
1972 finderArgs, this);
1973
1974 if ((list != null) && !list.isEmpty()) {
1975 for (DLFileEntryMetadata dlFileEntryMetadata : list) {
1976 if ((fileVersionId != dlFileEntryMetadata.getFileVersionId())) {
1977 list = null;
1978
1979 break;
1980 }
1981 }
1982 }
1983
1984 if (list == null) {
1985 StringBundler query = null;
1986
1987 if (orderByComparator != null) {
1988 query = new StringBundler(3 +
1989 (orderByComparator.getOrderByFields().length * 3));
1990 }
1991 else {
1992 query = new StringBundler(2);
1993 }
1994
1995 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
1996
1997 query.append(_FINDER_COLUMN_FILEVERSIONID_FILEVERSIONID_2);
1998
1999 if (orderByComparator != null) {
2000 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2001 orderByComparator);
2002 }
2003
2004 String sql = query.toString();
2005
2006 Session session = null;
2007
2008 try {
2009 session = openSession();
2010
2011 Query q = session.createQuery(sql);
2012
2013 QueryPos qPos = QueryPos.getInstance(q);
2014
2015 qPos.add(fileVersionId);
2016
2017 list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
2018 getDialect(), start, end);
2019 }
2020 catch (Exception e) {
2021 throw processException(e);
2022 }
2023 finally {
2024 if (list == null) {
2025 FinderCacheUtil.removeResult(finderPath, finderArgs);
2026 }
2027 else {
2028 cacheResult(list);
2029
2030 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2031 }
2032
2033 closeSession(session);
2034 }
2035 }
2036
2037 return list;
2038 }
2039
2040
2049 public DLFileEntryMetadata findByFileVersionId_First(long fileVersionId,
2050 OrderByComparator orderByComparator)
2051 throws NoSuchFileEntryMetadataException, SystemException {
2052 DLFileEntryMetadata dlFileEntryMetadata = fetchByFileVersionId_First(fileVersionId,
2053 orderByComparator);
2054
2055 if (dlFileEntryMetadata != null) {
2056 return dlFileEntryMetadata;
2057 }
2058
2059 StringBundler msg = new StringBundler(4);
2060
2061 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2062
2063 msg.append("fileVersionId=");
2064 msg.append(fileVersionId);
2065
2066 msg.append(StringPool.CLOSE_CURLY_BRACE);
2067
2068 throw new NoSuchFileEntryMetadataException(msg.toString());
2069 }
2070
2071
2079 public DLFileEntryMetadata fetchByFileVersionId_First(long fileVersionId,
2080 OrderByComparator orderByComparator) throws SystemException {
2081 List<DLFileEntryMetadata> list = findByFileVersionId(fileVersionId, 0,
2082 1, orderByComparator);
2083
2084 if (!list.isEmpty()) {
2085 return list.get(0);
2086 }
2087
2088 return null;
2089 }
2090
2091
2100 public DLFileEntryMetadata findByFileVersionId_Last(long fileVersionId,
2101 OrderByComparator orderByComparator)
2102 throws NoSuchFileEntryMetadataException, SystemException {
2103 DLFileEntryMetadata dlFileEntryMetadata = fetchByFileVersionId_Last(fileVersionId,
2104 orderByComparator);
2105
2106 if (dlFileEntryMetadata != null) {
2107 return dlFileEntryMetadata;
2108 }
2109
2110 StringBundler msg = new StringBundler(4);
2111
2112 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2113
2114 msg.append("fileVersionId=");
2115 msg.append(fileVersionId);
2116
2117 msg.append(StringPool.CLOSE_CURLY_BRACE);
2118
2119 throw new NoSuchFileEntryMetadataException(msg.toString());
2120 }
2121
2122
2130 public DLFileEntryMetadata fetchByFileVersionId_Last(long fileVersionId,
2131 OrderByComparator orderByComparator) throws SystemException {
2132 int count = countByFileVersionId(fileVersionId);
2133
2134 List<DLFileEntryMetadata> list = findByFileVersionId(fileVersionId,
2135 count - 1, count, orderByComparator);
2136
2137 if (!list.isEmpty()) {
2138 return list.get(0);
2139 }
2140
2141 return null;
2142 }
2143
2144
2154 public DLFileEntryMetadata[] findByFileVersionId_PrevAndNext(
2155 long fileEntryMetadataId, long fileVersionId,
2156 OrderByComparator orderByComparator)
2157 throws NoSuchFileEntryMetadataException, SystemException {
2158 DLFileEntryMetadata dlFileEntryMetadata = findByPrimaryKey(fileEntryMetadataId);
2159
2160 Session session = null;
2161
2162 try {
2163 session = openSession();
2164
2165 DLFileEntryMetadata[] array = new DLFileEntryMetadataImpl[3];
2166
2167 array[0] = getByFileVersionId_PrevAndNext(session,
2168 dlFileEntryMetadata, fileVersionId, orderByComparator, true);
2169
2170 array[1] = dlFileEntryMetadata;
2171
2172 array[2] = getByFileVersionId_PrevAndNext(session,
2173 dlFileEntryMetadata, fileVersionId, orderByComparator, false);
2174
2175 return array;
2176 }
2177 catch (Exception e) {
2178 throw processException(e);
2179 }
2180 finally {
2181 closeSession(session);
2182 }
2183 }
2184
2185 protected DLFileEntryMetadata getByFileVersionId_PrevAndNext(
2186 Session session, DLFileEntryMetadata dlFileEntryMetadata,
2187 long fileVersionId, OrderByComparator orderByComparator,
2188 boolean previous) {
2189 StringBundler query = null;
2190
2191 if (orderByComparator != null) {
2192 query = new StringBundler(6 +
2193 (orderByComparator.getOrderByFields().length * 6));
2194 }
2195 else {
2196 query = new StringBundler(3);
2197 }
2198
2199 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
2200
2201 query.append(_FINDER_COLUMN_FILEVERSIONID_FILEVERSIONID_2);
2202
2203 if (orderByComparator != null) {
2204 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2205
2206 if (orderByConditionFields.length > 0) {
2207 query.append(WHERE_AND);
2208 }
2209
2210 for (int i = 0; i < orderByConditionFields.length; i++) {
2211 query.append(_ORDER_BY_ENTITY_ALIAS);
2212 query.append(orderByConditionFields[i]);
2213
2214 if ((i + 1) < orderByConditionFields.length) {
2215 if (orderByComparator.isAscending() ^ previous) {
2216 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2217 }
2218 else {
2219 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2220 }
2221 }
2222 else {
2223 if (orderByComparator.isAscending() ^ previous) {
2224 query.append(WHERE_GREATER_THAN);
2225 }
2226 else {
2227 query.append(WHERE_LESSER_THAN);
2228 }
2229 }
2230 }
2231
2232 query.append(ORDER_BY_CLAUSE);
2233
2234 String[] orderByFields = orderByComparator.getOrderByFields();
2235
2236 for (int i = 0; i < orderByFields.length; i++) {
2237 query.append(_ORDER_BY_ENTITY_ALIAS);
2238 query.append(orderByFields[i]);
2239
2240 if ((i + 1) < orderByFields.length) {
2241 if (orderByComparator.isAscending() ^ previous) {
2242 query.append(ORDER_BY_ASC_HAS_NEXT);
2243 }
2244 else {
2245 query.append(ORDER_BY_DESC_HAS_NEXT);
2246 }
2247 }
2248 else {
2249 if (orderByComparator.isAscending() ^ previous) {
2250 query.append(ORDER_BY_ASC);
2251 }
2252 else {
2253 query.append(ORDER_BY_DESC);
2254 }
2255 }
2256 }
2257 }
2258
2259 String sql = query.toString();
2260
2261 Query q = session.createQuery(sql);
2262
2263 q.setFirstResult(0);
2264 q.setMaxResults(2);
2265
2266 QueryPos qPos = QueryPos.getInstance(q);
2267
2268 qPos.add(fileVersionId);
2269
2270 if (orderByComparator != null) {
2271 Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryMetadata);
2272
2273 for (Object value : values) {
2274 qPos.add(value);
2275 }
2276 }
2277
2278 List<DLFileEntryMetadata> list = q.list();
2279
2280 if (list.size() == 2) {
2281 return list.get(1);
2282 }
2283 else {
2284 return null;
2285 }
2286 }
2287
2288
2297 public DLFileEntryMetadata findByD_F(long DDMStructureId, long fileVersionId)
2298 throws NoSuchFileEntryMetadataException, SystemException {
2299 DLFileEntryMetadata dlFileEntryMetadata = fetchByD_F(DDMStructureId,
2300 fileVersionId);
2301
2302 if (dlFileEntryMetadata == null) {
2303 StringBundler msg = new StringBundler(6);
2304
2305 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2306
2307 msg.append("DDMStructureId=");
2308 msg.append(DDMStructureId);
2309
2310 msg.append(", fileVersionId=");
2311 msg.append(fileVersionId);
2312
2313 msg.append(StringPool.CLOSE_CURLY_BRACE);
2314
2315 if (_log.isWarnEnabled()) {
2316 _log.warn(msg.toString());
2317 }
2318
2319 throw new NoSuchFileEntryMetadataException(msg.toString());
2320 }
2321
2322 return dlFileEntryMetadata;
2323 }
2324
2325
2333 public DLFileEntryMetadata fetchByD_F(long DDMStructureId,
2334 long fileVersionId) throws SystemException {
2335 return fetchByD_F(DDMStructureId, fileVersionId, true);
2336 }
2337
2338
2347 public DLFileEntryMetadata fetchByD_F(long DDMStructureId,
2348 long fileVersionId, boolean retrieveFromCache)
2349 throws SystemException {
2350 Object[] finderArgs = new Object[] { DDMStructureId, fileVersionId };
2351
2352 Object result = null;
2353
2354 if (retrieveFromCache) {
2355 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_D_F,
2356 finderArgs, this);
2357 }
2358
2359 if (result instanceof DLFileEntryMetadata) {
2360 DLFileEntryMetadata dlFileEntryMetadata = (DLFileEntryMetadata)result;
2361
2362 if ((DDMStructureId != dlFileEntryMetadata.getDDMStructureId()) ||
2363 (fileVersionId != dlFileEntryMetadata.getFileVersionId())) {
2364 result = null;
2365 }
2366 }
2367
2368 if (result == null) {
2369 StringBundler query = new StringBundler(3);
2370
2371 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
2372
2373 query.append(_FINDER_COLUMN_D_F_DDMSTRUCTUREID_2);
2374
2375 query.append(_FINDER_COLUMN_D_F_FILEVERSIONID_2);
2376
2377 String sql = query.toString();
2378
2379 Session session = null;
2380
2381 try {
2382 session = openSession();
2383
2384 Query q = session.createQuery(sql);
2385
2386 QueryPos qPos = QueryPos.getInstance(q);
2387
2388 qPos.add(DDMStructureId);
2389
2390 qPos.add(fileVersionId);
2391
2392 List<DLFileEntryMetadata> list = q.list();
2393
2394 result = list;
2395
2396 DLFileEntryMetadata dlFileEntryMetadata = null;
2397
2398 if (list.isEmpty()) {
2399 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F,
2400 finderArgs, list);
2401 }
2402 else {
2403 dlFileEntryMetadata = list.get(0);
2404
2405 cacheResult(dlFileEntryMetadata);
2406
2407 if ((dlFileEntryMetadata.getDDMStructureId() != DDMStructureId) ||
2408 (dlFileEntryMetadata.getFileVersionId() != fileVersionId)) {
2409 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_D_F,
2410 finderArgs, dlFileEntryMetadata);
2411 }
2412 }
2413
2414 return dlFileEntryMetadata;
2415 }
2416 catch (Exception e) {
2417 throw processException(e);
2418 }
2419 finally {
2420 if (result == null) {
2421 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_D_F,
2422 finderArgs);
2423 }
2424
2425 closeSession(session);
2426 }
2427 }
2428 else {
2429 if (result instanceof List<?>) {
2430 return null;
2431 }
2432 else {
2433 return (DLFileEntryMetadata)result;
2434 }
2435 }
2436 }
2437
2438
2447 public DLFileEntryMetadata findByF_V(long fileEntryId, long fileVersionId)
2448 throws NoSuchFileEntryMetadataException, SystemException {
2449 DLFileEntryMetadata dlFileEntryMetadata = fetchByF_V(fileEntryId,
2450 fileVersionId);
2451
2452 if (dlFileEntryMetadata == null) {
2453 StringBundler msg = new StringBundler(6);
2454
2455 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2456
2457 msg.append("fileEntryId=");
2458 msg.append(fileEntryId);
2459
2460 msg.append(", fileVersionId=");
2461 msg.append(fileVersionId);
2462
2463 msg.append(StringPool.CLOSE_CURLY_BRACE);
2464
2465 if (_log.isWarnEnabled()) {
2466 _log.warn(msg.toString());
2467 }
2468
2469 throw new NoSuchFileEntryMetadataException(msg.toString());
2470 }
2471
2472 return dlFileEntryMetadata;
2473 }
2474
2475
2483 public DLFileEntryMetadata fetchByF_V(long fileEntryId, long fileVersionId)
2484 throws SystemException {
2485 return fetchByF_V(fileEntryId, fileVersionId, true);
2486 }
2487
2488
2497 public DLFileEntryMetadata fetchByF_V(long fileEntryId, long fileVersionId,
2498 boolean retrieveFromCache) throws SystemException {
2499 Object[] finderArgs = new Object[] { fileEntryId, fileVersionId };
2500
2501 Object result = null;
2502
2503 if (retrieveFromCache) {
2504 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_F_V,
2505 finderArgs, this);
2506 }
2507
2508 if (result instanceof DLFileEntryMetadata) {
2509 DLFileEntryMetadata dlFileEntryMetadata = (DLFileEntryMetadata)result;
2510
2511 if ((fileEntryId != dlFileEntryMetadata.getFileEntryId()) ||
2512 (fileVersionId != dlFileEntryMetadata.getFileVersionId())) {
2513 result = null;
2514 }
2515 }
2516
2517 if (result == null) {
2518 StringBundler query = new StringBundler(3);
2519
2520 query.append(_SQL_SELECT_DLFILEENTRYMETADATA_WHERE);
2521
2522 query.append(_FINDER_COLUMN_F_V_FILEENTRYID_2);
2523
2524 query.append(_FINDER_COLUMN_F_V_FILEVERSIONID_2);
2525
2526 String sql = query.toString();
2527
2528 Session session = null;
2529
2530 try {
2531 session = openSession();
2532
2533 Query q = session.createQuery(sql);
2534
2535 QueryPos qPos = QueryPos.getInstance(q);
2536
2537 qPos.add(fileEntryId);
2538
2539 qPos.add(fileVersionId);
2540
2541 List<DLFileEntryMetadata> list = q.list();
2542
2543 result = list;
2544
2545 DLFileEntryMetadata dlFileEntryMetadata = null;
2546
2547 if (list.isEmpty()) {
2548 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
2549 finderArgs, list);
2550 }
2551 else {
2552 dlFileEntryMetadata = list.get(0);
2553
2554 cacheResult(dlFileEntryMetadata);
2555
2556 if ((dlFileEntryMetadata.getFileEntryId() != fileEntryId) ||
2557 (dlFileEntryMetadata.getFileVersionId() != fileVersionId)) {
2558 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_V,
2559 finderArgs, dlFileEntryMetadata);
2560 }
2561 }
2562
2563 return dlFileEntryMetadata;
2564 }
2565 catch (Exception e) {
2566 throw processException(e);
2567 }
2568 finally {
2569 if (result == null) {
2570 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_V,
2571 finderArgs);
2572 }
2573
2574 closeSession(session);
2575 }
2576 }
2577 else {
2578 if (result instanceof List<?>) {
2579 return null;
2580 }
2581 else {
2582 return (DLFileEntryMetadata)result;
2583 }
2584 }
2585 }
2586
2587
2593 public List<DLFileEntryMetadata> findAll() throws SystemException {
2594 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2595 }
2596
2597
2609 public List<DLFileEntryMetadata> findAll(int start, int end)
2610 throws SystemException {
2611 return findAll(start, end, null);
2612 }
2613
2614
2627 public List<DLFileEntryMetadata> findAll(int start, int end,
2628 OrderByComparator orderByComparator) throws SystemException {
2629 FinderPath finderPath = null;
2630 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2631
2632 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2633 (orderByComparator == null)) {
2634 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2635 finderArgs = FINDER_ARGS_EMPTY;
2636 }
2637 else {
2638 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2639 finderArgs = new Object[] { start, end, orderByComparator };
2640 }
2641
2642 List<DLFileEntryMetadata> list = (List<DLFileEntryMetadata>)FinderCacheUtil.getResult(finderPath,
2643 finderArgs, this);
2644
2645 if (list == null) {
2646 StringBundler query = null;
2647 String sql = null;
2648
2649 if (orderByComparator != null) {
2650 query = new StringBundler(2 +
2651 (orderByComparator.getOrderByFields().length * 3));
2652
2653 query.append(_SQL_SELECT_DLFILEENTRYMETADATA);
2654
2655 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2656 orderByComparator);
2657
2658 sql = query.toString();
2659 }
2660 else {
2661 sql = _SQL_SELECT_DLFILEENTRYMETADATA;
2662 }
2663
2664 Session session = null;
2665
2666 try {
2667 session = openSession();
2668
2669 Query q = session.createQuery(sql);
2670
2671 if (orderByComparator == null) {
2672 list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
2673 getDialect(), start, end, false);
2674
2675 Collections.sort(list);
2676 }
2677 else {
2678 list = (List<DLFileEntryMetadata>)QueryUtil.list(q,
2679 getDialect(), start, end);
2680 }
2681 }
2682 catch (Exception e) {
2683 throw processException(e);
2684 }
2685 finally {
2686 if (list == null) {
2687 FinderCacheUtil.removeResult(finderPath, finderArgs);
2688 }
2689 else {
2690 cacheResult(list);
2691
2692 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2693 }
2694
2695 closeSession(session);
2696 }
2697 }
2698
2699 return list;
2700 }
2701
2702
2708 public void removeByUuid(String uuid) throws SystemException {
2709 for (DLFileEntryMetadata dlFileEntryMetadata : findByUuid(uuid)) {
2710 remove(dlFileEntryMetadata);
2711 }
2712 }
2713
2714
2720 public void removeByFileEntryTypeId(long fileEntryTypeId)
2721 throws SystemException {
2722 for (DLFileEntryMetadata dlFileEntryMetadata : findByFileEntryTypeId(
2723 fileEntryTypeId)) {
2724 remove(dlFileEntryMetadata);
2725 }
2726 }
2727
2728
2734 public void removeByFileEntryId(long fileEntryId) throws SystemException {
2735 for (DLFileEntryMetadata dlFileEntryMetadata : findByFileEntryId(
2736 fileEntryId)) {
2737 remove(dlFileEntryMetadata);
2738 }
2739 }
2740
2741
2747 public void removeByFileVersionId(long fileVersionId)
2748 throws SystemException {
2749 for (DLFileEntryMetadata dlFileEntryMetadata : findByFileVersionId(
2750 fileVersionId)) {
2751 remove(dlFileEntryMetadata);
2752 }
2753 }
2754
2755
2763 public DLFileEntryMetadata removeByD_F(long DDMStructureId,
2764 long fileVersionId)
2765 throws NoSuchFileEntryMetadataException, SystemException {
2766 DLFileEntryMetadata dlFileEntryMetadata = findByD_F(DDMStructureId,
2767 fileVersionId);
2768
2769 return remove(dlFileEntryMetadata);
2770 }
2771
2772
2780 public DLFileEntryMetadata removeByF_V(long fileEntryId, long fileVersionId)
2781 throws NoSuchFileEntryMetadataException, SystemException {
2782 DLFileEntryMetadata dlFileEntryMetadata = findByF_V(fileEntryId,
2783 fileVersionId);
2784
2785 return remove(dlFileEntryMetadata);
2786 }
2787
2788
2793 public void removeAll() throws SystemException {
2794 for (DLFileEntryMetadata dlFileEntryMetadata : findAll()) {
2795 remove(dlFileEntryMetadata);
2796 }
2797 }
2798
2799
2806 public int countByUuid(String uuid) throws SystemException {
2807 Object[] finderArgs = new Object[] { uuid };
2808
2809 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2810 finderArgs, this);
2811
2812 if (count == null) {
2813 StringBundler query = new StringBundler(2);
2814
2815 query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2816
2817 if (uuid == null) {
2818 query.append(_FINDER_COLUMN_UUID_UUID_1);
2819 }
2820 else {
2821 if (uuid.equals(StringPool.BLANK)) {
2822 query.append(_FINDER_COLUMN_UUID_UUID_3);
2823 }
2824 else {
2825 query.append(_FINDER_COLUMN_UUID_UUID_2);
2826 }
2827 }
2828
2829 String sql = query.toString();
2830
2831 Session session = null;
2832
2833 try {
2834 session = openSession();
2835
2836 Query q = session.createQuery(sql);
2837
2838 QueryPos qPos = QueryPos.getInstance(q);
2839
2840 if (uuid != null) {
2841 qPos.add(uuid);
2842 }
2843
2844 count = (Long)q.uniqueResult();
2845 }
2846 catch (Exception e) {
2847 throw processException(e);
2848 }
2849 finally {
2850 if (count == null) {
2851 count = Long.valueOf(0);
2852 }
2853
2854 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2855 finderArgs, count);
2856
2857 closeSession(session);
2858 }
2859 }
2860
2861 return count.intValue();
2862 }
2863
2864
2871 public int countByFileEntryTypeId(long fileEntryTypeId)
2872 throws SystemException {
2873 Object[] finderArgs = new Object[] { fileEntryTypeId };
2874
2875 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
2876 finderArgs, this);
2877
2878 if (count == null) {
2879 StringBundler query = new StringBundler(2);
2880
2881 query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2882
2883 query.append(_FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2);
2884
2885 String sql = query.toString();
2886
2887 Session session = null;
2888
2889 try {
2890 session = openSession();
2891
2892 Query q = session.createQuery(sql);
2893
2894 QueryPos qPos = QueryPos.getInstance(q);
2895
2896 qPos.add(fileEntryTypeId);
2897
2898 count = (Long)q.uniqueResult();
2899 }
2900 catch (Exception e) {
2901 throw processException(e);
2902 }
2903 finally {
2904 if (count == null) {
2905 count = Long.valueOf(0);
2906 }
2907
2908 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYTYPEID,
2909 finderArgs, count);
2910
2911 closeSession(session);
2912 }
2913 }
2914
2915 return count.intValue();
2916 }
2917
2918
2925 public int countByFileEntryId(long fileEntryId) throws SystemException {
2926 Object[] finderArgs = new Object[] { fileEntryId };
2927
2928 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2929 finderArgs, this);
2930
2931 if (count == null) {
2932 StringBundler query = new StringBundler(2);
2933
2934 query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2935
2936 query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
2937
2938 String sql = query.toString();
2939
2940 Session session = null;
2941
2942 try {
2943 session = openSession();
2944
2945 Query q = session.createQuery(sql);
2946
2947 QueryPos qPos = QueryPos.getInstance(q);
2948
2949 qPos.add(fileEntryId);
2950
2951 count = (Long)q.uniqueResult();
2952 }
2953 catch (Exception e) {
2954 throw processException(e);
2955 }
2956 finally {
2957 if (count == null) {
2958 count = Long.valueOf(0);
2959 }
2960
2961 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2962 finderArgs, count);
2963
2964 closeSession(session);
2965 }
2966 }
2967
2968 return count.intValue();
2969 }
2970
2971
2978 public int countByFileVersionId(long fileVersionId)
2979 throws SystemException {
2980 Object[] finderArgs = new Object[] { fileVersionId };
2981
2982 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEVERSIONID,
2983 finderArgs, this);
2984
2985 if (count == null) {
2986 StringBundler query = new StringBundler(2);
2987
2988 query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
2989
2990 query.append(_FINDER_COLUMN_FILEVERSIONID_FILEVERSIONID_2);
2991
2992 String sql = query.toString();
2993
2994 Session session = null;
2995
2996 try {
2997 session = openSession();
2998
2999 Query q = session.createQuery(sql);
3000
3001 QueryPos qPos = QueryPos.getInstance(q);
3002
3003 qPos.add(fileVersionId);
3004
3005 count = (Long)q.uniqueResult();
3006 }
3007 catch (Exception e) {
3008 throw processException(e);
3009 }
3010 finally {
3011 if (count == null) {
3012 count = Long.valueOf(0);
3013 }
3014
3015 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEVERSIONID,
3016 finderArgs, count);
3017
3018 closeSession(session);
3019 }
3020 }
3021
3022 return count.intValue();
3023 }
3024
3025
3033 public int countByD_F(long DDMStructureId, long fileVersionId)
3034 throws SystemException {
3035 Object[] finderArgs = new Object[] { DDMStructureId, fileVersionId };
3036
3037 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_D_F,
3038 finderArgs, this);
3039
3040 if (count == null) {
3041 StringBundler query = new StringBundler(3);
3042
3043 query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
3044
3045 query.append(_FINDER_COLUMN_D_F_DDMSTRUCTUREID_2);
3046
3047 query.append(_FINDER_COLUMN_D_F_FILEVERSIONID_2);
3048
3049 String sql = query.toString();
3050
3051 Session session = null;
3052
3053 try {
3054 session = openSession();
3055
3056 Query q = session.createQuery(sql);
3057
3058 QueryPos qPos = QueryPos.getInstance(q);
3059
3060 qPos.add(DDMStructureId);
3061
3062 qPos.add(fileVersionId);
3063
3064 count = (Long)q.uniqueResult();
3065 }
3066 catch (Exception e) {
3067 throw processException(e);
3068 }
3069 finally {
3070 if (count == null) {
3071 count = Long.valueOf(0);
3072 }
3073
3074 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_D_F, finderArgs,
3075 count);
3076
3077 closeSession(session);
3078 }
3079 }
3080
3081 return count.intValue();
3082 }
3083
3084
3092 public int countByF_V(long fileEntryId, long fileVersionId)
3093 throws SystemException {
3094 Object[] finderArgs = new Object[] { fileEntryId, fileVersionId };
3095
3096 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_V,
3097 finderArgs, this);
3098
3099 if (count == null) {
3100 StringBundler query = new StringBundler(3);
3101
3102 query.append(_SQL_COUNT_DLFILEENTRYMETADATA_WHERE);
3103
3104 query.append(_FINDER_COLUMN_F_V_FILEENTRYID_2);
3105
3106 query.append(_FINDER_COLUMN_F_V_FILEVERSIONID_2);
3107
3108 String sql = query.toString();
3109
3110 Session session = null;
3111
3112 try {
3113 session = openSession();
3114
3115 Query q = session.createQuery(sql);
3116
3117 QueryPos qPos = QueryPos.getInstance(q);
3118
3119 qPos.add(fileEntryId);
3120
3121 qPos.add(fileVersionId);
3122
3123 count = (Long)q.uniqueResult();
3124 }
3125 catch (Exception e) {
3126 throw processException(e);
3127 }
3128 finally {
3129 if (count == null) {
3130 count = Long.valueOf(0);
3131 }
3132
3133 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_V, finderArgs,
3134 count);
3135
3136 closeSession(session);
3137 }
3138 }
3139
3140 return count.intValue();
3141 }
3142
3143
3149 public int countAll() throws SystemException {
3150 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3151 FINDER_ARGS_EMPTY, this);
3152
3153 if (count == null) {
3154 Session session = null;
3155
3156 try {
3157 session = openSession();
3158
3159 Query q = session.createQuery(_SQL_COUNT_DLFILEENTRYMETADATA);
3160
3161 count = (Long)q.uniqueResult();
3162 }
3163 catch (Exception e) {
3164 throw processException(e);
3165 }
3166 finally {
3167 if (count == null) {
3168 count = Long.valueOf(0);
3169 }
3170
3171 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3172 FINDER_ARGS_EMPTY, count);
3173
3174 closeSession(session);
3175 }
3176 }
3177
3178 return count.intValue();
3179 }
3180
3181
3184 public void afterPropertiesSet() {
3185 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3186 com.liferay.portal.util.PropsUtil.get(
3187 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata")));
3188
3189 if (listenerClassNames.length > 0) {
3190 try {
3191 List<ModelListener<DLFileEntryMetadata>> listenersList = new ArrayList<ModelListener<DLFileEntryMetadata>>();
3192
3193 for (String listenerClassName : listenerClassNames) {
3194 Class<?> clazz = getClass();
3195
3196 listenersList.add((ModelListener<DLFileEntryMetadata>)InstanceFactory.newInstance(
3197 clazz.getClassLoader(), listenerClassName));
3198 }
3199
3200 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3201 }
3202 catch (Exception e) {
3203 _log.error(e);
3204 }
3205 }
3206 }
3207
3208 public void destroy() {
3209 EntityCacheUtil.removeCache(DLFileEntryMetadataImpl.class.getName());
3210 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3211 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3212 }
3213
3214 @BeanReference(type = DLContentPersistence.class)
3215 protected DLContentPersistence dlContentPersistence;
3216 @BeanReference(type = DLFileEntryPersistence.class)
3217 protected DLFileEntryPersistence dlFileEntryPersistence;
3218 @BeanReference(type = DLFileEntryMetadataPersistence.class)
3219 protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
3220 @BeanReference(type = DLFileEntryTypePersistence.class)
3221 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
3222 @BeanReference(type = DLFileRankPersistence.class)
3223 protected DLFileRankPersistence dlFileRankPersistence;
3224 @BeanReference(type = DLFileShortcutPersistence.class)
3225 protected DLFileShortcutPersistence dlFileShortcutPersistence;
3226 @BeanReference(type = DLFileVersionPersistence.class)
3227 protected DLFileVersionPersistence dlFileVersionPersistence;
3228 @BeanReference(type = DLFolderPersistence.class)
3229 protected DLFolderPersistence dlFolderPersistence;
3230 @BeanReference(type = DLSyncPersistence.class)
3231 protected DLSyncPersistence dlSyncPersistence;
3232 @BeanReference(type = ResourcePersistence.class)
3233 protected ResourcePersistence resourcePersistence;
3234 @BeanReference(type = UserPersistence.class)
3235 protected UserPersistence userPersistence;
3236 @BeanReference(type = DDMStructureLinkPersistence.class)
3237 protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
3238 private static final String _SQL_SELECT_DLFILEENTRYMETADATA = "SELECT dlFileEntryMetadata FROM DLFileEntryMetadata dlFileEntryMetadata";
3239 private static final String _SQL_SELECT_DLFILEENTRYMETADATA_WHERE = "SELECT dlFileEntryMetadata FROM DLFileEntryMetadata dlFileEntryMetadata WHERE ";
3240 private static final String _SQL_COUNT_DLFILEENTRYMETADATA = "SELECT COUNT(dlFileEntryMetadata) FROM DLFileEntryMetadata dlFileEntryMetadata";
3241 private static final String _SQL_COUNT_DLFILEENTRYMETADATA_WHERE = "SELECT COUNT(dlFileEntryMetadata) FROM DLFileEntryMetadata dlFileEntryMetadata WHERE ";
3242 private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntryMetadata.uuid IS NULL";
3243 private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntryMetadata.uuid = ?";
3244 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntryMetadata.uuid IS NULL OR dlFileEntryMetadata.uuid = ?)";
3245 private static final String _FINDER_COLUMN_FILEENTRYTYPEID_FILEENTRYTYPEID_2 =
3246 "dlFileEntryMetadata.fileEntryTypeId = ?";
3247 private static final String _FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2 = "dlFileEntryMetadata.fileEntryId = ?";
3248 private static final String _FINDER_COLUMN_FILEVERSIONID_FILEVERSIONID_2 = "dlFileEntryMetadata.fileVersionId = ?";
3249 private static final String _FINDER_COLUMN_D_F_DDMSTRUCTUREID_2 = "dlFileEntryMetadata.DDMStructureId = ? AND ";
3250 private static final String _FINDER_COLUMN_D_F_FILEVERSIONID_2 = "dlFileEntryMetadata.fileVersionId = ?";
3251 private static final String _FINDER_COLUMN_F_V_FILEENTRYID_2 = "dlFileEntryMetadata.fileEntryId = ? AND ";
3252 private static final String _FINDER_COLUMN_F_V_FILEVERSIONID_2 = "dlFileEntryMetadata.fileVersionId = ?";
3253 private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntryMetadata.";
3254 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntryMetadata exists with the primary key ";
3255 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntryMetadata exists with the key {";
3256 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3257 private static Log _log = LogFactoryUtil.getLog(DLFileEntryMetadataPersistenceImpl.class);
3258 private static DLFileEntryMetadata _nullDLFileEntryMetadata = new DLFileEntryMetadataImpl() {
3259 @Override
3260 public Object clone() {
3261 return this;
3262 }
3263
3264 @Override
3265 public CacheModel<DLFileEntryMetadata> toCacheModel() {
3266 return _nullDLFileEntryMetadataCacheModel;
3267 }
3268 };
3269
3270 private static CacheModel<DLFileEntryMetadata> _nullDLFileEntryMetadataCacheModel =
3271 new CacheModel<DLFileEntryMetadata>() {
3272 public DLFileEntryMetadata toEntityModel() {
3273 return _nullDLFileEntryMetadata;
3274 }
3275 };
3276 }