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.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.service.persistence.UserPersistence;
040 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041
042 import com.liferay.portlet.documentlibrary.NoSuchContentException;
043 import com.liferay.portlet.documentlibrary.model.DLContent;
044 import com.liferay.portlet.documentlibrary.model.impl.DLContentImpl;
045 import com.liferay.portlet.documentlibrary.model.impl.DLContentModelImpl;
046
047 import java.io.Serializable;
048
049 import java.util.ArrayList;
050 import java.util.Collections;
051 import java.util.List;
052
053
065 public class DLContentPersistenceImpl extends BasePersistenceImpl<DLContent>
066 implements DLContentPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = DLContentImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_R = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
078 DLContentModelImpl.FINDER_CACHE_ENABLED, DLContentImpl.class,
079 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_R",
080 new String[] {
081 Long.class.getName(), Long.class.getName(),
082
083 "java.lang.Integer", "java.lang.Integer",
084 "com.liferay.portal.kernel.util.OrderByComparator"
085 });
086 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
087 DLContentModelImpl.FINDER_CACHE_ENABLED, DLContentImpl.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_R",
089 new String[] { Long.class.getName(), Long.class.getName() },
090 DLContentModelImpl.COMPANYID_COLUMN_BITMASK |
091 DLContentModelImpl.REPOSITORYID_COLUMN_BITMASK);
092 public static final FinderPath FINDER_PATH_COUNT_BY_C_R = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
093 DLContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_R",
095 new String[] { Long.class.getName(), Long.class.getName() });
096 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_R_P = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
097 DLContentModelImpl.FINDER_CACHE_ENABLED, DLContentImpl.class,
098 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_R_P",
099 new String[] {
100 Long.class.getName(), Long.class.getName(),
101 String.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R_P = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
107 DLContentModelImpl.FINDER_CACHE_ENABLED, DLContentImpl.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_R_P",
109 new String[] {
110 Long.class.getName(), Long.class.getName(),
111 String.class.getName()
112 },
113 DLContentModelImpl.COMPANYID_COLUMN_BITMASK |
114 DLContentModelImpl.REPOSITORYID_COLUMN_BITMASK |
115 DLContentModelImpl.PATH_COLUMN_BITMASK);
116 public static final FinderPath FINDER_PATH_COUNT_BY_C_R_P = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
117 DLContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
118 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_R_P",
119 new String[] {
120 Long.class.getName(), Long.class.getName(),
121 String.class.getName()
122 });
123 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_R_LIKEP =
124 new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
125 DLContentModelImpl.FINDER_CACHE_ENABLED, DLContentImpl.class,
126 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_R_LikeP",
127 new String[] {
128 Long.class.getName(), Long.class.getName(),
129 String.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_WITH_PAGINATION_COUNT_BY_C_R_LIKEP =
135 new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
136 DLContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_R_LikeP",
138 new String[] {
139 Long.class.getName(), Long.class.getName(),
140 String.class.getName()
141 });
142 public static final FinderPath FINDER_PATH_FETCH_BY_C_R_P_V = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
143 DLContentModelImpl.FINDER_CACHE_ENABLED, DLContentImpl.class,
144 FINDER_CLASS_NAME_ENTITY, "fetchByC_R_P_V",
145 new String[] {
146 Long.class.getName(), Long.class.getName(),
147 String.class.getName(), String.class.getName()
148 },
149 DLContentModelImpl.COMPANYID_COLUMN_BITMASK |
150 DLContentModelImpl.REPOSITORYID_COLUMN_BITMASK |
151 DLContentModelImpl.PATH_COLUMN_BITMASK |
152 DLContentModelImpl.VERSION_COLUMN_BITMASK);
153 public static final FinderPath FINDER_PATH_COUNT_BY_C_R_P_V = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
154 DLContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
155 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_R_P_V",
156 new String[] {
157 Long.class.getName(), Long.class.getName(),
158 String.class.getName(), String.class.getName()
159 });
160 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
161 DLContentModelImpl.FINDER_CACHE_ENABLED, DLContentImpl.class,
162 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
163 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
164 DLContentModelImpl.FINDER_CACHE_ENABLED, DLContentImpl.class,
165 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
166 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLContentModelImpl.ENTITY_CACHE_ENABLED,
167 DLContentModelImpl.FINDER_CACHE_ENABLED, Long.class,
168 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
169
170
175 public void cacheResult(DLContent dlContent) {
176 EntityCacheUtil.putResult(DLContentModelImpl.ENTITY_CACHE_ENABLED,
177 DLContentImpl.class, dlContent.getPrimaryKey(), dlContent);
178
179 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R_P_V,
180 new Object[] {
181 Long.valueOf(dlContent.getCompanyId()),
182 Long.valueOf(dlContent.getRepositoryId()),
183
184 dlContent.getPath(),
185
186 dlContent.getVersion()
187 }, dlContent);
188
189 dlContent.resetOriginalValues();
190 }
191
192
197 public void cacheResult(List<DLContent> dlContents) {
198 for (DLContent dlContent : dlContents) {
199 if (EntityCacheUtil.getResult(
200 DLContentModelImpl.ENTITY_CACHE_ENABLED,
201 DLContentImpl.class, dlContent.getPrimaryKey()) == null) {
202 cacheResult(dlContent);
203 }
204 else {
205 dlContent.resetOriginalValues();
206 }
207 }
208 }
209
210
217 @Override
218 public void clearCache() {
219 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
220 CacheRegistryUtil.clear(DLContentImpl.class.getName());
221 }
222
223 EntityCacheUtil.clearCache(DLContentImpl.class.getName());
224
225 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
226 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
227 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
228 }
229
230
237 @Override
238 public void clearCache(DLContent dlContent) {
239 EntityCacheUtil.removeResult(DLContentModelImpl.ENTITY_CACHE_ENABLED,
240 DLContentImpl.class, dlContent.getPrimaryKey());
241
242 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
243 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
244
245 clearUniqueFindersCache(dlContent);
246 }
247
248 @Override
249 public void clearCache(List<DLContent> dlContents) {
250 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
251 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
252
253 for (DLContent dlContent : dlContents) {
254 EntityCacheUtil.removeResult(DLContentModelImpl.ENTITY_CACHE_ENABLED,
255 DLContentImpl.class, dlContent.getPrimaryKey());
256
257 clearUniqueFindersCache(dlContent);
258 }
259 }
260
261 protected void clearUniqueFindersCache(DLContent dlContent) {
262 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_R_P_V,
263 new Object[] {
264 Long.valueOf(dlContent.getCompanyId()),
265 Long.valueOf(dlContent.getRepositoryId()),
266
267 dlContent.getPath(),
268
269 dlContent.getVersion()
270 });
271 }
272
273
279 public DLContent create(long contentId) {
280 DLContent dlContent = new DLContentImpl();
281
282 dlContent.setNew(true);
283 dlContent.setPrimaryKey(contentId);
284
285 return dlContent;
286 }
287
288
296 public DLContent remove(long contentId)
297 throws NoSuchContentException, SystemException {
298 return remove(Long.valueOf(contentId));
299 }
300
301
309 @Override
310 public DLContent remove(Serializable primaryKey)
311 throws NoSuchContentException, SystemException {
312 Session session = null;
313
314 try {
315 session = openSession();
316
317 DLContent dlContent = (DLContent)session.get(DLContentImpl.class,
318 primaryKey);
319
320 if (dlContent == null) {
321 if (_log.isWarnEnabled()) {
322 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
323 }
324
325 throw new NoSuchContentException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
326 primaryKey);
327 }
328
329 return remove(dlContent);
330 }
331 catch (NoSuchContentException nsee) {
332 throw nsee;
333 }
334 catch (Exception e) {
335 throw processException(e);
336 }
337 finally {
338 closeSession(session);
339 }
340 }
341
342 @Override
343 protected DLContent removeImpl(DLContent dlContent)
344 throws SystemException {
345 dlContent = toUnwrappedModel(dlContent);
346
347 Session session = null;
348
349 try {
350 session = openSession();
351
352 if (dlContent.isCachedModel()) {
353 dlContent = (DLContent)session.get(DLContentImpl.class,
354 dlContent.getPrimaryKeyObj());
355 }
356
357 session.delete(dlContent);
358 }
359 catch (Exception e) {
360 throw processException(e);
361 }
362 finally {
363 closeSession(session);
364 }
365
366 clearCache(dlContent);
367
368 return dlContent;
369 }
370
371 @Override
372 public DLContent updateImpl(
373 com.liferay.portlet.documentlibrary.model.DLContent dlContent)
374 throws SystemException {
375 dlContent = toUnwrappedModel(dlContent);
376
377 boolean isNew = dlContent.isNew();
378
379 DLContentModelImpl dlContentModelImpl = (DLContentModelImpl)dlContent;
380
381 Session session = null;
382
383 try {
384 session = openSession();
385
386 if (dlContent.isNew()) {
387 session.save(dlContent);
388
389 dlContent.setNew(false);
390 }
391 else {
392 session.merge(dlContent);
393 }
394
395 session.flush();
396 session.clear();
397 }
398 catch (Exception e) {
399 throw processException(e);
400 }
401 finally {
402 closeSession(session);
403 }
404
405 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
406
407 if (isNew || !DLContentModelImpl.COLUMN_BITMASK_ENABLED) {
408 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
409 }
410
411 else {
412 if ((dlContentModelImpl.getColumnBitmask() &
413 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R.getColumnBitmask()) != 0) {
414 Object[] args = new Object[] {
415 Long.valueOf(dlContentModelImpl.getOriginalCompanyId()),
416 Long.valueOf(dlContentModelImpl.getOriginalRepositoryId())
417 };
418
419 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_R, args);
420 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R,
421 args);
422
423 args = new Object[] {
424 Long.valueOf(dlContentModelImpl.getCompanyId()),
425 Long.valueOf(dlContentModelImpl.getRepositoryId())
426 };
427
428 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_R, args);
429 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R,
430 args);
431 }
432
433 if ((dlContentModelImpl.getColumnBitmask() &
434 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R_P.getColumnBitmask()) != 0) {
435 Object[] args = new Object[] {
436 Long.valueOf(dlContentModelImpl.getOriginalCompanyId()),
437 Long.valueOf(dlContentModelImpl.getOriginalRepositoryId()),
438
439 dlContentModelImpl.getOriginalPath()
440 };
441
442 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_R_P, args);
443 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R_P,
444 args);
445
446 args = new Object[] {
447 Long.valueOf(dlContentModelImpl.getCompanyId()),
448 Long.valueOf(dlContentModelImpl.getRepositoryId()),
449
450 dlContentModelImpl.getPath()
451 };
452
453 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_R_P, args);
454 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R_P,
455 args);
456 }
457 }
458
459 EntityCacheUtil.putResult(DLContentModelImpl.ENTITY_CACHE_ENABLED,
460 DLContentImpl.class, dlContent.getPrimaryKey(), dlContent);
461
462 if (isNew) {
463 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R_P_V,
464 new Object[] {
465 Long.valueOf(dlContent.getCompanyId()),
466 Long.valueOf(dlContent.getRepositoryId()),
467
468 dlContent.getPath(),
469
470 dlContent.getVersion()
471 }, dlContent);
472 }
473 else {
474 if ((dlContentModelImpl.getColumnBitmask() &
475 FINDER_PATH_FETCH_BY_C_R_P_V.getColumnBitmask()) != 0) {
476 Object[] args = new Object[] {
477 Long.valueOf(dlContentModelImpl.getOriginalCompanyId()),
478 Long.valueOf(dlContentModelImpl.getOriginalRepositoryId()),
479
480 dlContentModelImpl.getOriginalPath(),
481
482 dlContentModelImpl.getOriginalVersion()
483 };
484
485 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_R_P_V, args);
486
487 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_R_P_V, args);
488
489 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R_P_V,
490 new Object[] {
491 Long.valueOf(dlContent.getCompanyId()),
492 Long.valueOf(dlContent.getRepositoryId()),
493
494 dlContent.getPath(),
495
496 dlContent.getVersion()
497 }, dlContent);
498 }
499 }
500
501 dlContent.resetOriginalValues();
502
503 return dlContent;
504 }
505
506 protected DLContent toUnwrappedModel(DLContent dlContent) {
507 if (dlContent instanceof DLContentImpl) {
508 return dlContent;
509 }
510
511 DLContentImpl dlContentImpl = new DLContentImpl();
512
513 dlContentImpl.setNew(dlContent.isNew());
514 dlContentImpl.setPrimaryKey(dlContent.getPrimaryKey());
515
516 dlContentImpl.setContentId(dlContent.getContentId());
517 dlContentImpl.setGroupId(dlContent.getGroupId());
518 dlContentImpl.setCompanyId(dlContent.getCompanyId());
519 dlContentImpl.setRepositoryId(dlContent.getRepositoryId());
520 dlContentImpl.setPath(dlContent.getPath());
521 dlContentImpl.setVersion(dlContent.getVersion());
522 dlContentImpl.setData(dlContent.getData());
523 dlContentImpl.setSize(dlContent.getSize());
524
525 return dlContentImpl;
526 }
527
528
536 @Override
537 public DLContent findByPrimaryKey(Serializable primaryKey)
538 throws NoSuchModelException, SystemException {
539 return findByPrimaryKey(((Long)primaryKey).longValue());
540 }
541
542
550 public DLContent findByPrimaryKey(long contentId)
551 throws NoSuchContentException, SystemException {
552 DLContent dlContent = fetchByPrimaryKey(contentId);
553
554 if (dlContent == null) {
555 if (_log.isWarnEnabled()) {
556 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentId);
557 }
558
559 throw new NoSuchContentException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
560 contentId);
561 }
562
563 return dlContent;
564 }
565
566
573 @Override
574 public DLContent fetchByPrimaryKey(Serializable primaryKey)
575 throws SystemException {
576 return fetchByPrimaryKey(((Long)primaryKey).longValue());
577 }
578
579
586 public DLContent fetchByPrimaryKey(long contentId)
587 throws SystemException {
588 DLContent dlContent = (DLContent)EntityCacheUtil.getResult(DLContentModelImpl.ENTITY_CACHE_ENABLED,
589 DLContentImpl.class, contentId);
590
591 if (dlContent == _nullDLContent) {
592 return null;
593 }
594
595 if (dlContent == null) {
596 Session session = null;
597
598 boolean hasException = false;
599
600 try {
601 session = openSession();
602
603 dlContent = (DLContent)session.get(DLContentImpl.class,
604 Long.valueOf(contentId));
605 }
606 catch (Exception e) {
607 hasException = true;
608
609 throw processException(e);
610 }
611 finally {
612 if (dlContent != null) {
613 cacheResult(dlContent);
614 }
615 else if (!hasException) {
616 EntityCacheUtil.putResult(DLContentModelImpl.ENTITY_CACHE_ENABLED,
617 DLContentImpl.class, contentId, _nullDLContent);
618 }
619
620 closeSession(session);
621 }
622 }
623
624 return dlContent;
625 }
626
627
635 public List<DLContent> findByC_R(long companyId, long repositoryId)
636 throws SystemException {
637 return findByC_R(companyId, repositoryId, QueryUtil.ALL_POS,
638 QueryUtil.ALL_POS, null);
639 }
640
641
655 public List<DLContent> findByC_R(long companyId, long repositoryId,
656 int start, int end) throws SystemException {
657 return findByC_R(companyId, repositoryId, start, end, null);
658 }
659
660
675 public List<DLContent> findByC_R(long companyId, long repositoryId,
676 int start, int end, OrderByComparator orderByComparator)
677 throws SystemException {
678 FinderPath finderPath = null;
679 Object[] finderArgs = null;
680
681 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
682 (orderByComparator == null)) {
683 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R;
684 finderArgs = new Object[] { companyId, repositoryId };
685 }
686 else {
687 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_R;
688 finderArgs = new Object[] {
689 companyId, repositoryId,
690
691 start, end, orderByComparator
692 };
693 }
694
695 List<DLContent> list = (List<DLContent>)FinderCacheUtil.getResult(finderPath,
696 finderArgs, this);
697
698 if ((list != null) && !list.isEmpty()) {
699 for (DLContent dlContent : list) {
700 if ((companyId != dlContent.getCompanyId()) ||
701 (repositoryId != dlContent.getRepositoryId())) {
702 list = null;
703
704 break;
705 }
706 }
707 }
708
709 if (list == null) {
710 StringBundler query = null;
711
712 if (orderByComparator != null) {
713 query = new StringBundler(4 +
714 (orderByComparator.getOrderByFields().length * 3));
715 }
716 else {
717 query = new StringBundler(4);
718 }
719
720 query.append(_SQL_SELECT_DLCONTENT_WHERE);
721
722 query.append(_FINDER_COLUMN_C_R_COMPANYID_2);
723
724 query.append(_FINDER_COLUMN_C_R_REPOSITORYID_2);
725
726 if (orderByComparator != null) {
727 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
728 orderByComparator);
729 }
730
731 else {
732 query.append(DLContentModelImpl.ORDER_BY_JPQL);
733 }
734
735 String sql = query.toString();
736
737 Session session = null;
738
739 try {
740 session = openSession();
741
742 Query q = session.createQuery(sql);
743
744 QueryPos qPos = QueryPos.getInstance(q);
745
746 qPos.add(companyId);
747
748 qPos.add(repositoryId);
749
750 list = (List<DLContent>)QueryUtil.list(q, getDialect(), start,
751 end);
752 }
753 catch (Exception e) {
754 throw processException(e);
755 }
756 finally {
757 if (list == null) {
758 FinderCacheUtil.removeResult(finderPath, finderArgs);
759 }
760 else {
761 cacheResult(list);
762
763 FinderCacheUtil.putResult(finderPath, finderArgs, list);
764 }
765
766 closeSession(session);
767 }
768 }
769
770 return list;
771 }
772
773
783 public DLContent findByC_R_First(long companyId, long repositoryId,
784 OrderByComparator orderByComparator)
785 throws NoSuchContentException, SystemException {
786 DLContent dlContent = fetchByC_R_First(companyId, repositoryId,
787 orderByComparator);
788
789 if (dlContent != null) {
790 return dlContent;
791 }
792
793 StringBundler msg = new StringBundler(6);
794
795 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
796
797 msg.append("companyId=");
798 msg.append(companyId);
799
800 msg.append(", repositoryId=");
801 msg.append(repositoryId);
802
803 msg.append(StringPool.CLOSE_CURLY_BRACE);
804
805 throw new NoSuchContentException(msg.toString());
806 }
807
808
817 public DLContent fetchByC_R_First(long companyId, long repositoryId,
818 OrderByComparator orderByComparator) throws SystemException {
819 List<DLContent> list = findByC_R(companyId, repositoryId, 0, 1,
820 orderByComparator);
821
822 if (!list.isEmpty()) {
823 return list.get(0);
824 }
825
826 return null;
827 }
828
829
839 public DLContent findByC_R_Last(long companyId, long repositoryId,
840 OrderByComparator orderByComparator)
841 throws NoSuchContentException, SystemException {
842 DLContent dlContent = fetchByC_R_Last(companyId, repositoryId,
843 orderByComparator);
844
845 if (dlContent != null) {
846 return dlContent;
847 }
848
849 StringBundler msg = new StringBundler(6);
850
851 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
852
853 msg.append("companyId=");
854 msg.append(companyId);
855
856 msg.append(", repositoryId=");
857 msg.append(repositoryId);
858
859 msg.append(StringPool.CLOSE_CURLY_BRACE);
860
861 throw new NoSuchContentException(msg.toString());
862 }
863
864
873 public DLContent fetchByC_R_Last(long companyId, long repositoryId,
874 OrderByComparator orderByComparator) throws SystemException {
875 int count = countByC_R(companyId, repositoryId);
876
877 List<DLContent> list = findByC_R(companyId, repositoryId, count - 1,
878 count, orderByComparator);
879
880 if (!list.isEmpty()) {
881 return list.get(0);
882 }
883
884 return null;
885 }
886
887
898 public DLContent[] findByC_R_PrevAndNext(long contentId, long companyId,
899 long repositoryId, OrderByComparator orderByComparator)
900 throws NoSuchContentException, SystemException {
901 DLContent dlContent = findByPrimaryKey(contentId);
902
903 Session session = null;
904
905 try {
906 session = openSession();
907
908 DLContent[] array = new DLContentImpl[3];
909
910 array[0] = getByC_R_PrevAndNext(session, dlContent, companyId,
911 repositoryId, orderByComparator, true);
912
913 array[1] = dlContent;
914
915 array[2] = getByC_R_PrevAndNext(session, dlContent, companyId,
916 repositoryId, orderByComparator, false);
917
918 return array;
919 }
920 catch (Exception e) {
921 throw processException(e);
922 }
923 finally {
924 closeSession(session);
925 }
926 }
927
928 protected DLContent getByC_R_PrevAndNext(Session session,
929 DLContent dlContent, long companyId, long repositoryId,
930 OrderByComparator orderByComparator, boolean previous) {
931 StringBundler query = null;
932
933 if (orderByComparator != null) {
934 query = new StringBundler(6 +
935 (orderByComparator.getOrderByFields().length * 6));
936 }
937 else {
938 query = new StringBundler(3);
939 }
940
941 query.append(_SQL_SELECT_DLCONTENT_WHERE);
942
943 query.append(_FINDER_COLUMN_C_R_COMPANYID_2);
944
945 query.append(_FINDER_COLUMN_C_R_REPOSITORYID_2);
946
947 if (orderByComparator != null) {
948 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
949
950 if (orderByConditionFields.length > 0) {
951 query.append(WHERE_AND);
952 }
953
954 for (int i = 0; i < orderByConditionFields.length; i++) {
955 query.append(_ORDER_BY_ENTITY_ALIAS);
956 query.append(orderByConditionFields[i]);
957
958 if ((i + 1) < orderByConditionFields.length) {
959 if (orderByComparator.isAscending() ^ previous) {
960 query.append(WHERE_GREATER_THAN_HAS_NEXT);
961 }
962 else {
963 query.append(WHERE_LESSER_THAN_HAS_NEXT);
964 }
965 }
966 else {
967 if (orderByComparator.isAscending() ^ previous) {
968 query.append(WHERE_GREATER_THAN);
969 }
970 else {
971 query.append(WHERE_LESSER_THAN);
972 }
973 }
974 }
975
976 query.append(ORDER_BY_CLAUSE);
977
978 String[] orderByFields = orderByComparator.getOrderByFields();
979
980 for (int i = 0; i < orderByFields.length; i++) {
981 query.append(_ORDER_BY_ENTITY_ALIAS);
982 query.append(orderByFields[i]);
983
984 if ((i + 1) < orderByFields.length) {
985 if (orderByComparator.isAscending() ^ previous) {
986 query.append(ORDER_BY_ASC_HAS_NEXT);
987 }
988 else {
989 query.append(ORDER_BY_DESC_HAS_NEXT);
990 }
991 }
992 else {
993 if (orderByComparator.isAscending() ^ previous) {
994 query.append(ORDER_BY_ASC);
995 }
996 else {
997 query.append(ORDER_BY_DESC);
998 }
999 }
1000 }
1001 }
1002
1003 else {
1004 query.append(DLContentModelImpl.ORDER_BY_JPQL);
1005 }
1006
1007 String sql = query.toString();
1008
1009 Query q = session.createQuery(sql);
1010
1011 q.setFirstResult(0);
1012 q.setMaxResults(2);
1013
1014 QueryPos qPos = QueryPos.getInstance(q);
1015
1016 qPos.add(companyId);
1017
1018 qPos.add(repositoryId);
1019
1020 if (orderByComparator != null) {
1021 Object[] values = orderByComparator.getOrderByConditionValues(dlContent);
1022
1023 for (Object value : values) {
1024 qPos.add(value);
1025 }
1026 }
1027
1028 List<DLContent> list = q.list();
1029
1030 if (list.size() == 2) {
1031 return list.get(1);
1032 }
1033 else {
1034 return null;
1035 }
1036 }
1037
1038
1047 public List<DLContent> findByC_R_P(long companyId, long repositoryId,
1048 String path) throws SystemException {
1049 return findByC_R_P(companyId, repositoryId, path, QueryUtil.ALL_POS,
1050 QueryUtil.ALL_POS, null);
1051 }
1052
1053
1068 public List<DLContent> findByC_R_P(long companyId, long repositoryId,
1069 String path, int start, int end) throws SystemException {
1070 return findByC_R_P(companyId, repositoryId, path, start, end, null);
1071 }
1072
1073
1089 public List<DLContent> findByC_R_P(long companyId, long repositoryId,
1090 String path, int start, int end, OrderByComparator orderByComparator)
1091 throws SystemException {
1092 FinderPath finderPath = null;
1093 Object[] finderArgs = null;
1094
1095 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1096 (orderByComparator == null)) {
1097 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_R_P;
1098 finderArgs = new Object[] { companyId, repositoryId, path };
1099 }
1100 else {
1101 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_R_P;
1102 finderArgs = new Object[] {
1103 companyId, repositoryId, path,
1104
1105 start, end, orderByComparator
1106 };
1107 }
1108
1109 List<DLContent> list = (List<DLContent>)FinderCacheUtil.getResult(finderPath,
1110 finderArgs, this);
1111
1112 if ((list != null) && !list.isEmpty()) {
1113 for (DLContent dlContent : list) {
1114 if ((companyId != dlContent.getCompanyId()) ||
1115 (repositoryId != dlContent.getRepositoryId()) ||
1116 !Validator.equals(path, dlContent.getPath())) {
1117 list = null;
1118
1119 break;
1120 }
1121 }
1122 }
1123
1124 if (list == null) {
1125 StringBundler query = null;
1126
1127 if (orderByComparator != null) {
1128 query = new StringBundler(5 +
1129 (orderByComparator.getOrderByFields().length * 3));
1130 }
1131 else {
1132 query = new StringBundler(5);
1133 }
1134
1135 query.append(_SQL_SELECT_DLCONTENT_WHERE);
1136
1137 query.append(_FINDER_COLUMN_C_R_P_COMPANYID_2);
1138
1139 query.append(_FINDER_COLUMN_C_R_P_REPOSITORYID_2);
1140
1141 if (path == null) {
1142 query.append(_FINDER_COLUMN_C_R_P_PATH_1);
1143 }
1144 else {
1145 if (path.equals(StringPool.BLANK)) {
1146 query.append(_FINDER_COLUMN_C_R_P_PATH_3);
1147 }
1148 else {
1149 query.append(_FINDER_COLUMN_C_R_P_PATH_2);
1150 }
1151 }
1152
1153 if (orderByComparator != null) {
1154 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1155 orderByComparator);
1156 }
1157
1158 else {
1159 query.append(DLContentModelImpl.ORDER_BY_JPQL);
1160 }
1161
1162 String sql = query.toString();
1163
1164 Session session = null;
1165
1166 try {
1167 session = openSession();
1168
1169 Query q = session.createQuery(sql);
1170
1171 QueryPos qPos = QueryPos.getInstance(q);
1172
1173 qPos.add(companyId);
1174
1175 qPos.add(repositoryId);
1176
1177 if (path != null) {
1178 qPos.add(path);
1179 }
1180
1181 list = (List<DLContent>)QueryUtil.list(q, getDialect(), start,
1182 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
1215 public DLContent findByC_R_P_First(long companyId, long repositoryId,
1216 String path, OrderByComparator orderByComparator)
1217 throws NoSuchContentException, SystemException {
1218 DLContent dlContent = fetchByC_R_P_First(companyId, repositoryId, path,
1219 orderByComparator);
1220
1221 if (dlContent != null) {
1222 return dlContent;
1223 }
1224
1225 StringBundler msg = new StringBundler(8);
1226
1227 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1228
1229 msg.append("companyId=");
1230 msg.append(companyId);
1231
1232 msg.append(", repositoryId=");
1233 msg.append(repositoryId);
1234
1235 msg.append(", path=");
1236 msg.append(path);
1237
1238 msg.append(StringPool.CLOSE_CURLY_BRACE);
1239
1240 throw new NoSuchContentException(msg.toString());
1241 }
1242
1243
1253 public DLContent fetchByC_R_P_First(long companyId, long repositoryId,
1254 String path, OrderByComparator orderByComparator)
1255 throws SystemException {
1256 List<DLContent> list = findByC_R_P(companyId, repositoryId, path, 0, 1,
1257 orderByComparator);
1258
1259 if (!list.isEmpty()) {
1260 return list.get(0);
1261 }
1262
1263 return null;
1264 }
1265
1266
1277 public DLContent findByC_R_P_Last(long companyId, long repositoryId,
1278 String path, OrderByComparator orderByComparator)
1279 throws NoSuchContentException, SystemException {
1280 DLContent dlContent = fetchByC_R_P_Last(companyId, repositoryId, path,
1281 orderByComparator);
1282
1283 if (dlContent != null) {
1284 return dlContent;
1285 }
1286
1287 StringBundler msg = new StringBundler(8);
1288
1289 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1290
1291 msg.append("companyId=");
1292 msg.append(companyId);
1293
1294 msg.append(", repositoryId=");
1295 msg.append(repositoryId);
1296
1297 msg.append(", path=");
1298 msg.append(path);
1299
1300 msg.append(StringPool.CLOSE_CURLY_BRACE);
1301
1302 throw new NoSuchContentException(msg.toString());
1303 }
1304
1305
1315 public DLContent fetchByC_R_P_Last(long companyId, long repositoryId,
1316 String path, OrderByComparator orderByComparator)
1317 throws SystemException {
1318 int count = countByC_R_P(companyId, repositoryId, path);
1319
1320 List<DLContent> list = findByC_R_P(companyId, repositoryId, path,
1321 count - 1, count, orderByComparator);
1322
1323 if (!list.isEmpty()) {
1324 return list.get(0);
1325 }
1326
1327 return null;
1328 }
1329
1330
1342 public DLContent[] findByC_R_P_PrevAndNext(long contentId, long companyId,
1343 long repositoryId, String path, OrderByComparator orderByComparator)
1344 throws NoSuchContentException, SystemException {
1345 DLContent dlContent = findByPrimaryKey(contentId);
1346
1347 Session session = null;
1348
1349 try {
1350 session = openSession();
1351
1352 DLContent[] array = new DLContentImpl[3];
1353
1354 array[0] = getByC_R_P_PrevAndNext(session, dlContent, companyId,
1355 repositoryId, path, orderByComparator, true);
1356
1357 array[1] = dlContent;
1358
1359 array[2] = getByC_R_P_PrevAndNext(session, dlContent, companyId,
1360 repositoryId, path, orderByComparator, false);
1361
1362 return array;
1363 }
1364 catch (Exception e) {
1365 throw processException(e);
1366 }
1367 finally {
1368 closeSession(session);
1369 }
1370 }
1371
1372 protected DLContent getByC_R_P_PrevAndNext(Session session,
1373 DLContent dlContent, long companyId, long repositoryId, String path,
1374 OrderByComparator orderByComparator, boolean previous) {
1375 StringBundler query = null;
1376
1377 if (orderByComparator != null) {
1378 query = new StringBundler(6 +
1379 (orderByComparator.getOrderByFields().length * 6));
1380 }
1381 else {
1382 query = new StringBundler(3);
1383 }
1384
1385 query.append(_SQL_SELECT_DLCONTENT_WHERE);
1386
1387 query.append(_FINDER_COLUMN_C_R_P_COMPANYID_2);
1388
1389 query.append(_FINDER_COLUMN_C_R_P_REPOSITORYID_2);
1390
1391 if (path == null) {
1392 query.append(_FINDER_COLUMN_C_R_P_PATH_1);
1393 }
1394 else {
1395 if (path.equals(StringPool.BLANK)) {
1396 query.append(_FINDER_COLUMN_C_R_P_PATH_3);
1397 }
1398 else {
1399 query.append(_FINDER_COLUMN_C_R_P_PATH_2);
1400 }
1401 }
1402
1403 if (orderByComparator != null) {
1404 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1405
1406 if (orderByConditionFields.length > 0) {
1407 query.append(WHERE_AND);
1408 }
1409
1410 for (int i = 0; i < orderByConditionFields.length; i++) {
1411 query.append(_ORDER_BY_ENTITY_ALIAS);
1412 query.append(orderByConditionFields[i]);
1413
1414 if ((i + 1) < orderByConditionFields.length) {
1415 if (orderByComparator.isAscending() ^ previous) {
1416 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1417 }
1418 else {
1419 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1420 }
1421 }
1422 else {
1423 if (orderByComparator.isAscending() ^ previous) {
1424 query.append(WHERE_GREATER_THAN);
1425 }
1426 else {
1427 query.append(WHERE_LESSER_THAN);
1428 }
1429 }
1430 }
1431
1432 query.append(ORDER_BY_CLAUSE);
1433
1434 String[] orderByFields = orderByComparator.getOrderByFields();
1435
1436 for (int i = 0; i < orderByFields.length; i++) {
1437 query.append(_ORDER_BY_ENTITY_ALIAS);
1438 query.append(orderByFields[i]);
1439
1440 if ((i + 1) < orderByFields.length) {
1441 if (orderByComparator.isAscending() ^ previous) {
1442 query.append(ORDER_BY_ASC_HAS_NEXT);
1443 }
1444 else {
1445 query.append(ORDER_BY_DESC_HAS_NEXT);
1446 }
1447 }
1448 else {
1449 if (orderByComparator.isAscending() ^ previous) {
1450 query.append(ORDER_BY_ASC);
1451 }
1452 else {
1453 query.append(ORDER_BY_DESC);
1454 }
1455 }
1456 }
1457 }
1458
1459 else {
1460 query.append(DLContentModelImpl.ORDER_BY_JPQL);
1461 }
1462
1463 String sql = query.toString();
1464
1465 Query q = session.createQuery(sql);
1466
1467 q.setFirstResult(0);
1468 q.setMaxResults(2);
1469
1470 QueryPos qPos = QueryPos.getInstance(q);
1471
1472 qPos.add(companyId);
1473
1474 qPos.add(repositoryId);
1475
1476 if (path != null) {
1477 qPos.add(path);
1478 }
1479
1480 if (orderByComparator != null) {
1481 Object[] values = orderByComparator.getOrderByConditionValues(dlContent);
1482
1483 for (Object value : values) {
1484 qPos.add(value);
1485 }
1486 }
1487
1488 List<DLContent> list = q.list();
1489
1490 if (list.size() == 2) {
1491 return list.get(1);
1492 }
1493 else {
1494 return null;
1495 }
1496 }
1497
1498
1507 public List<DLContent> findByC_R_LikeP(long companyId, long repositoryId,
1508 String path) throws SystemException {
1509 return findByC_R_LikeP(companyId, repositoryId, path,
1510 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1511 }
1512
1513
1528 public List<DLContent> findByC_R_LikeP(long companyId, long repositoryId,
1529 String path, int start, int end) throws SystemException {
1530 return findByC_R_LikeP(companyId, repositoryId, path, start, end, null);
1531 }
1532
1533
1549 public List<DLContent> findByC_R_LikeP(long companyId, long repositoryId,
1550 String path, int start, int end, OrderByComparator orderByComparator)
1551 throws SystemException {
1552 FinderPath finderPath = null;
1553 Object[] finderArgs = null;
1554
1555 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_R_LIKEP;
1556 finderArgs = new Object[] {
1557 companyId, repositoryId, path,
1558
1559 start, end, orderByComparator
1560 };
1561
1562 List<DLContent> list = (List<DLContent>)FinderCacheUtil.getResult(finderPath,
1563 finderArgs, this);
1564
1565 if ((list != null) && !list.isEmpty()) {
1566 for (DLContent dlContent : list) {
1567 if ((companyId != dlContent.getCompanyId()) ||
1568 (repositoryId != dlContent.getRepositoryId()) ||
1569 !Validator.equals(path, dlContent.getPath())) {
1570 list = null;
1571
1572 break;
1573 }
1574 }
1575 }
1576
1577 if (list == null) {
1578 StringBundler query = null;
1579
1580 if (orderByComparator != null) {
1581 query = new StringBundler(5 +
1582 (orderByComparator.getOrderByFields().length * 3));
1583 }
1584 else {
1585 query = new StringBundler(5);
1586 }
1587
1588 query.append(_SQL_SELECT_DLCONTENT_WHERE);
1589
1590 query.append(_FINDER_COLUMN_C_R_LIKEP_COMPANYID_2);
1591
1592 query.append(_FINDER_COLUMN_C_R_LIKEP_REPOSITORYID_2);
1593
1594 if (path == null) {
1595 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_1);
1596 }
1597 else {
1598 if (path.equals(StringPool.BLANK)) {
1599 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_3);
1600 }
1601 else {
1602 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_2);
1603 }
1604 }
1605
1606 if (orderByComparator != null) {
1607 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1608 orderByComparator);
1609 }
1610
1611 else {
1612 query.append(DLContentModelImpl.ORDER_BY_JPQL);
1613 }
1614
1615 String sql = query.toString();
1616
1617 Session session = null;
1618
1619 try {
1620 session = openSession();
1621
1622 Query q = session.createQuery(sql);
1623
1624 QueryPos qPos = QueryPos.getInstance(q);
1625
1626 qPos.add(companyId);
1627
1628 qPos.add(repositoryId);
1629
1630 if (path != null) {
1631 qPos.add(path);
1632 }
1633
1634 list = (List<DLContent>)QueryUtil.list(q, getDialect(), start,
1635 end);
1636 }
1637 catch (Exception e) {
1638 throw processException(e);
1639 }
1640 finally {
1641 if (list == null) {
1642 FinderCacheUtil.removeResult(finderPath, finderArgs);
1643 }
1644 else {
1645 cacheResult(list);
1646
1647 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1648 }
1649
1650 closeSession(session);
1651 }
1652 }
1653
1654 return list;
1655 }
1656
1657
1668 public DLContent findByC_R_LikeP_First(long companyId, long repositoryId,
1669 String path, OrderByComparator orderByComparator)
1670 throws NoSuchContentException, SystemException {
1671 DLContent dlContent = fetchByC_R_LikeP_First(companyId, repositoryId,
1672 path, orderByComparator);
1673
1674 if (dlContent != null) {
1675 return dlContent;
1676 }
1677
1678 StringBundler msg = new StringBundler(8);
1679
1680 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1681
1682 msg.append("companyId=");
1683 msg.append(companyId);
1684
1685 msg.append(", repositoryId=");
1686 msg.append(repositoryId);
1687
1688 msg.append(", path=");
1689 msg.append(path);
1690
1691 msg.append(StringPool.CLOSE_CURLY_BRACE);
1692
1693 throw new NoSuchContentException(msg.toString());
1694 }
1695
1696
1706 public DLContent fetchByC_R_LikeP_First(long companyId, long repositoryId,
1707 String path, OrderByComparator orderByComparator)
1708 throws SystemException {
1709 List<DLContent> list = findByC_R_LikeP(companyId, repositoryId, path,
1710 0, 1, orderByComparator);
1711
1712 if (!list.isEmpty()) {
1713 return list.get(0);
1714 }
1715
1716 return null;
1717 }
1718
1719
1730 public DLContent findByC_R_LikeP_Last(long companyId, long repositoryId,
1731 String path, OrderByComparator orderByComparator)
1732 throws NoSuchContentException, SystemException {
1733 DLContent dlContent = fetchByC_R_LikeP_Last(companyId, repositoryId,
1734 path, orderByComparator);
1735
1736 if (dlContent != null) {
1737 return dlContent;
1738 }
1739
1740 StringBundler msg = new StringBundler(8);
1741
1742 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1743
1744 msg.append("companyId=");
1745 msg.append(companyId);
1746
1747 msg.append(", repositoryId=");
1748 msg.append(repositoryId);
1749
1750 msg.append(", path=");
1751 msg.append(path);
1752
1753 msg.append(StringPool.CLOSE_CURLY_BRACE);
1754
1755 throw new NoSuchContentException(msg.toString());
1756 }
1757
1758
1768 public DLContent fetchByC_R_LikeP_Last(long companyId, long repositoryId,
1769 String path, OrderByComparator orderByComparator)
1770 throws SystemException {
1771 int count = countByC_R_LikeP(companyId, repositoryId, path);
1772
1773 List<DLContent> list = findByC_R_LikeP(companyId, repositoryId, path,
1774 count - 1, count, orderByComparator);
1775
1776 if (!list.isEmpty()) {
1777 return list.get(0);
1778 }
1779
1780 return null;
1781 }
1782
1783
1795 public DLContent[] findByC_R_LikeP_PrevAndNext(long contentId,
1796 long companyId, long repositoryId, String path,
1797 OrderByComparator orderByComparator)
1798 throws NoSuchContentException, SystemException {
1799 DLContent dlContent = findByPrimaryKey(contentId);
1800
1801 Session session = null;
1802
1803 try {
1804 session = openSession();
1805
1806 DLContent[] array = new DLContentImpl[3];
1807
1808 array[0] = getByC_R_LikeP_PrevAndNext(session, dlContent,
1809 companyId, repositoryId, path, orderByComparator, true);
1810
1811 array[1] = dlContent;
1812
1813 array[2] = getByC_R_LikeP_PrevAndNext(session, dlContent,
1814 companyId, repositoryId, path, orderByComparator, false);
1815
1816 return array;
1817 }
1818 catch (Exception e) {
1819 throw processException(e);
1820 }
1821 finally {
1822 closeSession(session);
1823 }
1824 }
1825
1826 protected DLContent getByC_R_LikeP_PrevAndNext(Session session,
1827 DLContent dlContent, long companyId, long repositoryId, String path,
1828 OrderByComparator orderByComparator, boolean previous) {
1829 StringBundler query = null;
1830
1831 if (orderByComparator != null) {
1832 query = new StringBundler(6 +
1833 (orderByComparator.getOrderByFields().length * 6));
1834 }
1835 else {
1836 query = new StringBundler(3);
1837 }
1838
1839 query.append(_SQL_SELECT_DLCONTENT_WHERE);
1840
1841 query.append(_FINDER_COLUMN_C_R_LIKEP_COMPANYID_2);
1842
1843 query.append(_FINDER_COLUMN_C_R_LIKEP_REPOSITORYID_2);
1844
1845 if (path == null) {
1846 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_1);
1847 }
1848 else {
1849 if (path.equals(StringPool.BLANK)) {
1850 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_3);
1851 }
1852 else {
1853 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_2);
1854 }
1855 }
1856
1857 if (orderByComparator != null) {
1858 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1859
1860 if (orderByConditionFields.length > 0) {
1861 query.append(WHERE_AND);
1862 }
1863
1864 for (int i = 0; i < orderByConditionFields.length; i++) {
1865 query.append(_ORDER_BY_ENTITY_ALIAS);
1866 query.append(orderByConditionFields[i]);
1867
1868 if ((i + 1) < orderByConditionFields.length) {
1869 if (orderByComparator.isAscending() ^ previous) {
1870 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1871 }
1872 else {
1873 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1874 }
1875 }
1876 else {
1877 if (orderByComparator.isAscending() ^ previous) {
1878 query.append(WHERE_GREATER_THAN);
1879 }
1880 else {
1881 query.append(WHERE_LESSER_THAN);
1882 }
1883 }
1884 }
1885
1886 query.append(ORDER_BY_CLAUSE);
1887
1888 String[] orderByFields = orderByComparator.getOrderByFields();
1889
1890 for (int i = 0; i < orderByFields.length; i++) {
1891 query.append(_ORDER_BY_ENTITY_ALIAS);
1892 query.append(orderByFields[i]);
1893
1894 if ((i + 1) < orderByFields.length) {
1895 if (orderByComparator.isAscending() ^ previous) {
1896 query.append(ORDER_BY_ASC_HAS_NEXT);
1897 }
1898 else {
1899 query.append(ORDER_BY_DESC_HAS_NEXT);
1900 }
1901 }
1902 else {
1903 if (orderByComparator.isAscending() ^ previous) {
1904 query.append(ORDER_BY_ASC);
1905 }
1906 else {
1907 query.append(ORDER_BY_DESC);
1908 }
1909 }
1910 }
1911 }
1912
1913 else {
1914 query.append(DLContentModelImpl.ORDER_BY_JPQL);
1915 }
1916
1917 String sql = query.toString();
1918
1919 Query q = session.createQuery(sql);
1920
1921 q.setFirstResult(0);
1922 q.setMaxResults(2);
1923
1924 QueryPos qPos = QueryPos.getInstance(q);
1925
1926 qPos.add(companyId);
1927
1928 qPos.add(repositoryId);
1929
1930 if (path != null) {
1931 qPos.add(path);
1932 }
1933
1934 if (orderByComparator != null) {
1935 Object[] values = orderByComparator.getOrderByConditionValues(dlContent);
1936
1937 for (Object value : values) {
1938 qPos.add(value);
1939 }
1940 }
1941
1942 List<DLContent> list = q.list();
1943
1944 if (list.size() == 2) {
1945 return list.get(1);
1946 }
1947 else {
1948 return null;
1949 }
1950 }
1951
1952
1963 public DLContent findByC_R_P_V(long companyId, long repositoryId,
1964 String path, String version)
1965 throws NoSuchContentException, SystemException {
1966 DLContent dlContent = fetchByC_R_P_V(companyId, repositoryId, path,
1967 version);
1968
1969 if (dlContent == null) {
1970 StringBundler msg = new StringBundler(10);
1971
1972 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1973
1974 msg.append("companyId=");
1975 msg.append(companyId);
1976
1977 msg.append(", repositoryId=");
1978 msg.append(repositoryId);
1979
1980 msg.append(", path=");
1981 msg.append(path);
1982
1983 msg.append(", version=");
1984 msg.append(version);
1985
1986 msg.append(StringPool.CLOSE_CURLY_BRACE);
1987
1988 if (_log.isWarnEnabled()) {
1989 _log.warn(msg.toString());
1990 }
1991
1992 throw new NoSuchContentException(msg.toString());
1993 }
1994
1995 return dlContent;
1996 }
1997
1998
2008 public DLContent fetchByC_R_P_V(long companyId, long repositoryId,
2009 String path, String version) throws SystemException {
2010 return fetchByC_R_P_V(companyId, repositoryId, path, version, true);
2011 }
2012
2013
2024 public DLContent fetchByC_R_P_V(long companyId, long repositoryId,
2025 String path, String version, boolean retrieveFromCache)
2026 throws SystemException {
2027 Object[] finderArgs = new Object[] {
2028 companyId, repositoryId, path, version
2029 };
2030
2031 Object result = null;
2032
2033 if (retrieveFromCache) {
2034 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_R_P_V,
2035 finderArgs, this);
2036 }
2037
2038 if (result instanceof DLContent) {
2039 DLContent dlContent = (DLContent)result;
2040
2041 if ((companyId != dlContent.getCompanyId()) ||
2042 (repositoryId != dlContent.getRepositoryId()) ||
2043 !Validator.equals(path, dlContent.getPath()) ||
2044 !Validator.equals(version, dlContent.getVersion())) {
2045 result = null;
2046 }
2047 }
2048
2049 if (result == null) {
2050 StringBundler query = new StringBundler(6);
2051
2052 query.append(_SQL_SELECT_DLCONTENT_WHERE);
2053
2054 query.append(_FINDER_COLUMN_C_R_P_V_COMPANYID_2);
2055
2056 query.append(_FINDER_COLUMN_C_R_P_V_REPOSITORYID_2);
2057
2058 if (path == null) {
2059 query.append(_FINDER_COLUMN_C_R_P_V_PATH_1);
2060 }
2061 else {
2062 if (path.equals(StringPool.BLANK)) {
2063 query.append(_FINDER_COLUMN_C_R_P_V_PATH_3);
2064 }
2065 else {
2066 query.append(_FINDER_COLUMN_C_R_P_V_PATH_2);
2067 }
2068 }
2069
2070 if (version == null) {
2071 query.append(_FINDER_COLUMN_C_R_P_V_VERSION_1);
2072 }
2073 else {
2074 if (version.equals(StringPool.BLANK)) {
2075 query.append(_FINDER_COLUMN_C_R_P_V_VERSION_3);
2076 }
2077 else {
2078 query.append(_FINDER_COLUMN_C_R_P_V_VERSION_2);
2079 }
2080 }
2081
2082 query.append(DLContentModelImpl.ORDER_BY_JPQL);
2083
2084 String sql = query.toString();
2085
2086 Session session = null;
2087
2088 try {
2089 session = openSession();
2090
2091 Query q = session.createQuery(sql);
2092
2093 QueryPos qPos = QueryPos.getInstance(q);
2094
2095 qPos.add(companyId);
2096
2097 qPos.add(repositoryId);
2098
2099 if (path != null) {
2100 qPos.add(path);
2101 }
2102
2103 if (version != null) {
2104 qPos.add(version);
2105 }
2106
2107 List<DLContent> list = q.list();
2108
2109 result = list;
2110
2111 DLContent dlContent = null;
2112
2113 if (list.isEmpty()) {
2114 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R_P_V,
2115 finderArgs, list);
2116 }
2117 else {
2118 dlContent = list.get(0);
2119
2120 cacheResult(dlContent);
2121
2122 if ((dlContent.getCompanyId() != companyId) ||
2123 (dlContent.getRepositoryId() != repositoryId) ||
2124 (dlContent.getPath() == null) ||
2125 !dlContent.getPath().equals(path) ||
2126 (dlContent.getVersion() == null) ||
2127 !dlContent.getVersion().equals(version)) {
2128 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_R_P_V,
2129 finderArgs, dlContent);
2130 }
2131 }
2132
2133 return dlContent;
2134 }
2135 catch (Exception e) {
2136 throw processException(e);
2137 }
2138 finally {
2139 if (result == null) {
2140 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_R_P_V,
2141 finderArgs);
2142 }
2143
2144 closeSession(session);
2145 }
2146 }
2147 else {
2148 if (result instanceof List<?>) {
2149 return null;
2150 }
2151 else {
2152 return (DLContent)result;
2153 }
2154 }
2155 }
2156
2157
2163 public List<DLContent> findAll() throws SystemException {
2164 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2165 }
2166
2167
2179 public List<DLContent> findAll(int start, int end)
2180 throws SystemException {
2181 return findAll(start, end, null);
2182 }
2183
2184
2197 public List<DLContent> findAll(int start, int end,
2198 OrderByComparator orderByComparator) throws SystemException {
2199 FinderPath finderPath = null;
2200 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2201
2202 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2203 (orderByComparator == null)) {
2204 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2205 finderArgs = FINDER_ARGS_EMPTY;
2206 }
2207 else {
2208 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2209 finderArgs = new Object[] { start, end, orderByComparator };
2210 }
2211
2212 List<DLContent> list = (List<DLContent>)FinderCacheUtil.getResult(finderPath,
2213 finderArgs, this);
2214
2215 if (list == null) {
2216 StringBundler query = null;
2217 String sql = null;
2218
2219 if (orderByComparator != null) {
2220 query = new StringBundler(2 +
2221 (orderByComparator.getOrderByFields().length * 3));
2222
2223 query.append(_SQL_SELECT_DLCONTENT);
2224
2225 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2226 orderByComparator);
2227
2228 sql = query.toString();
2229 }
2230 else {
2231 sql = _SQL_SELECT_DLCONTENT.concat(DLContentModelImpl.ORDER_BY_JPQL);
2232 }
2233
2234 Session session = null;
2235
2236 try {
2237 session = openSession();
2238
2239 Query q = session.createQuery(sql);
2240
2241 if (orderByComparator == null) {
2242 list = (List<DLContent>)QueryUtil.list(q, getDialect(),
2243 start, end, false);
2244
2245 Collections.sort(list);
2246 }
2247 else {
2248 list = (List<DLContent>)QueryUtil.list(q, getDialect(),
2249 start, end);
2250 }
2251 }
2252 catch (Exception e) {
2253 throw processException(e);
2254 }
2255 finally {
2256 if (list == null) {
2257 FinderCacheUtil.removeResult(finderPath, finderArgs);
2258 }
2259 else {
2260 cacheResult(list);
2261
2262 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2263 }
2264
2265 closeSession(session);
2266 }
2267 }
2268
2269 return list;
2270 }
2271
2272
2279 public void removeByC_R(long companyId, long repositoryId)
2280 throws SystemException {
2281 for (DLContent dlContent : findByC_R(companyId, repositoryId)) {
2282 remove(dlContent);
2283 }
2284 }
2285
2286
2294 public void removeByC_R_P(long companyId, long repositoryId, String path)
2295 throws SystemException {
2296 for (DLContent dlContent : findByC_R_P(companyId, repositoryId, path)) {
2297 remove(dlContent);
2298 }
2299 }
2300
2301
2309 public void removeByC_R_LikeP(long companyId, long repositoryId, String path)
2310 throws SystemException {
2311 for (DLContent dlContent : findByC_R_LikeP(companyId, repositoryId, path)) {
2312 remove(dlContent);
2313 }
2314 }
2315
2316
2326 public DLContent removeByC_R_P_V(long companyId, long repositoryId,
2327 String path, String version)
2328 throws NoSuchContentException, SystemException {
2329 DLContent dlContent = findByC_R_P_V(companyId, repositoryId, path,
2330 version);
2331
2332 return remove(dlContent);
2333 }
2334
2335
2340 public void removeAll() throws SystemException {
2341 for (DLContent dlContent : findAll()) {
2342 remove(dlContent);
2343 }
2344 }
2345
2346
2354 public int countByC_R(long companyId, long repositoryId)
2355 throws SystemException {
2356 Object[] finderArgs = new Object[] { companyId, repositoryId };
2357
2358 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_R,
2359 finderArgs, this);
2360
2361 if (count == null) {
2362 StringBundler query = new StringBundler(3);
2363
2364 query.append(_SQL_COUNT_DLCONTENT_WHERE);
2365
2366 query.append(_FINDER_COLUMN_C_R_COMPANYID_2);
2367
2368 query.append(_FINDER_COLUMN_C_R_REPOSITORYID_2);
2369
2370 String sql = query.toString();
2371
2372 Session session = null;
2373
2374 try {
2375 session = openSession();
2376
2377 Query q = session.createQuery(sql);
2378
2379 QueryPos qPos = QueryPos.getInstance(q);
2380
2381 qPos.add(companyId);
2382
2383 qPos.add(repositoryId);
2384
2385 count = (Long)q.uniqueResult();
2386 }
2387 catch (Exception e) {
2388 throw processException(e);
2389 }
2390 finally {
2391 if (count == null) {
2392 count = Long.valueOf(0);
2393 }
2394
2395 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_R, finderArgs,
2396 count);
2397
2398 closeSession(session);
2399 }
2400 }
2401
2402 return count.intValue();
2403 }
2404
2405
2414 public int countByC_R_P(long companyId, long repositoryId, String path)
2415 throws SystemException {
2416 Object[] finderArgs = new Object[] { companyId, repositoryId, path };
2417
2418 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_R_P,
2419 finderArgs, this);
2420
2421 if (count == null) {
2422 StringBundler query = new StringBundler(4);
2423
2424 query.append(_SQL_COUNT_DLCONTENT_WHERE);
2425
2426 query.append(_FINDER_COLUMN_C_R_P_COMPANYID_2);
2427
2428 query.append(_FINDER_COLUMN_C_R_P_REPOSITORYID_2);
2429
2430 if (path == null) {
2431 query.append(_FINDER_COLUMN_C_R_P_PATH_1);
2432 }
2433 else {
2434 if (path.equals(StringPool.BLANK)) {
2435 query.append(_FINDER_COLUMN_C_R_P_PATH_3);
2436 }
2437 else {
2438 query.append(_FINDER_COLUMN_C_R_P_PATH_2);
2439 }
2440 }
2441
2442 String sql = query.toString();
2443
2444 Session session = null;
2445
2446 try {
2447 session = openSession();
2448
2449 Query q = session.createQuery(sql);
2450
2451 QueryPos qPos = QueryPos.getInstance(q);
2452
2453 qPos.add(companyId);
2454
2455 qPos.add(repositoryId);
2456
2457 if (path != null) {
2458 qPos.add(path);
2459 }
2460
2461 count = (Long)q.uniqueResult();
2462 }
2463 catch (Exception e) {
2464 throw processException(e);
2465 }
2466 finally {
2467 if (count == null) {
2468 count = Long.valueOf(0);
2469 }
2470
2471 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_R_P,
2472 finderArgs, count);
2473
2474 closeSession(session);
2475 }
2476 }
2477
2478 return count.intValue();
2479 }
2480
2481
2490 public int countByC_R_LikeP(long companyId, long repositoryId, String path)
2491 throws SystemException {
2492 Object[] finderArgs = new Object[] { companyId, repositoryId, path };
2493
2494 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_R_LIKEP,
2495 finderArgs, this);
2496
2497 if (count == null) {
2498 StringBundler query = new StringBundler(4);
2499
2500 query.append(_SQL_COUNT_DLCONTENT_WHERE);
2501
2502 query.append(_FINDER_COLUMN_C_R_LIKEP_COMPANYID_2);
2503
2504 query.append(_FINDER_COLUMN_C_R_LIKEP_REPOSITORYID_2);
2505
2506 if (path == null) {
2507 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_1);
2508 }
2509 else {
2510 if (path.equals(StringPool.BLANK)) {
2511 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_3);
2512 }
2513 else {
2514 query.append(_FINDER_COLUMN_C_R_LIKEP_PATH_2);
2515 }
2516 }
2517
2518 String sql = query.toString();
2519
2520 Session session = null;
2521
2522 try {
2523 session = openSession();
2524
2525 Query q = session.createQuery(sql);
2526
2527 QueryPos qPos = QueryPos.getInstance(q);
2528
2529 qPos.add(companyId);
2530
2531 qPos.add(repositoryId);
2532
2533 if (path != null) {
2534 qPos.add(path);
2535 }
2536
2537 count = (Long)q.uniqueResult();
2538 }
2539 catch (Exception e) {
2540 throw processException(e);
2541 }
2542 finally {
2543 if (count == null) {
2544 count = Long.valueOf(0);
2545 }
2546
2547 FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_R_LIKEP,
2548 finderArgs, count);
2549
2550 closeSession(session);
2551 }
2552 }
2553
2554 return count.intValue();
2555 }
2556
2557
2567 public int countByC_R_P_V(long companyId, long repositoryId, String path,
2568 String version) throws SystemException {
2569 Object[] finderArgs = new Object[] {
2570 companyId, repositoryId, path, version
2571 };
2572
2573 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_R_P_V,
2574 finderArgs, this);
2575
2576 if (count == null) {
2577 StringBundler query = new StringBundler(5);
2578
2579 query.append(_SQL_COUNT_DLCONTENT_WHERE);
2580
2581 query.append(_FINDER_COLUMN_C_R_P_V_COMPANYID_2);
2582
2583 query.append(_FINDER_COLUMN_C_R_P_V_REPOSITORYID_2);
2584
2585 if (path == null) {
2586 query.append(_FINDER_COLUMN_C_R_P_V_PATH_1);
2587 }
2588 else {
2589 if (path.equals(StringPool.BLANK)) {
2590 query.append(_FINDER_COLUMN_C_R_P_V_PATH_3);
2591 }
2592 else {
2593 query.append(_FINDER_COLUMN_C_R_P_V_PATH_2);
2594 }
2595 }
2596
2597 if (version == null) {
2598 query.append(_FINDER_COLUMN_C_R_P_V_VERSION_1);
2599 }
2600 else {
2601 if (version.equals(StringPool.BLANK)) {
2602 query.append(_FINDER_COLUMN_C_R_P_V_VERSION_3);
2603 }
2604 else {
2605 query.append(_FINDER_COLUMN_C_R_P_V_VERSION_2);
2606 }
2607 }
2608
2609 String sql = query.toString();
2610
2611 Session session = null;
2612
2613 try {
2614 session = openSession();
2615
2616 Query q = session.createQuery(sql);
2617
2618 QueryPos qPos = QueryPos.getInstance(q);
2619
2620 qPos.add(companyId);
2621
2622 qPos.add(repositoryId);
2623
2624 if (path != null) {
2625 qPos.add(path);
2626 }
2627
2628 if (version != null) {
2629 qPos.add(version);
2630 }
2631
2632 count = (Long)q.uniqueResult();
2633 }
2634 catch (Exception e) {
2635 throw processException(e);
2636 }
2637 finally {
2638 if (count == null) {
2639 count = Long.valueOf(0);
2640 }
2641
2642 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_R_P_V,
2643 finderArgs, count);
2644
2645 closeSession(session);
2646 }
2647 }
2648
2649 return count.intValue();
2650 }
2651
2652
2658 public int countAll() throws SystemException {
2659 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2660 FINDER_ARGS_EMPTY, this);
2661
2662 if (count == null) {
2663 Session session = null;
2664
2665 try {
2666 session = openSession();
2667
2668 Query q = session.createQuery(_SQL_COUNT_DLCONTENT);
2669
2670 count = (Long)q.uniqueResult();
2671 }
2672 catch (Exception e) {
2673 throw processException(e);
2674 }
2675 finally {
2676 if (count == null) {
2677 count = Long.valueOf(0);
2678 }
2679
2680 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2681 FINDER_ARGS_EMPTY, count);
2682
2683 closeSession(session);
2684 }
2685 }
2686
2687 return count.intValue();
2688 }
2689
2690
2693 public void afterPropertiesSet() {
2694 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2695 com.liferay.portal.util.PropsUtil.get(
2696 "value.object.listener.com.liferay.portlet.documentlibrary.model.DLContent")));
2697
2698 if (listenerClassNames.length > 0) {
2699 try {
2700 List<ModelListener<DLContent>> listenersList = new ArrayList<ModelListener<DLContent>>();
2701
2702 for (String listenerClassName : listenerClassNames) {
2703 listenersList.add((ModelListener<DLContent>)InstanceFactory.newInstance(
2704 listenerClassName));
2705 }
2706
2707 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2708 }
2709 catch (Exception e) {
2710 _log.error(e);
2711 }
2712 }
2713 }
2714
2715 public void destroy() {
2716 EntityCacheUtil.removeCache(DLContentImpl.class.getName());
2717 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2718 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2719 }
2720
2721 @BeanReference(type = DLContentPersistence.class)
2722 protected DLContentPersistence dlContentPersistence;
2723 @BeanReference(type = DLFileEntryPersistence.class)
2724 protected DLFileEntryPersistence dlFileEntryPersistence;
2725 @BeanReference(type = DLFileEntryMetadataPersistence.class)
2726 protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
2727 @BeanReference(type = DLFileEntryTypePersistence.class)
2728 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
2729 @BeanReference(type = DLFileRankPersistence.class)
2730 protected DLFileRankPersistence dlFileRankPersistence;
2731 @BeanReference(type = DLFileShortcutPersistence.class)
2732 protected DLFileShortcutPersistence dlFileShortcutPersistence;
2733 @BeanReference(type = DLFileVersionPersistence.class)
2734 protected DLFileVersionPersistence dlFileVersionPersistence;
2735 @BeanReference(type = DLFolderPersistence.class)
2736 protected DLFolderPersistence dlFolderPersistence;
2737 @BeanReference(type = DLSyncPersistence.class)
2738 protected DLSyncPersistence dlSyncPersistence;
2739 @BeanReference(type = UserPersistence.class)
2740 protected UserPersistence userPersistence;
2741 private static final String _SQL_SELECT_DLCONTENT = "SELECT dlContent FROM DLContent dlContent";
2742 private static final String _SQL_SELECT_DLCONTENT_WHERE = "SELECT dlContent FROM DLContent dlContent WHERE ";
2743 private static final String _SQL_COUNT_DLCONTENT = "SELECT COUNT(dlContent) FROM DLContent dlContent";
2744 private static final String _SQL_COUNT_DLCONTENT_WHERE = "SELECT COUNT(dlContent) FROM DLContent dlContent WHERE ";
2745 private static final String _FINDER_COLUMN_C_R_COMPANYID_2 = "dlContent.companyId = ? AND ";
2746 private static final String _FINDER_COLUMN_C_R_REPOSITORYID_2 = "dlContent.repositoryId = ?";
2747 private static final String _FINDER_COLUMN_C_R_P_COMPANYID_2 = "dlContent.companyId = ? AND ";
2748 private static final String _FINDER_COLUMN_C_R_P_REPOSITORYID_2 = "dlContent.repositoryId = ? AND ";
2749 private static final String _FINDER_COLUMN_C_R_P_PATH_1 = "dlContent.path IS NULL";
2750 private static final String _FINDER_COLUMN_C_R_P_PATH_2 = "dlContent.path = ?";
2751 private static final String _FINDER_COLUMN_C_R_P_PATH_3 = "(dlContent.path IS NULL OR dlContent.path = ?)";
2752 private static final String _FINDER_COLUMN_C_R_LIKEP_COMPANYID_2 = "dlContent.companyId = ? AND ";
2753 private static final String _FINDER_COLUMN_C_R_LIKEP_REPOSITORYID_2 = "dlContent.repositoryId = ? AND ";
2754 private static final String _FINDER_COLUMN_C_R_LIKEP_PATH_1 = "dlContent.path LIKE NULL";
2755 private static final String _FINDER_COLUMN_C_R_LIKEP_PATH_2 = "dlContent.path LIKE ?";
2756 private static final String _FINDER_COLUMN_C_R_LIKEP_PATH_3 = "(dlContent.path IS NULL OR dlContent.path LIKE ?)";
2757 private static final String _FINDER_COLUMN_C_R_P_V_COMPANYID_2 = "dlContent.companyId = ? AND ";
2758 private static final String _FINDER_COLUMN_C_R_P_V_REPOSITORYID_2 = "dlContent.repositoryId = ? AND ";
2759 private static final String _FINDER_COLUMN_C_R_P_V_PATH_1 = "dlContent.path IS NULL AND ";
2760 private static final String _FINDER_COLUMN_C_R_P_V_PATH_2 = "dlContent.path = ? AND ";
2761 private static final String _FINDER_COLUMN_C_R_P_V_PATH_3 = "(dlContent.path IS NULL OR dlContent.path = ?) AND ";
2762 private static final String _FINDER_COLUMN_C_R_P_V_VERSION_1 = "dlContent.version IS NULL";
2763 private static final String _FINDER_COLUMN_C_R_P_V_VERSION_2 = "dlContent.version = ?";
2764 private static final String _FINDER_COLUMN_C_R_P_V_VERSION_3 = "(dlContent.version IS NULL OR dlContent.version = ?)";
2765 private static final String _ORDER_BY_ENTITY_ALIAS = "dlContent.";
2766 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLContent exists with the primary key ";
2767 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLContent exists with the key {";
2768 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2769 private static Log _log = LogFactoryUtil.getLog(DLContentPersistenceImpl.class);
2770 private static DLContent _nullDLContent = new DLContentImpl() {
2771 @Override
2772 public Object clone() {
2773 return this;
2774 }
2775
2776 @Override
2777 public CacheModel<DLContent> toCacheModel() {
2778 return _nullDLContentCacheModel;
2779 }
2780 };
2781
2782 private static CacheModel<DLContent> _nullDLContentCacheModel = new CacheModel<DLContent>() {
2783 public DLContent toEntityModel() {
2784 return _nullDLContent;
2785 }
2786 };
2787 }