001
014
015 package com.liferay.portlet.dynamicdatalists.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.BatchSessionUtil;
040 import com.liferay.portal.service.persistence.ResourcePersistence;
041 import com.liferay.portal.service.persistence.UserPersistence;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.dynamicdatalists.NoSuchRecordVersionException;
045 import com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion;
046 import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordVersionImpl;
047 import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordVersionModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.ArrayList;
052 import java.util.Collections;
053 import java.util.List;
054
055
067 public class DDLRecordVersionPersistenceImpl extends BasePersistenceImpl<DDLRecordVersion>
068 implements DDLRecordVersionPersistence {
069
074 public static final String FINDER_CLASS_NAME_ENTITY = DDLRecordVersionImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List1";
077 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List2";
079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RECORDID = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
080 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
081 DDLRecordVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
082 "findByRecordId",
083 new String[] {
084 Long.class.getName(),
085
086 "java.lang.Integer", "java.lang.Integer",
087 "com.liferay.portal.kernel.util.OrderByComparator"
088 });
089 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID =
090 new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
091 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
092 DDLRecordVersionImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRecordId",
094 new String[] { Long.class.getName() },
095 DDLRecordVersionModelImpl.RECORDID_COLUMN_BITMASK);
096 public static final FinderPath FINDER_PATH_COUNT_BY_RECORDID = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
097 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRecordId",
099 new String[] { Long.class.getName() });
100 public static final FinderPath FINDER_PATH_FETCH_BY_R_V = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
101 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
102 DDLRecordVersionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByR_V",
103 new String[] { Long.class.getName(), String.class.getName() },
104 DDLRecordVersionModelImpl.RECORDID_COLUMN_BITMASK |
105 DDLRecordVersionModelImpl.VERSION_COLUMN_BITMASK);
106 public static final FinderPath FINDER_PATH_COUNT_BY_R_V = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
107 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_V",
109 new String[] { Long.class.getName(), String.class.getName() });
110 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
111 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
112 DDLRecordVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
113 "findByR_S",
114 new String[] {
115 Long.class.getName(), Integer.class.getName(),
116
117 "java.lang.Integer", "java.lang.Integer",
118 "com.liferay.portal.kernel.util.OrderByComparator"
119 });
120 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
121 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
122 DDLRecordVersionImpl.class,
123 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_S",
124 new String[] { Long.class.getName(), Integer.class.getName() },
125 DDLRecordVersionModelImpl.RECORDID_COLUMN_BITMASK |
126 DDLRecordVersionModelImpl.STATUS_COLUMN_BITMASK);
127 public static final FinderPath FINDER_PATH_COUNT_BY_R_S = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
128 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
129 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_S",
130 new String[] { Long.class.getName(), Integer.class.getName() });
131 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
132 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
133 DDLRecordVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
134 "findAll", new String[0]);
135 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
136 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
137 DDLRecordVersionImpl.class,
138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
139 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
140 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
142
143
148 public void cacheResult(DDLRecordVersion ddlRecordVersion) {
149 EntityCacheUtil.putResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
150 DDLRecordVersionImpl.class, ddlRecordVersion.getPrimaryKey(),
151 ddlRecordVersion);
152
153 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
154 new Object[] {
155 Long.valueOf(ddlRecordVersion.getRecordId()),
156
157 ddlRecordVersion.getVersion()
158 }, ddlRecordVersion);
159
160 ddlRecordVersion.resetOriginalValues();
161 }
162
163
168 public void cacheResult(List<DDLRecordVersion> ddlRecordVersions) {
169 for (DDLRecordVersion ddlRecordVersion : ddlRecordVersions) {
170 if (EntityCacheUtil.getResult(
171 DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
172 DDLRecordVersionImpl.class,
173 ddlRecordVersion.getPrimaryKey()) == null) {
174 cacheResult(ddlRecordVersion);
175 }
176 else {
177 ddlRecordVersion.resetOriginalValues();
178 }
179 }
180 }
181
182
189 @Override
190 public void clearCache() {
191 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
192 CacheRegistryUtil.clear(DDLRecordVersionImpl.class.getName());
193 }
194
195 EntityCacheUtil.clearCache(DDLRecordVersionImpl.class.getName());
196
197 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
198 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
199 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
200 }
201
202
209 @Override
210 public void clearCache(DDLRecordVersion ddlRecordVersion) {
211 EntityCacheUtil.removeResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
212 DDLRecordVersionImpl.class, ddlRecordVersion.getPrimaryKey());
213
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
215 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
216
217 clearUniqueFindersCache(ddlRecordVersion);
218 }
219
220 @Override
221 public void clearCache(List<DDLRecordVersion> ddlRecordVersions) {
222 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
223 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
224
225 for (DDLRecordVersion ddlRecordVersion : ddlRecordVersions) {
226 EntityCacheUtil.removeResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
227 DDLRecordVersionImpl.class, ddlRecordVersion.getPrimaryKey());
228
229 clearUniqueFindersCache(ddlRecordVersion);
230 }
231 }
232
233 protected void clearUniqueFindersCache(DDLRecordVersion ddlRecordVersion) {
234 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_V,
235 new Object[] {
236 Long.valueOf(ddlRecordVersion.getRecordId()),
237
238 ddlRecordVersion.getVersion()
239 });
240 }
241
242
248 public DDLRecordVersion create(long recordVersionId) {
249 DDLRecordVersion ddlRecordVersion = new DDLRecordVersionImpl();
250
251 ddlRecordVersion.setNew(true);
252 ddlRecordVersion.setPrimaryKey(recordVersionId);
253
254 return ddlRecordVersion;
255 }
256
257
265 public DDLRecordVersion remove(long recordVersionId)
266 throws NoSuchRecordVersionException, SystemException {
267 return remove(Long.valueOf(recordVersionId));
268 }
269
270
278 @Override
279 public DDLRecordVersion remove(Serializable primaryKey)
280 throws NoSuchRecordVersionException, SystemException {
281 Session session = null;
282
283 try {
284 session = openSession();
285
286 DDLRecordVersion ddlRecordVersion = (DDLRecordVersion)session.get(DDLRecordVersionImpl.class,
287 primaryKey);
288
289 if (ddlRecordVersion == null) {
290 if (_log.isWarnEnabled()) {
291 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
292 }
293
294 throw new NoSuchRecordVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
295 primaryKey);
296 }
297
298 return remove(ddlRecordVersion);
299 }
300 catch (NoSuchRecordVersionException nsee) {
301 throw nsee;
302 }
303 catch (Exception e) {
304 throw processException(e);
305 }
306 finally {
307 closeSession(session);
308 }
309 }
310
311 @Override
312 protected DDLRecordVersion removeImpl(DDLRecordVersion ddlRecordVersion)
313 throws SystemException {
314 ddlRecordVersion = toUnwrappedModel(ddlRecordVersion);
315
316 Session session = null;
317
318 try {
319 session = openSession();
320
321 BatchSessionUtil.delete(session, ddlRecordVersion);
322 }
323 catch (Exception e) {
324 throw processException(e);
325 }
326 finally {
327 closeSession(session);
328 }
329
330 clearCache(ddlRecordVersion);
331
332 return ddlRecordVersion;
333 }
334
335 @Override
336 public DDLRecordVersion updateImpl(
337 com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion ddlRecordVersion,
338 boolean merge) throws SystemException {
339 ddlRecordVersion = toUnwrappedModel(ddlRecordVersion);
340
341 boolean isNew = ddlRecordVersion.isNew();
342
343 DDLRecordVersionModelImpl ddlRecordVersionModelImpl = (DDLRecordVersionModelImpl)ddlRecordVersion;
344
345 Session session = null;
346
347 try {
348 session = openSession();
349
350 BatchSessionUtil.update(session, ddlRecordVersion, merge);
351
352 ddlRecordVersion.setNew(false);
353 }
354 catch (Exception e) {
355 throw processException(e);
356 }
357 finally {
358 closeSession(session);
359 }
360
361 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
362
363 if (isNew || !DDLRecordVersionModelImpl.COLUMN_BITMASK_ENABLED) {
364 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
365 }
366
367 else {
368 if ((ddlRecordVersionModelImpl.getColumnBitmask() &
369 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID.getColumnBitmask()) != 0) {
370 Object[] args = new Object[] {
371 Long.valueOf(ddlRecordVersionModelImpl.getOriginalRecordId())
372 };
373
374 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECORDID, args);
375 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID,
376 args);
377
378 args = new Object[] {
379 Long.valueOf(ddlRecordVersionModelImpl.getRecordId())
380 };
381
382 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECORDID, args);
383 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID,
384 args);
385 }
386
387 if ((ddlRecordVersionModelImpl.getColumnBitmask() &
388 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S.getColumnBitmask()) != 0) {
389 Object[] args = new Object[] {
390 Long.valueOf(ddlRecordVersionModelImpl.getOriginalRecordId()),
391 Integer.valueOf(ddlRecordVersionModelImpl.getOriginalStatus())
392 };
393
394 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_S, args);
395 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S,
396 args);
397
398 args = new Object[] {
399 Long.valueOf(ddlRecordVersionModelImpl.getRecordId()),
400 Integer.valueOf(ddlRecordVersionModelImpl.getStatus())
401 };
402
403 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_S, args);
404 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S,
405 args);
406 }
407 }
408
409 EntityCacheUtil.putResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
410 DDLRecordVersionImpl.class, ddlRecordVersion.getPrimaryKey(),
411 ddlRecordVersion);
412
413 if (isNew) {
414 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
415 new Object[] {
416 Long.valueOf(ddlRecordVersion.getRecordId()),
417
418 ddlRecordVersion.getVersion()
419 }, ddlRecordVersion);
420 }
421 else {
422 if ((ddlRecordVersionModelImpl.getColumnBitmask() &
423 FINDER_PATH_FETCH_BY_R_V.getColumnBitmask()) != 0) {
424 Object[] args = new Object[] {
425 Long.valueOf(ddlRecordVersionModelImpl.getOriginalRecordId()),
426
427 ddlRecordVersionModelImpl.getOriginalVersion()
428 };
429
430 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_V, args);
431
432 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_V, args);
433
434 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
435 new Object[] {
436 Long.valueOf(ddlRecordVersion.getRecordId()),
437
438 ddlRecordVersion.getVersion()
439 }, ddlRecordVersion);
440 }
441 }
442
443 return ddlRecordVersion;
444 }
445
446 protected DDLRecordVersion toUnwrappedModel(
447 DDLRecordVersion ddlRecordVersion) {
448 if (ddlRecordVersion instanceof DDLRecordVersionImpl) {
449 return ddlRecordVersion;
450 }
451
452 DDLRecordVersionImpl ddlRecordVersionImpl = new DDLRecordVersionImpl();
453
454 ddlRecordVersionImpl.setNew(ddlRecordVersion.isNew());
455 ddlRecordVersionImpl.setPrimaryKey(ddlRecordVersion.getPrimaryKey());
456
457 ddlRecordVersionImpl.setRecordVersionId(ddlRecordVersion.getRecordVersionId());
458 ddlRecordVersionImpl.setGroupId(ddlRecordVersion.getGroupId());
459 ddlRecordVersionImpl.setCompanyId(ddlRecordVersion.getCompanyId());
460 ddlRecordVersionImpl.setUserId(ddlRecordVersion.getUserId());
461 ddlRecordVersionImpl.setUserName(ddlRecordVersion.getUserName());
462 ddlRecordVersionImpl.setCreateDate(ddlRecordVersion.getCreateDate());
463 ddlRecordVersionImpl.setDDMStorageId(ddlRecordVersion.getDDMStorageId());
464 ddlRecordVersionImpl.setRecordSetId(ddlRecordVersion.getRecordSetId());
465 ddlRecordVersionImpl.setRecordId(ddlRecordVersion.getRecordId());
466 ddlRecordVersionImpl.setVersion(ddlRecordVersion.getVersion());
467 ddlRecordVersionImpl.setDisplayIndex(ddlRecordVersion.getDisplayIndex());
468 ddlRecordVersionImpl.setStatus(ddlRecordVersion.getStatus());
469 ddlRecordVersionImpl.setStatusByUserId(ddlRecordVersion.getStatusByUserId());
470 ddlRecordVersionImpl.setStatusByUserName(ddlRecordVersion.getStatusByUserName());
471 ddlRecordVersionImpl.setStatusDate(ddlRecordVersion.getStatusDate());
472
473 return ddlRecordVersionImpl;
474 }
475
476
484 @Override
485 public DDLRecordVersion findByPrimaryKey(Serializable primaryKey)
486 throws NoSuchModelException, SystemException {
487 return findByPrimaryKey(((Long)primaryKey).longValue());
488 }
489
490
498 public DDLRecordVersion findByPrimaryKey(long recordVersionId)
499 throws NoSuchRecordVersionException, SystemException {
500 DDLRecordVersion ddlRecordVersion = fetchByPrimaryKey(recordVersionId);
501
502 if (ddlRecordVersion == null) {
503 if (_log.isWarnEnabled()) {
504 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + recordVersionId);
505 }
506
507 throw new NoSuchRecordVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
508 recordVersionId);
509 }
510
511 return ddlRecordVersion;
512 }
513
514
521 @Override
522 public DDLRecordVersion fetchByPrimaryKey(Serializable primaryKey)
523 throws SystemException {
524 return fetchByPrimaryKey(((Long)primaryKey).longValue());
525 }
526
527
534 public DDLRecordVersion fetchByPrimaryKey(long recordVersionId)
535 throws SystemException {
536 DDLRecordVersion ddlRecordVersion = (DDLRecordVersion)EntityCacheUtil.getResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
537 DDLRecordVersionImpl.class, recordVersionId);
538
539 if (ddlRecordVersion == _nullDDLRecordVersion) {
540 return null;
541 }
542
543 if (ddlRecordVersion == null) {
544 Session session = null;
545
546 boolean hasException = false;
547
548 try {
549 session = openSession();
550
551 ddlRecordVersion = (DDLRecordVersion)session.get(DDLRecordVersionImpl.class,
552 Long.valueOf(recordVersionId));
553 }
554 catch (Exception e) {
555 hasException = true;
556
557 throw processException(e);
558 }
559 finally {
560 if (ddlRecordVersion != null) {
561 cacheResult(ddlRecordVersion);
562 }
563 else if (!hasException) {
564 EntityCacheUtil.putResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
565 DDLRecordVersionImpl.class, recordVersionId,
566 _nullDDLRecordVersion);
567 }
568
569 closeSession(session);
570 }
571 }
572
573 return ddlRecordVersion;
574 }
575
576
583 public List<DDLRecordVersion> findByRecordId(long recordId)
584 throws SystemException {
585 return findByRecordId(recordId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
586 null);
587 }
588
589
602 public List<DDLRecordVersion> findByRecordId(long recordId, int start,
603 int end) throws SystemException {
604 return findByRecordId(recordId, start, end, null);
605 }
606
607
621 public List<DDLRecordVersion> findByRecordId(long recordId, int start,
622 int end, OrderByComparator orderByComparator) throws SystemException {
623 FinderPath finderPath = null;
624 Object[] finderArgs = null;
625
626 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
627 (orderByComparator == null)) {
628 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID;
629 finderArgs = new Object[] { recordId };
630 }
631 else {
632 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RECORDID;
633 finderArgs = new Object[] { recordId, start, end, orderByComparator };
634 }
635
636 List<DDLRecordVersion> list = (List<DDLRecordVersion>)FinderCacheUtil.getResult(finderPath,
637 finderArgs, this);
638
639 if ((list != null) && !list.isEmpty()) {
640 for (DDLRecordVersion ddlRecordVersion : list) {
641 if ((recordId != ddlRecordVersion.getRecordId())) {
642 list = null;
643
644 break;
645 }
646 }
647 }
648
649 if (list == null) {
650 StringBundler query = null;
651
652 if (orderByComparator != null) {
653 query = new StringBundler(3 +
654 (orderByComparator.getOrderByFields().length * 3));
655 }
656 else {
657 query = new StringBundler(2);
658 }
659
660 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
661
662 query.append(_FINDER_COLUMN_RECORDID_RECORDID_2);
663
664 if (orderByComparator != null) {
665 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
666 orderByComparator);
667 }
668
669 String sql = query.toString();
670
671 Session session = null;
672
673 try {
674 session = openSession();
675
676 Query q = session.createQuery(sql);
677
678 QueryPos qPos = QueryPos.getInstance(q);
679
680 qPos.add(recordId);
681
682 list = (List<DDLRecordVersion>)QueryUtil.list(q, getDialect(),
683 start, end);
684 }
685 catch (Exception e) {
686 throw processException(e);
687 }
688 finally {
689 if (list == null) {
690 FinderCacheUtil.removeResult(finderPath, finderArgs);
691 }
692 else {
693 cacheResult(list);
694
695 FinderCacheUtil.putResult(finderPath, finderArgs, list);
696 }
697
698 closeSession(session);
699 }
700 }
701
702 return list;
703 }
704
705
714 public DDLRecordVersion findByRecordId_First(long recordId,
715 OrderByComparator orderByComparator)
716 throws NoSuchRecordVersionException, SystemException {
717 DDLRecordVersion ddlRecordVersion = fetchByRecordId_First(recordId,
718 orderByComparator);
719
720 if (ddlRecordVersion != null) {
721 return ddlRecordVersion;
722 }
723
724 StringBundler msg = new StringBundler(4);
725
726 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
727
728 msg.append("recordId=");
729 msg.append(recordId);
730
731 msg.append(StringPool.CLOSE_CURLY_BRACE);
732
733 throw new NoSuchRecordVersionException(msg.toString());
734 }
735
736
744 public DDLRecordVersion fetchByRecordId_First(long recordId,
745 OrderByComparator orderByComparator) throws SystemException {
746 List<DDLRecordVersion> list = findByRecordId(recordId, 0, 1,
747 orderByComparator);
748
749 if (!list.isEmpty()) {
750 return list.get(0);
751 }
752
753 return null;
754 }
755
756
765 public DDLRecordVersion findByRecordId_Last(long recordId,
766 OrderByComparator orderByComparator)
767 throws NoSuchRecordVersionException, SystemException {
768 DDLRecordVersion ddlRecordVersion = fetchByRecordId_Last(recordId,
769 orderByComparator);
770
771 if (ddlRecordVersion != null) {
772 return ddlRecordVersion;
773 }
774
775 StringBundler msg = new StringBundler(4);
776
777 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
778
779 msg.append("recordId=");
780 msg.append(recordId);
781
782 msg.append(StringPool.CLOSE_CURLY_BRACE);
783
784 throw new NoSuchRecordVersionException(msg.toString());
785 }
786
787
795 public DDLRecordVersion fetchByRecordId_Last(long recordId,
796 OrderByComparator orderByComparator) throws SystemException {
797 int count = countByRecordId(recordId);
798
799 List<DDLRecordVersion> list = findByRecordId(recordId, count - 1,
800 count, orderByComparator);
801
802 if (!list.isEmpty()) {
803 return list.get(0);
804 }
805
806 return null;
807 }
808
809
819 public DDLRecordVersion[] findByRecordId_PrevAndNext(long recordVersionId,
820 long recordId, OrderByComparator orderByComparator)
821 throws NoSuchRecordVersionException, SystemException {
822 DDLRecordVersion ddlRecordVersion = findByPrimaryKey(recordVersionId);
823
824 Session session = null;
825
826 try {
827 session = openSession();
828
829 DDLRecordVersion[] array = new DDLRecordVersionImpl[3];
830
831 array[0] = getByRecordId_PrevAndNext(session, ddlRecordVersion,
832 recordId, orderByComparator, true);
833
834 array[1] = ddlRecordVersion;
835
836 array[2] = getByRecordId_PrevAndNext(session, ddlRecordVersion,
837 recordId, orderByComparator, false);
838
839 return array;
840 }
841 catch (Exception e) {
842 throw processException(e);
843 }
844 finally {
845 closeSession(session);
846 }
847 }
848
849 protected DDLRecordVersion getByRecordId_PrevAndNext(Session session,
850 DDLRecordVersion ddlRecordVersion, long recordId,
851 OrderByComparator orderByComparator, boolean previous) {
852 StringBundler query = null;
853
854 if (orderByComparator != null) {
855 query = new StringBundler(6 +
856 (orderByComparator.getOrderByFields().length * 6));
857 }
858 else {
859 query = new StringBundler(3);
860 }
861
862 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
863
864 query.append(_FINDER_COLUMN_RECORDID_RECORDID_2);
865
866 if (orderByComparator != null) {
867 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
868
869 if (orderByConditionFields.length > 0) {
870 query.append(WHERE_AND);
871 }
872
873 for (int i = 0; i < orderByConditionFields.length; i++) {
874 query.append(_ORDER_BY_ENTITY_ALIAS);
875 query.append(orderByConditionFields[i]);
876
877 if ((i + 1) < orderByConditionFields.length) {
878 if (orderByComparator.isAscending() ^ previous) {
879 query.append(WHERE_GREATER_THAN_HAS_NEXT);
880 }
881 else {
882 query.append(WHERE_LESSER_THAN_HAS_NEXT);
883 }
884 }
885 else {
886 if (orderByComparator.isAscending() ^ previous) {
887 query.append(WHERE_GREATER_THAN);
888 }
889 else {
890 query.append(WHERE_LESSER_THAN);
891 }
892 }
893 }
894
895 query.append(ORDER_BY_CLAUSE);
896
897 String[] orderByFields = orderByComparator.getOrderByFields();
898
899 for (int i = 0; i < orderByFields.length; i++) {
900 query.append(_ORDER_BY_ENTITY_ALIAS);
901 query.append(orderByFields[i]);
902
903 if ((i + 1) < orderByFields.length) {
904 if (orderByComparator.isAscending() ^ previous) {
905 query.append(ORDER_BY_ASC_HAS_NEXT);
906 }
907 else {
908 query.append(ORDER_BY_DESC_HAS_NEXT);
909 }
910 }
911 else {
912 if (orderByComparator.isAscending() ^ previous) {
913 query.append(ORDER_BY_ASC);
914 }
915 else {
916 query.append(ORDER_BY_DESC);
917 }
918 }
919 }
920 }
921
922 String sql = query.toString();
923
924 Query q = session.createQuery(sql);
925
926 q.setFirstResult(0);
927 q.setMaxResults(2);
928
929 QueryPos qPos = QueryPos.getInstance(q);
930
931 qPos.add(recordId);
932
933 if (orderByComparator != null) {
934 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordVersion);
935
936 for (Object value : values) {
937 qPos.add(value);
938 }
939 }
940
941 List<DDLRecordVersion> list = q.list();
942
943 if (list.size() == 2) {
944 return list.get(1);
945 }
946 else {
947 return null;
948 }
949 }
950
951
960 public DDLRecordVersion findByR_V(long recordId, String version)
961 throws NoSuchRecordVersionException, SystemException {
962 DDLRecordVersion ddlRecordVersion = fetchByR_V(recordId, version);
963
964 if (ddlRecordVersion == null) {
965 StringBundler msg = new StringBundler(6);
966
967 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
968
969 msg.append("recordId=");
970 msg.append(recordId);
971
972 msg.append(", version=");
973 msg.append(version);
974
975 msg.append(StringPool.CLOSE_CURLY_BRACE);
976
977 if (_log.isWarnEnabled()) {
978 _log.warn(msg.toString());
979 }
980
981 throw new NoSuchRecordVersionException(msg.toString());
982 }
983
984 return ddlRecordVersion;
985 }
986
987
995 public DDLRecordVersion fetchByR_V(long recordId, String version)
996 throws SystemException {
997 return fetchByR_V(recordId, version, true);
998 }
999
1000
1009 public DDLRecordVersion fetchByR_V(long recordId, String version,
1010 boolean retrieveFromCache) throws SystemException {
1011 Object[] finderArgs = new Object[] { recordId, version };
1012
1013 Object result = null;
1014
1015 if (retrieveFromCache) {
1016 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_V,
1017 finderArgs, this);
1018 }
1019
1020 if (result instanceof DDLRecordVersion) {
1021 DDLRecordVersion ddlRecordVersion = (DDLRecordVersion)result;
1022
1023 if ((recordId != ddlRecordVersion.getRecordId()) ||
1024 !Validator.equals(version, ddlRecordVersion.getVersion())) {
1025 result = null;
1026 }
1027 }
1028
1029 if (result == null) {
1030 StringBundler query = new StringBundler(3);
1031
1032 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
1033
1034 query.append(_FINDER_COLUMN_R_V_RECORDID_2);
1035
1036 if (version == null) {
1037 query.append(_FINDER_COLUMN_R_V_VERSION_1);
1038 }
1039 else {
1040 if (version.equals(StringPool.BLANK)) {
1041 query.append(_FINDER_COLUMN_R_V_VERSION_3);
1042 }
1043 else {
1044 query.append(_FINDER_COLUMN_R_V_VERSION_2);
1045 }
1046 }
1047
1048 String sql = query.toString();
1049
1050 Session session = null;
1051
1052 try {
1053 session = openSession();
1054
1055 Query q = session.createQuery(sql);
1056
1057 QueryPos qPos = QueryPos.getInstance(q);
1058
1059 qPos.add(recordId);
1060
1061 if (version != null) {
1062 qPos.add(version);
1063 }
1064
1065 List<DDLRecordVersion> list = q.list();
1066
1067 result = list;
1068
1069 DDLRecordVersion ddlRecordVersion = null;
1070
1071 if (list.isEmpty()) {
1072 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
1073 finderArgs, list);
1074 }
1075 else {
1076 ddlRecordVersion = list.get(0);
1077
1078 cacheResult(ddlRecordVersion);
1079
1080 if ((ddlRecordVersion.getRecordId() != recordId) ||
1081 (ddlRecordVersion.getVersion() == null) ||
1082 !ddlRecordVersion.getVersion().equals(version)) {
1083 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
1084 finderArgs, ddlRecordVersion);
1085 }
1086 }
1087
1088 return ddlRecordVersion;
1089 }
1090 catch (Exception e) {
1091 throw processException(e);
1092 }
1093 finally {
1094 if (result == null) {
1095 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_V,
1096 finderArgs);
1097 }
1098
1099 closeSession(session);
1100 }
1101 }
1102 else {
1103 if (result instanceof List<?>) {
1104 return null;
1105 }
1106 else {
1107 return (DDLRecordVersion)result;
1108 }
1109 }
1110 }
1111
1112
1120 public List<DDLRecordVersion> findByR_S(long recordId, int status)
1121 throws SystemException {
1122 return findByR_S(recordId, status, QueryUtil.ALL_POS,
1123 QueryUtil.ALL_POS, null);
1124 }
1125
1126
1140 public List<DDLRecordVersion> findByR_S(long recordId, int status,
1141 int start, int end) throws SystemException {
1142 return findByR_S(recordId, status, start, end, null);
1143 }
1144
1145
1160 public List<DDLRecordVersion> findByR_S(long recordId, int status,
1161 int start, int end, OrderByComparator orderByComparator)
1162 throws SystemException {
1163 FinderPath finderPath = null;
1164 Object[] finderArgs = null;
1165
1166 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1167 (orderByComparator == null)) {
1168 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S;
1169 finderArgs = new Object[] { recordId, status };
1170 }
1171 else {
1172 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S;
1173 finderArgs = new Object[] {
1174 recordId, status,
1175
1176 start, end, orderByComparator
1177 };
1178 }
1179
1180 List<DDLRecordVersion> list = (List<DDLRecordVersion>)FinderCacheUtil.getResult(finderPath,
1181 finderArgs, this);
1182
1183 if ((list != null) && !list.isEmpty()) {
1184 for (DDLRecordVersion ddlRecordVersion : list) {
1185 if ((recordId != ddlRecordVersion.getRecordId()) ||
1186 (status != ddlRecordVersion.getStatus())) {
1187 list = null;
1188
1189 break;
1190 }
1191 }
1192 }
1193
1194 if (list == null) {
1195 StringBundler query = null;
1196
1197 if (orderByComparator != null) {
1198 query = new StringBundler(4 +
1199 (orderByComparator.getOrderByFields().length * 3));
1200 }
1201 else {
1202 query = new StringBundler(3);
1203 }
1204
1205 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
1206
1207 query.append(_FINDER_COLUMN_R_S_RECORDID_2);
1208
1209 query.append(_FINDER_COLUMN_R_S_STATUS_2);
1210
1211 if (orderByComparator != null) {
1212 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1213 orderByComparator);
1214 }
1215
1216 String sql = query.toString();
1217
1218 Session session = null;
1219
1220 try {
1221 session = openSession();
1222
1223 Query q = session.createQuery(sql);
1224
1225 QueryPos qPos = QueryPos.getInstance(q);
1226
1227 qPos.add(recordId);
1228
1229 qPos.add(status);
1230
1231 list = (List<DDLRecordVersion>)QueryUtil.list(q, getDialect(),
1232 start, end);
1233 }
1234 catch (Exception e) {
1235 throw processException(e);
1236 }
1237 finally {
1238 if (list == null) {
1239 FinderCacheUtil.removeResult(finderPath, finderArgs);
1240 }
1241 else {
1242 cacheResult(list);
1243
1244 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1245 }
1246
1247 closeSession(session);
1248 }
1249 }
1250
1251 return list;
1252 }
1253
1254
1264 public DDLRecordVersion findByR_S_First(long recordId, int status,
1265 OrderByComparator orderByComparator)
1266 throws NoSuchRecordVersionException, SystemException {
1267 DDLRecordVersion ddlRecordVersion = fetchByR_S_First(recordId, status,
1268 orderByComparator);
1269
1270 if (ddlRecordVersion != null) {
1271 return ddlRecordVersion;
1272 }
1273
1274 StringBundler msg = new StringBundler(6);
1275
1276 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1277
1278 msg.append("recordId=");
1279 msg.append(recordId);
1280
1281 msg.append(", status=");
1282 msg.append(status);
1283
1284 msg.append(StringPool.CLOSE_CURLY_BRACE);
1285
1286 throw new NoSuchRecordVersionException(msg.toString());
1287 }
1288
1289
1298 public DDLRecordVersion fetchByR_S_First(long recordId, int status,
1299 OrderByComparator orderByComparator) throws SystemException {
1300 List<DDLRecordVersion> list = findByR_S(recordId, status, 0, 1,
1301 orderByComparator);
1302
1303 if (!list.isEmpty()) {
1304 return list.get(0);
1305 }
1306
1307 return null;
1308 }
1309
1310
1320 public DDLRecordVersion findByR_S_Last(long recordId, int status,
1321 OrderByComparator orderByComparator)
1322 throws NoSuchRecordVersionException, SystemException {
1323 DDLRecordVersion ddlRecordVersion = fetchByR_S_Last(recordId, status,
1324 orderByComparator);
1325
1326 if (ddlRecordVersion != null) {
1327 return ddlRecordVersion;
1328 }
1329
1330 StringBundler msg = new StringBundler(6);
1331
1332 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1333
1334 msg.append("recordId=");
1335 msg.append(recordId);
1336
1337 msg.append(", status=");
1338 msg.append(status);
1339
1340 msg.append(StringPool.CLOSE_CURLY_BRACE);
1341
1342 throw new NoSuchRecordVersionException(msg.toString());
1343 }
1344
1345
1354 public DDLRecordVersion fetchByR_S_Last(long recordId, int status,
1355 OrderByComparator orderByComparator) throws SystemException {
1356 int count = countByR_S(recordId, status);
1357
1358 List<DDLRecordVersion> list = findByR_S(recordId, status, count - 1,
1359 count, orderByComparator);
1360
1361 if (!list.isEmpty()) {
1362 return list.get(0);
1363 }
1364
1365 return null;
1366 }
1367
1368
1379 public DDLRecordVersion[] findByR_S_PrevAndNext(long recordVersionId,
1380 long recordId, int status, OrderByComparator orderByComparator)
1381 throws NoSuchRecordVersionException, SystemException {
1382 DDLRecordVersion ddlRecordVersion = findByPrimaryKey(recordVersionId);
1383
1384 Session session = null;
1385
1386 try {
1387 session = openSession();
1388
1389 DDLRecordVersion[] array = new DDLRecordVersionImpl[3];
1390
1391 array[0] = getByR_S_PrevAndNext(session, ddlRecordVersion,
1392 recordId, status, orderByComparator, true);
1393
1394 array[1] = ddlRecordVersion;
1395
1396 array[2] = getByR_S_PrevAndNext(session, ddlRecordVersion,
1397 recordId, status, orderByComparator, false);
1398
1399 return array;
1400 }
1401 catch (Exception e) {
1402 throw processException(e);
1403 }
1404 finally {
1405 closeSession(session);
1406 }
1407 }
1408
1409 protected DDLRecordVersion getByR_S_PrevAndNext(Session session,
1410 DDLRecordVersion ddlRecordVersion, long recordId, int status,
1411 OrderByComparator orderByComparator, boolean previous) {
1412 StringBundler query = null;
1413
1414 if (orderByComparator != null) {
1415 query = new StringBundler(6 +
1416 (orderByComparator.getOrderByFields().length * 6));
1417 }
1418 else {
1419 query = new StringBundler(3);
1420 }
1421
1422 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
1423
1424 query.append(_FINDER_COLUMN_R_S_RECORDID_2);
1425
1426 query.append(_FINDER_COLUMN_R_S_STATUS_2);
1427
1428 if (orderByComparator != null) {
1429 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1430
1431 if (orderByConditionFields.length > 0) {
1432 query.append(WHERE_AND);
1433 }
1434
1435 for (int i = 0; i < orderByConditionFields.length; i++) {
1436 query.append(_ORDER_BY_ENTITY_ALIAS);
1437 query.append(orderByConditionFields[i]);
1438
1439 if ((i + 1) < orderByConditionFields.length) {
1440 if (orderByComparator.isAscending() ^ previous) {
1441 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1442 }
1443 else {
1444 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1445 }
1446 }
1447 else {
1448 if (orderByComparator.isAscending() ^ previous) {
1449 query.append(WHERE_GREATER_THAN);
1450 }
1451 else {
1452 query.append(WHERE_LESSER_THAN);
1453 }
1454 }
1455 }
1456
1457 query.append(ORDER_BY_CLAUSE);
1458
1459 String[] orderByFields = orderByComparator.getOrderByFields();
1460
1461 for (int i = 0; i < orderByFields.length; i++) {
1462 query.append(_ORDER_BY_ENTITY_ALIAS);
1463 query.append(orderByFields[i]);
1464
1465 if ((i + 1) < orderByFields.length) {
1466 if (orderByComparator.isAscending() ^ previous) {
1467 query.append(ORDER_BY_ASC_HAS_NEXT);
1468 }
1469 else {
1470 query.append(ORDER_BY_DESC_HAS_NEXT);
1471 }
1472 }
1473 else {
1474 if (orderByComparator.isAscending() ^ previous) {
1475 query.append(ORDER_BY_ASC);
1476 }
1477 else {
1478 query.append(ORDER_BY_DESC);
1479 }
1480 }
1481 }
1482 }
1483
1484 String sql = query.toString();
1485
1486 Query q = session.createQuery(sql);
1487
1488 q.setFirstResult(0);
1489 q.setMaxResults(2);
1490
1491 QueryPos qPos = QueryPos.getInstance(q);
1492
1493 qPos.add(recordId);
1494
1495 qPos.add(status);
1496
1497 if (orderByComparator != null) {
1498 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordVersion);
1499
1500 for (Object value : values) {
1501 qPos.add(value);
1502 }
1503 }
1504
1505 List<DDLRecordVersion> list = q.list();
1506
1507 if (list.size() == 2) {
1508 return list.get(1);
1509 }
1510 else {
1511 return null;
1512 }
1513 }
1514
1515
1521 public List<DDLRecordVersion> findAll() throws SystemException {
1522 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1523 }
1524
1525
1537 public List<DDLRecordVersion> findAll(int start, int end)
1538 throws SystemException {
1539 return findAll(start, end, null);
1540 }
1541
1542
1555 public List<DDLRecordVersion> findAll(int start, int end,
1556 OrderByComparator orderByComparator) throws SystemException {
1557 FinderPath finderPath = null;
1558 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1559
1560 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1561 (orderByComparator == null)) {
1562 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1563 finderArgs = FINDER_ARGS_EMPTY;
1564 }
1565 else {
1566 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1567 finderArgs = new Object[] { start, end, orderByComparator };
1568 }
1569
1570 List<DDLRecordVersion> list = (List<DDLRecordVersion>)FinderCacheUtil.getResult(finderPath,
1571 finderArgs, this);
1572
1573 if (list == null) {
1574 StringBundler query = null;
1575 String sql = null;
1576
1577 if (orderByComparator != null) {
1578 query = new StringBundler(2 +
1579 (orderByComparator.getOrderByFields().length * 3));
1580
1581 query.append(_SQL_SELECT_DDLRECORDVERSION);
1582
1583 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1584 orderByComparator);
1585
1586 sql = query.toString();
1587 }
1588 else {
1589 sql = _SQL_SELECT_DDLRECORDVERSION;
1590 }
1591
1592 Session session = null;
1593
1594 try {
1595 session = openSession();
1596
1597 Query q = session.createQuery(sql);
1598
1599 if (orderByComparator == null) {
1600 list = (List<DDLRecordVersion>)QueryUtil.list(q,
1601 getDialect(), start, end, false);
1602
1603 Collections.sort(list);
1604 }
1605 else {
1606 list = (List<DDLRecordVersion>)QueryUtil.list(q,
1607 getDialect(), start, end);
1608 }
1609 }
1610 catch (Exception e) {
1611 throw processException(e);
1612 }
1613 finally {
1614 if (list == null) {
1615 FinderCacheUtil.removeResult(finderPath, finderArgs);
1616 }
1617 else {
1618 cacheResult(list);
1619
1620 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1621 }
1622
1623 closeSession(session);
1624 }
1625 }
1626
1627 return list;
1628 }
1629
1630
1636 public void removeByRecordId(long recordId) throws SystemException {
1637 for (DDLRecordVersion ddlRecordVersion : findByRecordId(recordId)) {
1638 remove(ddlRecordVersion);
1639 }
1640 }
1641
1642
1650 public DDLRecordVersion removeByR_V(long recordId, String version)
1651 throws NoSuchRecordVersionException, SystemException {
1652 DDLRecordVersion ddlRecordVersion = findByR_V(recordId, version);
1653
1654 return remove(ddlRecordVersion);
1655 }
1656
1657
1664 public void removeByR_S(long recordId, int status)
1665 throws SystemException {
1666 for (DDLRecordVersion ddlRecordVersion : findByR_S(recordId, status)) {
1667 remove(ddlRecordVersion);
1668 }
1669 }
1670
1671
1676 public void removeAll() throws SystemException {
1677 for (DDLRecordVersion ddlRecordVersion : findAll()) {
1678 remove(ddlRecordVersion);
1679 }
1680 }
1681
1682
1689 public int countByRecordId(long recordId) throws SystemException {
1690 Object[] finderArgs = new Object[] { recordId };
1691
1692 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RECORDID,
1693 finderArgs, this);
1694
1695 if (count == null) {
1696 StringBundler query = new StringBundler(2);
1697
1698 query.append(_SQL_COUNT_DDLRECORDVERSION_WHERE);
1699
1700 query.append(_FINDER_COLUMN_RECORDID_RECORDID_2);
1701
1702 String sql = query.toString();
1703
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 Query q = session.createQuery(sql);
1710
1711 QueryPos qPos = QueryPos.getInstance(q);
1712
1713 qPos.add(recordId);
1714
1715 count = (Long)q.uniqueResult();
1716 }
1717 catch (Exception e) {
1718 throw processException(e);
1719 }
1720 finally {
1721 if (count == null) {
1722 count = Long.valueOf(0);
1723 }
1724
1725 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RECORDID,
1726 finderArgs, count);
1727
1728 closeSession(session);
1729 }
1730 }
1731
1732 return count.intValue();
1733 }
1734
1735
1743 public int countByR_V(long recordId, String version)
1744 throws SystemException {
1745 Object[] finderArgs = new Object[] { recordId, version };
1746
1747 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_V,
1748 finderArgs, this);
1749
1750 if (count == null) {
1751 StringBundler query = new StringBundler(3);
1752
1753 query.append(_SQL_COUNT_DDLRECORDVERSION_WHERE);
1754
1755 query.append(_FINDER_COLUMN_R_V_RECORDID_2);
1756
1757 if (version == null) {
1758 query.append(_FINDER_COLUMN_R_V_VERSION_1);
1759 }
1760 else {
1761 if (version.equals(StringPool.BLANK)) {
1762 query.append(_FINDER_COLUMN_R_V_VERSION_3);
1763 }
1764 else {
1765 query.append(_FINDER_COLUMN_R_V_VERSION_2);
1766 }
1767 }
1768
1769 String sql = query.toString();
1770
1771 Session session = null;
1772
1773 try {
1774 session = openSession();
1775
1776 Query q = session.createQuery(sql);
1777
1778 QueryPos qPos = QueryPos.getInstance(q);
1779
1780 qPos.add(recordId);
1781
1782 if (version != null) {
1783 qPos.add(version);
1784 }
1785
1786 count = (Long)q.uniqueResult();
1787 }
1788 catch (Exception e) {
1789 throw processException(e);
1790 }
1791 finally {
1792 if (count == null) {
1793 count = Long.valueOf(0);
1794 }
1795
1796 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_V, finderArgs,
1797 count);
1798
1799 closeSession(session);
1800 }
1801 }
1802
1803 return count.intValue();
1804 }
1805
1806
1814 public int countByR_S(long recordId, int status) throws SystemException {
1815 Object[] finderArgs = new Object[] { recordId, status };
1816
1817 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_S,
1818 finderArgs, this);
1819
1820 if (count == null) {
1821 StringBundler query = new StringBundler(3);
1822
1823 query.append(_SQL_COUNT_DDLRECORDVERSION_WHERE);
1824
1825 query.append(_FINDER_COLUMN_R_S_RECORDID_2);
1826
1827 query.append(_FINDER_COLUMN_R_S_STATUS_2);
1828
1829 String sql = query.toString();
1830
1831 Session session = null;
1832
1833 try {
1834 session = openSession();
1835
1836 Query q = session.createQuery(sql);
1837
1838 QueryPos qPos = QueryPos.getInstance(q);
1839
1840 qPos.add(recordId);
1841
1842 qPos.add(status);
1843
1844 count = (Long)q.uniqueResult();
1845 }
1846 catch (Exception e) {
1847 throw processException(e);
1848 }
1849 finally {
1850 if (count == null) {
1851 count = Long.valueOf(0);
1852 }
1853
1854 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_S, finderArgs,
1855 count);
1856
1857 closeSession(session);
1858 }
1859 }
1860
1861 return count.intValue();
1862 }
1863
1864
1870 public int countAll() throws SystemException {
1871 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1872 FINDER_ARGS_EMPTY, this);
1873
1874 if (count == null) {
1875 Session session = null;
1876
1877 try {
1878 session = openSession();
1879
1880 Query q = session.createQuery(_SQL_COUNT_DDLRECORDVERSION);
1881
1882 count = (Long)q.uniqueResult();
1883 }
1884 catch (Exception e) {
1885 throw processException(e);
1886 }
1887 finally {
1888 if (count == null) {
1889 count = Long.valueOf(0);
1890 }
1891
1892 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1893 FINDER_ARGS_EMPTY, count);
1894
1895 closeSession(session);
1896 }
1897 }
1898
1899 return count.intValue();
1900 }
1901
1902
1905 public void afterPropertiesSet() {
1906 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1907 com.liferay.portal.util.PropsUtil.get(
1908 "value.object.listener.com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion")));
1909
1910 if (listenerClassNames.length > 0) {
1911 try {
1912 List<ModelListener<DDLRecordVersion>> listenersList = new ArrayList<ModelListener<DDLRecordVersion>>();
1913
1914 for (String listenerClassName : listenerClassNames) {
1915 listenersList.add((ModelListener<DDLRecordVersion>)InstanceFactory.newInstance(
1916 listenerClassName));
1917 }
1918
1919 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1920 }
1921 catch (Exception e) {
1922 _log.error(e);
1923 }
1924 }
1925 }
1926
1927 public void destroy() {
1928 EntityCacheUtil.removeCache(DDLRecordVersionImpl.class.getName());
1929 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1930 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1931 }
1932
1933 @BeanReference(type = DDLRecordPersistence.class)
1934 protected DDLRecordPersistence ddlRecordPersistence;
1935 @BeanReference(type = DDLRecordSetPersistence.class)
1936 protected DDLRecordSetPersistence ddlRecordSetPersistence;
1937 @BeanReference(type = DDLRecordVersionPersistence.class)
1938 protected DDLRecordVersionPersistence ddlRecordVersionPersistence;
1939 @BeanReference(type = ResourcePersistence.class)
1940 protected ResourcePersistence resourcePersistence;
1941 @BeanReference(type = UserPersistence.class)
1942 protected UserPersistence userPersistence;
1943 private static final String _SQL_SELECT_DDLRECORDVERSION = "SELECT ddlRecordVersion FROM DDLRecordVersion ddlRecordVersion";
1944 private static final String _SQL_SELECT_DDLRECORDVERSION_WHERE = "SELECT ddlRecordVersion FROM DDLRecordVersion ddlRecordVersion WHERE ";
1945 private static final String _SQL_COUNT_DDLRECORDVERSION = "SELECT COUNT(ddlRecordVersion) FROM DDLRecordVersion ddlRecordVersion";
1946 private static final String _SQL_COUNT_DDLRECORDVERSION_WHERE = "SELECT COUNT(ddlRecordVersion) FROM DDLRecordVersion ddlRecordVersion WHERE ";
1947 private static final String _FINDER_COLUMN_RECORDID_RECORDID_2 = "ddlRecordVersion.recordId = ?";
1948 private static final String _FINDER_COLUMN_R_V_RECORDID_2 = "ddlRecordVersion.recordId = ? AND ";
1949 private static final String _FINDER_COLUMN_R_V_VERSION_1 = "ddlRecordVersion.version IS NULL";
1950 private static final String _FINDER_COLUMN_R_V_VERSION_2 = "ddlRecordVersion.version = ?";
1951 private static final String _FINDER_COLUMN_R_V_VERSION_3 = "(ddlRecordVersion.version IS NULL OR ddlRecordVersion.version = ?)";
1952 private static final String _FINDER_COLUMN_R_S_RECORDID_2 = "ddlRecordVersion.recordId = ? AND ";
1953 private static final String _FINDER_COLUMN_R_S_STATUS_2 = "ddlRecordVersion.status = ?";
1954 private static final String _ORDER_BY_ENTITY_ALIAS = "ddlRecordVersion.";
1955 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDLRecordVersion exists with the primary key ";
1956 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDLRecordVersion exists with the key {";
1957 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1958 private static Log _log = LogFactoryUtil.getLog(DDLRecordVersionPersistenceImpl.class);
1959 private static DDLRecordVersion _nullDDLRecordVersion = new DDLRecordVersionImpl() {
1960 @Override
1961 public Object clone() {
1962 return this;
1963 }
1964
1965 @Override
1966 public CacheModel<DDLRecordVersion> toCacheModel() {
1967 return _nullDDLRecordVersionCacheModel;
1968 }
1969 };
1970
1971 private static CacheModel<DDLRecordVersion> _nullDDLRecordVersionCacheModel = new CacheModel<DDLRecordVersion>() {
1972 public DDLRecordVersion toEntityModel() {
1973 return _nullDDLRecordVersion;
1974 }
1975 };
1976 }