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.model.CacheModel;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.ResourcePersistence;
040 import com.liferay.portal.service.persistence.UserPersistence;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.dynamicdatalists.NoSuchRecordVersionException;
044 import com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion;
045 import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordVersionImpl;
046 import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordVersionModelImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
066 public class DDLRecordVersionPersistenceImpl extends BasePersistenceImpl<DDLRecordVersion>
067 implements DDLRecordVersionPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = DDLRecordVersionImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RECORDID = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
079 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
080 DDLRecordVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
081 "findByRecordId",
082 new String[] {
083 Long.class.getName(),
084
085 "java.lang.Integer", "java.lang.Integer",
086 "com.liferay.portal.kernel.util.OrderByComparator"
087 });
088 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID =
089 new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
090 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
091 DDLRecordVersionImpl.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRecordId",
093 new String[] { Long.class.getName() },
094 DDLRecordVersionModelImpl.RECORDID_COLUMN_BITMASK);
095 public static final FinderPath FINDER_PATH_COUNT_BY_RECORDID = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
096 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRecordId",
098 new String[] { Long.class.getName() });
099 public static final FinderPath FINDER_PATH_FETCH_BY_R_V = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
100 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
101 DDLRecordVersionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByR_V",
102 new String[] { Long.class.getName(), String.class.getName() },
103 DDLRecordVersionModelImpl.RECORDID_COLUMN_BITMASK |
104 DDLRecordVersionModelImpl.VERSION_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_R_V = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
106 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_V",
108 new String[] { Long.class.getName(), String.class.getName() });
109 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
110 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
111 DDLRecordVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
112 "findByR_S",
113 new String[] {
114 Long.class.getName(), Integer.class.getName(),
115
116 "java.lang.Integer", "java.lang.Integer",
117 "com.liferay.portal.kernel.util.OrderByComparator"
118 });
119 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
120 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
121 DDLRecordVersionImpl.class,
122 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByR_S",
123 new String[] { Long.class.getName(), Integer.class.getName() },
124 DDLRecordVersionModelImpl.RECORDID_COLUMN_BITMASK |
125 DDLRecordVersionModelImpl.STATUS_COLUMN_BITMASK);
126 public static final FinderPath FINDER_PATH_COUNT_BY_R_S = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
127 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
128 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_S",
129 new String[] { Long.class.getName(), Integer.class.getName() });
130 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
131 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
132 DDLRecordVersionImpl.class,
133 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
134 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
135 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED,
136 DDLRecordVersionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
137 "findAll", new String[0]);
138 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
139 DDLRecordVersionModelImpl.FINDER_CACHE_ENABLED, Long.class,
140 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
141
142
147 public void cacheResult(DDLRecordVersion ddlRecordVersion) {
148 EntityCacheUtil.putResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
149 DDLRecordVersionImpl.class, ddlRecordVersion.getPrimaryKey(),
150 ddlRecordVersion);
151
152 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
153 new Object[] {
154 Long.valueOf(ddlRecordVersion.getRecordId()),
155
156 ddlRecordVersion.getVersion()
157 }, ddlRecordVersion);
158
159 ddlRecordVersion.resetOriginalValues();
160 }
161
162
167 public void cacheResult(List<DDLRecordVersion> ddlRecordVersions) {
168 for (DDLRecordVersion ddlRecordVersion : ddlRecordVersions) {
169 if (EntityCacheUtil.getResult(
170 DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
171 DDLRecordVersionImpl.class,
172 ddlRecordVersion.getPrimaryKey()) == null) {
173 cacheResult(ddlRecordVersion);
174 }
175 else {
176 ddlRecordVersion.resetOriginalValues();
177 }
178 }
179 }
180
181
188 @Override
189 public void clearCache() {
190 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
191 CacheRegistryUtil.clear(DDLRecordVersionImpl.class.getName());
192 }
193
194 EntityCacheUtil.clearCache(DDLRecordVersionImpl.class.getName());
195
196 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
197 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
198 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
199 }
200
201
208 @Override
209 public void clearCache(DDLRecordVersion ddlRecordVersion) {
210 EntityCacheUtil.removeResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
211 DDLRecordVersionImpl.class, ddlRecordVersion.getPrimaryKey());
212
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
215
216 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_V,
217 new Object[] {
218 Long.valueOf(ddlRecordVersion.getRecordId()),
219
220 ddlRecordVersion.getVersion()
221 });
222 }
223
224
230 public DDLRecordVersion create(long recordVersionId) {
231 DDLRecordVersion ddlRecordVersion = new DDLRecordVersionImpl();
232
233 ddlRecordVersion.setNew(true);
234 ddlRecordVersion.setPrimaryKey(recordVersionId);
235
236 return ddlRecordVersion;
237 }
238
239
247 @Override
248 public DDLRecordVersion remove(Serializable primaryKey)
249 throws NoSuchModelException, SystemException {
250 return remove(((Long)primaryKey).longValue());
251 }
252
253
261 public DDLRecordVersion remove(long recordVersionId)
262 throws NoSuchRecordVersionException, SystemException {
263 Session session = null;
264
265 try {
266 session = openSession();
267
268 DDLRecordVersion ddlRecordVersion = (DDLRecordVersion)session.get(DDLRecordVersionImpl.class,
269 Long.valueOf(recordVersionId));
270
271 if (ddlRecordVersion == null) {
272 if (_log.isWarnEnabled()) {
273 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
274 recordVersionId);
275 }
276
277 throw new NoSuchRecordVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
278 recordVersionId);
279 }
280
281 return ddlRecordVersionPersistence.remove(ddlRecordVersion);
282 }
283 catch (NoSuchRecordVersionException nsee) {
284 throw nsee;
285 }
286 catch (Exception e) {
287 throw processException(e);
288 }
289 finally {
290 closeSession(session);
291 }
292 }
293
294
301 @Override
302 public DDLRecordVersion remove(DDLRecordVersion ddlRecordVersion)
303 throws SystemException {
304 return super.remove(ddlRecordVersion);
305 }
306
307 @Override
308 protected DDLRecordVersion removeImpl(DDLRecordVersion ddlRecordVersion)
309 throws SystemException {
310 ddlRecordVersion = toUnwrappedModel(ddlRecordVersion);
311
312 Session session = null;
313
314 try {
315 session = openSession();
316
317 BatchSessionUtil.delete(session, ddlRecordVersion);
318 }
319 catch (Exception e) {
320 throw processException(e);
321 }
322 finally {
323 closeSession(session);
324 }
325
326 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
327 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
328
329 DDLRecordVersionModelImpl ddlRecordVersionModelImpl = (DDLRecordVersionModelImpl)ddlRecordVersion;
330
331 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_V,
332 new Object[] {
333 Long.valueOf(ddlRecordVersionModelImpl.getRecordId()),
334
335 ddlRecordVersionModelImpl.getVersion()
336 });
337
338 EntityCacheUtil.removeResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
339 DDLRecordVersionImpl.class, ddlRecordVersion.getPrimaryKey());
340
341 return ddlRecordVersion;
342 }
343
344 @Override
345 public DDLRecordVersion updateImpl(
346 com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion ddlRecordVersion,
347 boolean merge) throws SystemException {
348 ddlRecordVersion = toUnwrappedModel(ddlRecordVersion);
349
350 boolean isNew = ddlRecordVersion.isNew();
351
352 DDLRecordVersionModelImpl ddlRecordVersionModelImpl = (DDLRecordVersionModelImpl)ddlRecordVersion;
353
354 Session session = null;
355
356 try {
357 session = openSession();
358
359 BatchSessionUtil.update(session, ddlRecordVersion, merge);
360
361 ddlRecordVersion.setNew(false);
362 }
363 catch (Exception e) {
364 throw processException(e);
365 }
366 finally {
367 closeSession(session);
368 }
369
370 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
371
372 if (isNew || !DDLRecordVersionModelImpl.COLUMN_BITMASK_ENABLED) {
373 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
374 }
375
376 else {
377 if ((ddlRecordVersionModelImpl.getColumnBitmask() &
378 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID.getColumnBitmask()) != 0) {
379 Object[] args = new Object[] {
380 Long.valueOf(ddlRecordVersionModelImpl.getOriginalRecordId())
381 };
382
383 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECORDID, args);
384 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID,
385 args);
386
387 args = new Object[] {
388 Long.valueOf(ddlRecordVersionModelImpl.getRecordId())
389 };
390
391 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECORDID, args);
392 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID,
393 args);
394 }
395
396 if ((ddlRecordVersionModelImpl.getColumnBitmask() &
397 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S.getColumnBitmask()) != 0) {
398 Object[] args = new Object[] {
399 Long.valueOf(ddlRecordVersionModelImpl.getOriginalRecordId()),
400 Integer.valueOf(ddlRecordVersionModelImpl.getOriginalStatus())
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 args = new Object[] {
408 Long.valueOf(ddlRecordVersionModelImpl.getRecordId()),
409 Integer.valueOf(ddlRecordVersionModelImpl.getStatus())
410 };
411
412 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_S, args);
413 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S,
414 args);
415 }
416 }
417
418 EntityCacheUtil.putResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
419 DDLRecordVersionImpl.class, ddlRecordVersion.getPrimaryKey(),
420 ddlRecordVersion);
421
422 if (isNew) {
423 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
424 new Object[] {
425 Long.valueOf(ddlRecordVersion.getRecordId()),
426
427 ddlRecordVersion.getVersion()
428 }, ddlRecordVersion);
429 }
430 else {
431 if ((ddlRecordVersionModelImpl.getColumnBitmask() &
432 FINDER_PATH_FETCH_BY_R_V.getColumnBitmask()) != 0) {
433 Object[] args = new Object[] {
434 Long.valueOf(ddlRecordVersionModelImpl.getOriginalRecordId()),
435
436 ddlRecordVersionModelImpl.getOriginalVersion()
437 };
438
439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_V, args);
440 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_V, args);
441
442 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
443 new Object[] {
444 Long.valueOf(ddlRecordVersion.getRecordId()),
445
446 ddlRecordVersion.getVersion()
447 }, ddlRecordVersion);
448 }
449 }
450
451 return ddlRecordVersion;
452 }
453
454 protected DDLRecordVersion toUnwrappedModel(
455 DDLRecordVersion ddlRecordVersion) {
456 if (ddlRecordVersion instanceof DDLRecordVersionImpl) {
457 return ddlRecordVersion;
458 }
459
460 DDLRecordVersionImpl ddlRecordVersionImpl = new DDLRecordVersionImpl();
461
462 ddlRecordVersionImpl.setNew(ddlRecordVersion.isNew());
463 ddlRecordVersionImpl.setPrimaryKey(ddlRecordVersion.getPrimaryKey());
464
465 ddlRecordVersionImpl.setRecordVersionId(ddlRecordVersion.getRecordVersionId());
466 ddlRecordVersionImpl.setGroupId(ddlRecordVersion.getGroupId());
467 ddlRecordVersionImpl.setCompanyId(ddlRecordVersion.getCompanyId());
468 ddlRecordVersionImpl.setUserId(ddlRecordVersion.getUserId());
469 ddlRecordVersionImpl.setUserName(ddlRecordVersion.getUserName());
470 ddlRecordVersionImpl.setCreateDate(ddlRecordVersion.getCreateDate());
471 ddlRecordVersionImpl.setDDMStorageId(ddlRecordVersion.getDDMStorageId());
472 ddlRecordVersionImpl.setRecordSetId(ddlRecordVersion.getRecordSetId());
473 ddlRecordVersionImpl.setRecordId(ddlRecordVersion.getRecordId());
474 ddlRecordVersionImpl.setVersion(ddlRecordVersion.getVersion());
475 ddlRecordVersionImpl.setDisplayIndex(ddlRecordVersion.getDisplayIndex());
476 ddlRecordVersionImpl.setStatus(ddlRecordVersion.getStatus());
477 ddlRecordVersionImpl.setStatusByUserId(ddlRecordVersion.getStatusByUserId());
478 ddlRecordVersionImpl.setStatusByUserName(ddlRecordVersion.getStatusByUserName());
479 ddlRecordVersionImpl.setStatusDate(ddlRecordVersion.getStatusDate());
480
481 return ddlRecordVersionImpl;
482 }
483
484
492 @Override
493 public DDLRecordVersion findByPrimaryKey(Serializable primaryKey)
494 throws NoSuchModelException, SystemException {
495 return findByPrimaryKey(((Long)primaryKey).longValue());
496 }
497
498
506 public DDLRecordVersion findByPrimaryKey(long recordVersionId)
507 throws NoSuchRecordVersionException, SystemException {
508 DDLRecordVersion ddlRecordVersion = fetchByPrimaryKey(recordVersionId);
509
510 if (ddlRecordVersion == null) {
511 if (_log.isWarnEnabled()) {
512 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + recordVersionId);
513 }
514
515 throw new NoSuchRecordVersionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
516 recordVersionId);
517 }
518
519 return ddlRecordVersion;
520 }
521
522
529 @Override
530 public DDLRecordVersion fetchByPrimaryKey(Serializable primaryKey)
531 throws SystemException {
532 return fetchByPrimaryKey(((Long)primaryKey).longValue());
533 }
534
535
542 public DDLRecordVersion fetchByPrimaryKey(long recordVersionId)
543 throws SystemException {
544 DDLRecordVersion ddlRecordVersion = (DDLRecordVersion)EntityCacheUtil.getResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
545 DDLRecordVersionImpl.class, recordVersionId);
546
547 if (ddlRecordVersion == _nullDDLRecordVersion) {
548 return null;
549 }
550
551 if (ddlRecordVersion == null) {
552 Session session = null;
553
554 boolean hasException = false;
555
556 try {
557 session = openSession();
558
559 ddlRecordVersion = (DDLRecordVersion)session.get(DDLRecordVersionImpl.class,
560 Long.valueOf(recordVersionId));
561 }
562 catch (Exception e) {
563 hasException = true;
564
565 throw processException(e);
566 }
567 finally {
568 if (ddlRecordVersion != null) {
569 cacheResult(ddlRecordVersion);
570 }
571 else if (!hasException) {
572 EntityCacheUtil.putResult(DDLRecordVersionModelImpl.ENTITY_CACHE_ENABLED,
573 DDLRecordVersionImpl.class, recordVersionId,
574 _nullDDLRecordVersion);
575 }
576
577 closeSession(session);
578 }
579 }
580
581 return ddlRecordVersion;
582 }
583
584
591 public List<DDLRecordVersion> findByRecordId(long recordId)
592 throws SystemException {
593 return findByRecordId(recordId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
594 null);
595 }
596
597
610 public List<DDLRecordVersion> findByRecordId(long recordId, int start,
611 int end) throws SystemException {
612 return findByRecordId(recordId, start, end, null);
613 }
614
615
629 public List<DDLRecordVersion> findByRecordId(long recordId, int start,
630 int end, OrderByComparator orderByComparator) throws SystemException {
631 FinderPath finderPath = null;
632 Object[] finderArgs = null;
633
634 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
635 (orderByComparator == null)) {
636 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECORDID;
637 finderArgs = new Object[] { recordId };
638 }
639 else {
640 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RECORDID;
641 finderArgs = new Object[] { recordId, start, end, orderByComparator };
642 }
643
644 List<DDLRecordVersion> list = (List<DDLRecordVersion>)FinderCacheUtil.getResult(finderPath,
645 finderArgs, this);
646
647 if (list == null) {
648 StringBundler query = null;
649
650 if (orderByComparator != null) {
651 query = new StringBundler(3 +
652 (orderByComparator.getOrderByFields().length * 3));
653 }
654 else {
655 query = new StringBundler(2);
656 }
657
658 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
659
660 query.append(_FINDER_COLUMN_RECORDID_RECORDID_2);
661
662 if (orderByComparator != null) {
663 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
664 orderByComparator);
665 }
666
667 String sql = query.toString();
668
669 Session session = null;
670
671 try {
672 session = openSession();
673
674 Query q = session.createQuery(sql);
675
676 QueryPos qPos = QueryPos.getInstance(q);
677
678 qPos.add(recordId);
679
680 list = (List<DDLRecordVersion>)QueryUtil.list(q, getDialect(),
681 start, end);
682 }
683 catch (Exception e) {
684 throw processException(e);
685 }
686 finally {
687 if (list == null) {
688 FinderCacheUtil.removeResult(finderPath, finderArgs);
689 }
690 else {
691 cacheResult(list);
692
693 FinderCacheUtil.putResult(finderPath, finderArgs, list);
694 }
695
696 closeSession(session);
697 }
698 }
699
700 return list;
701 }
702
703
716 public DDLRecordVersion findByRecordId_First(long recordId,
717 OrderByComparator orderByComparator)
718 throws NoSuchRecordVersionException, SystemException {
719 List<DDLRecordVersion> list = findByRecordId(recordId, 0, 1,
720 orderByComparator);
721
722 if (list.isEmpty()) {
723 StringBundler msg = new StringBundler(4);
724
725 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
726
727 msg.append("recordId=");
728 msg.append(recordId);
729
730 msg.append(StringPool.CLOSE_CURLY_BRACE);
731
732 throw new NoSuchRecordVersionException(msg.toString());
733 }
734 else {
735 return list.get(0);
736 }
737 }
738
739
752 public DDLRecordVersion findByRecordId_Last(long recordId,
753 OrderByComparator orderByComparator)
754 throws NoSuchRecordVersionException, SystemException {
755 int count = countByRecordId(recordId);
756
757 List<DDLRecordVersion> list = findByRecordId(recordId, count - 1,
758 count, orderByComparator);
759
760 if (list.isEmpty()) {
761 StringBundler msg = new StringBundler(4);
762
763 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
764
765 msg.append("recordId=");
766 msg.append(recordId);
767
768 msg.append(StringPool.CLOSE_CURLY_BRACE);
769
770 throw new NoSuchRecordVersionException(msg.toString());
771 }
772 else {
773 return list.get(0);
774 }
775 }
776
777
791 public DDLRecordVersion[] findByRecordId_PrevAndNext(long recordVersionId,
792 long recordId, OrderByComparator orderByComparator)
793 throws NoSuchRecordVersionException, SystemException {
794 DDLRecordVersion ddlRecordVersion = findByPrimaryKey(recordVersionId);
795
796 Session session = null;
797
798 try {
799 session = openSession();
800
801 DDLRecordVersion[] array = new DDLRecordVersionImpl[3];
802
803 array[0] = getByRecordId_PrevAndNext(session, ddlRecordVersion,
804 recordId, orderByComparator, true);
805
806 array[1] = ddlRecordVersion;
807
808 array[2] = getByRecordId_PrevAndNext(session, ddlRecordVersion,
809 recordId, orderByComparator, false);
810
811 return array;
812 }
813 catch (Exception e) {
814 throw processException(e);
815 }
816 finally {
817 closeSession(session);
818 }
819 }
820
821 protected DDLRecordVersion getByRecordId_PrevAndNext(Session session,
822 DDLRecordVersion ddlRecordVersion, long recordId,
823 OrderByComparator orderByComparator, boolean previous) {
824 StringBundler query = null;
825
826 if (orderByComparator != null) {
827 query = new StringBundler(6 +
828 (orderByComparator.getOrderByFields().length * 6));
829 }
830 else {
831 query = new StringBundler(3);
832 }
833
834 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
835
836 query.append(_FINDER_COLUMN_RECORDID_RECORDID_2);
837
838 if (orderByComparator != null) {
839 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
840
841 if (orderByConditionFields.length > 0) {
842 query.append(WHERE_AND);
843 }
844
845 for (int i = 0; i < orderByConditionFields.length; i++) {
846 query.append(_ORDER_BY_ENTITY_ALIAS);
847 query.append(orderByConditionFields[i]);
848
849 if ((i + 1) < orderByConditionFields.length) {
850 if (orderByComparator.isAscending() ^ previous) {
851 query.append(WHERE_GREATER_THAN_HAS_NEXT);
852 }
853 else {
854 query.append(WHERE_LESSER_THAN_HAS_NEXT);
855 }
856 }
857 else {
858 if (orderByComparator.isAscending() ^ previous) {
859 query.append(WHERE_GREATER_THAN);
860 }
861 else {
862 query.append(WHERE_LESSER_THAN);
863 }
864 }
865 }
866
867 query.append(ORDER_BY_CLAUSE);
868
869 String[] orderByFields = orderByComparator.getOrderByFields();
870
871 for (int i = 0; i < orderByFields.length; i++) {
872 query.append(_ORDER_BY_ENTITY_ALIAS);
873 query.append(orderByFields[i]);
874
875 if ((i + 1) < orderByFields.length) {
876 if (orderByComparator.isAscending() ^ previous) {
877 query.append(ORDER_BY_ASC_HAS_NEXT);
878 }
879 else {
880 query.append(ORDER_BY_DESC_HAS_NEXT);
881 }
882 }
883 else {
884 if (orderByComparator.isAscending() ^ previous) {
885 query.append(ORDER_BY_ASC);
886 }
887 else {
888 query.append(ORDER_BY_DESC);
889 }
890 }
891 }
892 }
893
894 String sql = query.toString();
895
896 Query q = session.createQuery(sql);
897
898 q.setFirstResult(0);
899 q.setMaxResults(2);
900
901 QueryPos qPos = QueryPos.getInstance(q);
902
903 qPos.add(recordId);
904
905 if (orderByComparator != null) {
906 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordVersion);
907
908 for (Object value : values) {
909 qPos.add(value);
910 }
911 }
912
913 List<DDLRecordVersion> list = q.list();
914
915 if (list.size() == 2) {
916 return list.get(1);
917 }
918 else {
919 return null;
920 }
921 }
922
923
932 public DDLRecordVersion findByR_V(long recordId, String version)
933 throws NoSuchRecordVersionException, SystemException {
934 DDLRecordVersion ddlRecordVersion = fetchByR_V(recordId, version);
935
936 if (ddlRecordVersion == null) {
937 StringBundler msg = new StringBundler(6);
938
939 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
940
941 msg.append("recordId=");
942 msg.append(recordId);
943
944 msg.append(", version=");
945 msg.append(version);
946
947 msg.append(StringPool.CLOSE_CURLY_BRACE);
948
949 if (_log.isWarnEnabled()) {
950 _log.warn(msg.toString());
951 }
952
953 throw new NoSuchRecordVersionException(msg.toString());
954 }
955
956 return ddlRecordVersion;
957 }
958
959
967 public DDLRecordVersion fetchByR_V(long recordId, String version)
968 throws SystemException {
969 return fetchByR_V(recordId, version, true);
970 }
971
972
981 public DDLRecordVersion fetchByR_V(long recordId, String version,
982 boolean retrieveFromCache) throws SystemException {
983 Object[] finderArgs = new Object[] { recordId, version };
984
985 Object result = null;
986
987 if (retrieveFromCache) {
988 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_V,
989 finderArgs, this);
990 }
991
992 if (result == null) {
993 StringBundler query = new StringBundler(3);
994
995 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
996
997 query.append(_FINDER_COLUMN_R_V_RECORDID_2);
998
999 if (version == null) {
1000 query.append(_FINDER_COLUMN_R_V_VERSION_1);
1001 }
1002 else {
1003 if (version.equals(StringPool.BLANK)) {
1004 query.append(_FINDER_COLUMN_R_V_VERSION_3);
1005 }
1006 else {
1007 query.append(_FINDER_COLUMN_R_V_VERSION_2);
1008 }
1009 }
1010
1011 String sql = query.toString();
1012
1013 Session session = null;
1014
1015 try {
1016 session = openSession();
1017
1018 Query q = session.createQuery(sql);
1019
1020 QueryPos qPos = QueryPos.getInstance(q);
1021
1022 qPos.add(recordId);
1023
1024 if (version != null) {
1025 qPos.add(version);
1026 }
1027
1028 List<DDLRecordVersion> list = q.list();
1029
1030 result = list;
1031
1032 DDLRecordVersion ddlRecordVersion = null;
1033
1034 if (list.isEmpty()) {
1035 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
1036 finderArgs, list);
1037 }
1038 else {
1039 ddlRecordVersion = list.get(0);
1040
1041 cacheResult(ddlRecordVersion);
1042
1043 if ((ddlRecordVersion.getRecordId() != recordId) ||
1044 (ddlRecordVersion.getVersion() == null) ||
1045 !ddlRecordVersion.getVersion().equals(version)) {
1046 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_V,
1047 finderArgs, ddlRecordVersion);
1048 }
1049 }
1050
1051 return ddlRecordVersion;
1052 }
1053 catch (Exception e) {
1054 throw processException(e);
1055 }
1056 finally {
1057 if (result == null) {
1058 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_V,
1059 finderArgs);
1060 }
1061
1062 closeSession(session);
1063 }
1064 }
1065 else {
1066 if (result instanceof List<?>) {
1067 return null;
1068 }
1069 else {
1070 return (DDLRecordVersion)result;
1071 }
1072 }
1073 }
1074
1075
1083 public List<DDLRecordVersion> findByR_S(long recordId, int status)
1084 throws SystemException {
1085 return findByR_S(recordId, status, QueryUtil.ALL_POS,
1086 QueryUtil.ALL_POS, null);
1087 }
1088
1089
1103 public List<DDLRecordVersion> findByR_S(long recordId, int status,
1104 int start, int end) throws SystemException {
1105 return findByR_S(recordId, status, start, end, null);
1106 }
1107
1108
1123 public List<DDLRecordVersion> findByR_S(long recordId, int status,
1124 int start, int end, OrderByComparator orderByComparator)
1125 throws SystemException {
1126 FinderPath finderPath = null;
1127 Object[] finderArgs = null;
1128
1129 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1130 (orderByComparator == null)) {
1131 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_R_S;
1132 finderArgs = new Object[] { recordId, status };
1133 }
1134 else {
1135 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_S;
1136 finderArgs = new Object[] {
1137 recordId, status,
1138
1139 start, end, orderByComparator
1140 };
1141 }
1142
1143 List<DDLRecordVersion> list = (List<DDLRecordVersion>)FinderCacheUtil.getResult(finderPath,
1144 finderArgs, this);
1145
1146 if (list == null) {
1147 StringBundler query = null;
1148
1149 if (orderByComparator != null) {
1150 query = new StringBundler(4 +
1151 (orderByComparator.getOrderByFields().length * 3));
1152 }
1153 else {
1154 query = new StringBundler(3);
1155 }
1156
1157 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
1158
1159 query.append(_FINDER_COLUMN_R_S_RECORDID_2);
1160
1161 query.append(_FINDER_COLUMN_R_S_STATUS_2);
1162
1163 if (orderByComparator != null) {
1164 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1165 orderByComparator);
1166 }
1167
1168 String sql = query.toString();
1169
1170 Session session = null;
1171
1172 try {
1173 session = openSession();
1174
1175 Query q = session.createQuery(sql);
1176
1177 QueryPos qPos = QueryPos.getInstance(q);
1178
1179 qPos.add(recordId);
1180
1181 qPos.add(status);
1182
1183 list = (List<DDLRecordVersion>)QueryUtil.list(q, getDialect(),
1184 start, end);
1185 }
1186 catch (Exception e) {
1187 throw processException(e);
1188 }
1189 finally {
1190 if (list == null) {
1191 FinderCacheUtil.removeResult(finderPath, finderArgs);
1192 }
1193 else {
1194 cacheResult(list);
1195
1196 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1197 }
1198
1199 closeSession(session);
1200 }
1201 }
1202
1203 return list;
1204 }
1205
1206
1220 public DDLRecordVersion findByR_S_First(long recordId, int status,
1221 OrderByComparator orderByComparator)
1222 throws NoSuchRecordVersionException, SystemException {
1223 List<DDLRecordVersion> list = findByR_S(recordId, status, 0, 1,
1224 orderByComparator);
1225
1226 if (list.isEmpty()) {
1227 StringBundler msg = new StringBundler(6);
1228
1229 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1230
1231 msg.append("recordId=");
1232 msg.append(recordId);
1233
1234 msg.append(", status=");
1235 msg.append(status);
1236
1237 msg.append(StringPool.CLOSE_CURLY_BRACE);
1238
1239 throw new NoSuchRecordVersionException(msg.toString());
1240 }
1241 else {
1242 return list.get(0);
1243 }
1244 }
1245
1246
1260 public DDLRecordVersion findByR_S_Last(long recordId, int status,
1261 OrderByComparator orderByComparator)
1262 throws NoSuchRecordVersionException, SystemException {
1263 int count = countByR_S(recordId, status);
1264
1265 List<DDLRecordVersion> list = findByR_S(recordId, status, count - 1,
1266 count, orderByComparator);
1267
1268 if (list.isEmpty()) {
1269 StringBundler msg = new StringBundler(6);
1270
1271 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1272
1273 msg.append("recordId=");
1274 msg.append(recordId);
1275
1276 msg.append(", status=");
1277 msg.append(status);
1278
1279 msg.append(StringPool.CLOSE_CURLY_BRACE);
1280
1281 throw new NoSuchRecordVersionException(msg.toString());
1282 }
1283 else {
1284 return list.get(0);
1285 }
1286 }
1287
1288
1303 public DDLRecordVersion[] findByR_S_PrevAndNext(long recordVersionId,
1304 long recordId, int status, OrderByComparator orderByComparator)
1305 throws NoSuchRecordVersionException, SystemException {
1306 DDLRecordVersion ddlRecordVersion = findByPrimaryKey(recordVersionId);
1307
1308 Session session = null;
1309
1310 try {
1311 session = openSession();
1312
1313 DDLRecordVersion[] array = new DDLRecordVersionImpl[3];
1314
1315 array[0] = getByR_S_PrevAndNext(session, ddlRecordVersion,
1316 recordId, status, orderByComparator, true);
1317
1318 array[1] = ddlRecordVersion;
1319
1320 array[2] = getByR_S_PrevAndNext(session, ddlRecordVersion,
1321 recordId, status, orderByComparator, false);
1322
1323 return array;
1324 }
1325 catch (Exception e) {
1326 throw processException(e);
1327 }
1328 finally {
1329 closeSession(session);
1330 }
1331 }
1332
1333 protected DDLRecordVersion getByR_S_PrevAndNext(Session session,
1334 DDLRecordVersion ddlRecordVersion, long recordId, int status,
1335 OrderByComparator orderByComparator, boolean previous) {
1336 StringBundler query = null;
1337
1338 if (orderByComparator != null) {
1339 query = new StringBundler(6 +
1340 (orderByComparator.getOrderByFields().length * 6));
1341 }
1342 else {
1343 query = new StringBundler(3);
1344 }
1345
1346 query.append(_SQL_SELECT_DDLRECORDVERSION_WHERE);
1347
1348 query.append(_FINDER_COLUMN_R_S_RECORDID_2);
1349
1350 query.append(_FINDER_COLUMN_R_S_STATUS_2);
1351
1352 if (orderByComparator != null) {
1353 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1354
1355 if (orderByConditionFields.length > 0) {
1356 query.append(WHERE_AND);
1357 }
1358
1359 for (int i = 0; i < orderByConditionFields.length; i++) {
1360 query.append(_ORDER_BY_ENTITY_ALIAS);
1361 query.append(orderByConditionFields[i]);
1362
1363 if ((i + 1) < orderByConditionFields.length) {
1364 if (orderByComparator.isAscending() ^ previous) {
1365 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1366 }
1367 else {
1368 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1369 }
1370 }
1371 else {
1372 if (orderByComparator.isAscending() ^ previous) {
1373 query.append(WHERE_GREATER_THAN);
1374 }
1375 else {
1376 query.append(WHERE_LESSER_THAN);
1377 }
1378 }
1379 }
1380
1381 query.append(ORDER_BY_CLAUSE);
1382
1383 String[] orderByFields = orderByComparator.getOrderByFields();
1384
1385 for (int i = 0; i < orderByFields.length; i++) {
1386 query.append(_ORDER_BY_ENTITY_ALIAS);
1387 query.append(orderByFields[i]);
1388
1389 if ((i + 1) < orderByFields.length) {
1390 if (orderByComparator.isAscending() ^ previous) {
1391 query.append(ORDER_BY_ASC_HAS_NEXT);
1392 }
1393 else {
1394 query.append(ORDER_BY_DESC_HAS_NEXT);
1395 }
1396 }
1397 else {
1398 if (orderByComparator.isAscending() ^ previous) {
1399 query.append(ORDER_BY_ASC);
1400 }
1401 else {
1402 query.append(ORDER_BY_DESC);
1403 }
1404 }
1405 }
1406 }
1407
1408 String sql = query.toString();
1409
1410 Query q = session.createQuery(sql);
1411
1412 q.setFirstResult(0);
1413 q.setMaxResults(2);
1414
1415 QueryPos qPos = QueryPos.getInstance(q);
1416
1417 qPos.add(recordId);
1418
1419 qPos.add(status);
1420
1421 if (orderByComparator != null) {
1422 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordVersion);
1423
1424 for (Object value : values) {
1425 qPos.add(value);
1426 }
1427 }
1428
1429 List<DDLRecordVersion> list = q.list();
1430
1431 if (list.size() == 2) {
1432 return list.get(1);
1433 }
1434 else {
1435 return null;
1436 }
1437 }
1438
1439
1445 public List<DDLRecordVersion> findAll() throws SystemException {
1446 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1447 }
1448
1449
1461 public List<DDLRecordVersion> findAll(int start, int end)
1462 throws SystemException {
1463 return findAll(start, end, null);
1464 }
1465
1466
1479 public List<DDLRecordVersion> findAll(int start, int end,
1480 OrderByComparator orderByComparator) throws SystemException {
1481 FinderPath finderPath = null;
1482 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1483
1484 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1485 (orderByComparator == null)) {
1486 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1487 finderArgs = FINDER_ARGS_EMPTY;
1488 }
1489 else {
1490 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1491 finderArgs = new Object[] { start, end, orderByComparator };
1492 }
1493
1494 List<DDLRecordVersion> list = (List<DDLRecordVersion>)FinderCacheUtil.getResult(finderPath,
1495 finderArgs, this);
1496
1497 if (list == null) {
1498 StringBundler query = null;
1499 String sql = null;
1500
1501 if (orderByComparator != null) {
1502 query = new StringBundler(2 +
1503 (orderByComparator.getOrderByFields().length * 3));
1504
1505 query.append(_SQL_SELECT_DDLRECORDVERSION);
1506
1507 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1508 orderByComparator);
1509
1510 sql = query.toString();
1511 }
1512 else {
1513 sql = _SQL_SELECT_DDLRECORDVERSION;
1514 }
1515
1516 Session session = null;
1517
1518 try {
1519 session = openSession();
1520
1521 Query q = session.createQuery(sql);
1522
1523 if (orderByComparator == null) {
1524 list = (List<DDLRecordVersion>)QueryUtil.list(q,
1525 getDialect(), start, end, false);
1526
1527 Collections.sort(list);
1528 }
1529 else {
1530 list = (List<DDLRecordVersion>)QueryUtil.list(q,
1531 getDialect(), start, end);
1532 }
1533 }
1534 catch (Exception e) {
1535 throw processException(e);
1536 }
1537 finally {
1538 if (list == null) {
1539 FinderCacheUtil.removeResult(finderPath, finderArgs);
1540 }
1541 else {
1542 cacheResult(list);
1543
1544 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1545 }
1546
1547 closeSession(session);
1548 }
1549 }
1550
1551 return list;
1552 }
1553
1554
1560 public void removeByRecordId(long recordId) throws SystemException {
1561 for (DDLRecordVersion ddlRecordVersion : findByRecordId(recordId)) {
1562 ddlRecordVersionPersistence.remove(ddlRecordVersion);
1563 }
1564 }
1565
1566
1573 public void removeByR_V(long recordId, String version)
1574 throws NoSuchRecordVersionException, SystemException {
1575 DDLRecordVersion ddlRecordVersion = findByR_V(recordId, version);
1576
1577 ddlRecordVersionPersistence.remove(ddlRecordVersion);
1578 }
1579
1580
1587 public void removeByR_S(long recordId, int status)
1588 throws SystemException {
1589 for (DDLRecordVersion ddlRecordVersion : findByR_S(recordId, status)) {
1590 ddlRecordVersionPersistence.remove(ddlRecordVersion);
1591 }
1592 }
1593
1594
1599 public void removeAll() throws SystemException {
1600 for (DDLRecordVersion ddlRecordVersion : findAll()) {
1601 ddlRecordVersionPersistence.remove(ddlRecordVersion);
1602 }
1603 }
1604
1605
1612 public int countByRecordId(long recordId) throws SystemException {
1613 Object[] finderArgs = new Object[] { recordId };
1614
1615 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RECORDID,
1616 finderArgs, this);
1617
1618 if (count == null) {
1619 StringBundler query = new StringBundler(2);
1620
1621 query.append(_SQL_COUNT_DDLRECORDVERSION_WHERE);
1622
1623 query.append(_FINDER_COLUMN_RECORDID_RECORDID_2);
1624
1625 String sql = query.toString();
1626
1627 Session session = null;
1628
1629 try {
1630 session = openSession();
1631
1632 Query q = session.createQuery(sql);
1633
1634 QueryPos qPos = QueryPos.getInstance(q);
1635
1636 qPos.add(recordId);
1637
1638 count = (Long)q.uniqueResult();
1639 }
1640 catch (Exception e) {
1641 throw processException(e);
1642 }
1643 finally {
1644 if (count == null) {
1645 count = Long.valueOf(0);
1646 }
1647
1648 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RECORDID,
1649 finderArgs, count);
1650
1651 closeSession(session);
1652 }
1653 }
1654
1655 return count.intValue();
1656 }
1657
1658
1666 public int countByR_V(long recordId, String version)
1667 throws SystemException {
1668 Object[] finderArgs = new Object[] { recordId, version };
1669
1670 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_V,
1671 finderArgs, this);
1672
1673 if (count == null) {
1674 StringBundler query = new StringBundler(3);
1675
1676 query.append(_SQL_COUNT_DDLRECORDVERSION_WHERE);
1677
1678 query.append(_FINDER_COLUMN_R_V_RECORDID_2);
1679
1680 if (version == null) {
1681 query.append(_FINDER_COLUMN_R_V_VERSION_1);
1682 }
1683 else {
1684 if (version.equals(StringPool.BLANK)) {
1685 query.append(_FINDER_COLUMN_R_V_VERSION_3);
1686 }
1687 else {
1688 query.append(_FINDER_COLUMN_R_V_VERSION_2);
1689 }
1690 }
1691
1692 String sql = query.toString();
1693
1694 Session session = null;
1695
1696 try {
1697 session = openSession();
1698
1699 Query q = session.createQuery(sql);
1700
1701 QueryPos qPos = QueryPos.getInstance(q);
1702
1703 qPos.add(recordId);
1704
1705 if (version != null) {
1706 qPos.add(version);
1707 }
1708
1709 count = (Long)q.uniqueResult();
1710 }
1711 catch (Exception e) {
1712 throw processException(e);
1713 }
1714 finally {
1715 if (count == null) {
1716 count = Long.valueOf(0);
1717 }
1718
1719 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_V, finderArgs,
1720 count);
1721
1722 closeSession(session);
1723 }
1724 }
1725
1726 return count.intValue();
1727 }
1728
1729
1737 public int countByR_S(long recordId, int status) throws SystemException {
1738 Object[] finderArgs = new Object[] { recordId, status };
1739
1740 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_S,
1741 finderArgs, this);
1742
1743 if (count == null) {
1744 StringBundler query = new StringBundler(3);
1745
1746 query.append(_SQL_COUNT_DDLRECORDVERSION_WHERE);
1747
1748 query.append(_FINDER_COLUMN_R_S_RECORDID_2);
1749
1750 query.append(_FINDER_COLUMN_R_S_STATUS_2);
1751
1752 String sql = query.toString();
1753
1754 Session session = null;
1755
1756 try {
1757 session = openSession();
1758
1759 Query q = session.createQuery(sql);
1760
1761 QueryPos qPos = QueryPos.getInstance(q);
1762
1763 qPos.add(recordId);
1764
1765 qPos.add(status);
1766
1767 count = (Long)q.uniqueResult();
1768 }
1769 catch (Exception e) {
1770 throw processException(e);
1771 }
1772 finally {
1773 if (count == null) {
1774 count = Long.valueOf(0);
1775 }
1776
1777 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_S, finderArgs,
1778 count);
1779
1780 closeSession(session);
1781 }
1782 }
1783
1784 return count.intValue();
1785 }
1786
1787
1793 public int countAll() throws SystemException {
1794 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1795 FINDER_ARGS_EMPTY, this);
1796
1797 if (count == null) {
1798 Session session = null;
1799
1800 try {
1801 session = openSession();
1802
1803 Query q = session.createQuery(_SQL_COUNT_DDLRECORDVERSION);
1804
1805 count = (Long)q.uniqueResult();
1806 }
1807 catch (Exception e) {
1808 throw processException(e);
1809 }
1810 finally {
1811 if (count == null) {
1812 count = Long.valueOf(0);
1813 }
1814
1815 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1816 FINDER_ARGS_EMPTY, count);
1817
1818 closeSession(session);
1819 }
1820 }
1821
1822 return count.intValue();
1823 }
1824
1825
1828 public void afterPropertiesSet() {
1829 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1830 com.liferay.portal.util.PropsUtil.get(
1831 "value.object.listener.com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion")));
1832
1833 if (listenerClassNames.length > 0) {
1834 try {
1835 List<ModelListener<DDLRecordVersion>> listenersList = new ArrayList<ModelListener<DDLRecordVersion>>();
1836
1837 for (String listenerClassName : listenerClassNames) {
1838 listenersList.add((ModelListener<DDLRecordVersion>)InstanceFactory.newInstance(
1839 listenerClassName));
1840 }
1841
1842 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1843 }
1844 catch (Exception e) {
1845 _log.error(e);
1846 }
1847 }
1848 }
1849
1850 public void destroy() {
1851 EntityCacheUtil.removeCache(DDLRecordVersionImpl.class.getName());
1852 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1853 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1854 }
1855
1856 @BeanReference(type = DDLRecordPersistence.class)
1857 protected DDLRecordPersistence ddlRecordPersistence;
1858 @BeanReference(type = DDLRecordSetPersistence.class)
1859 protected DDLRecordSetPersistence ddlRecordSetPersistence;
1860 @BeanReference(type = DDLRecordVersionPersistence.class)
1861 protected DDLRecordVersionPersistence ddlRecordVersionPersistence;
1862 @BeanReference(type = ResourcePersistence.class)
1863 protected ResourcePersistence resourcePersistence;
1864 @BeanReference(type = UserPersistence.class)
1865 protected UserPersistence userPersistence;
1866 private static final String _SQL_SELECT_DDLRECORDVERSION = "SELECT ddlRecordVersion FROM DDLRecordVersion ddlRecordVersion";
1867 private static final String _SQL_SELECT_DDLRECORDVERSION_WHERE = "SELECT ddlRecordVersion FROM DDLRecordVersion ddlRecordVersion WHERE ";
1868 private static final String _SQL_COUNT_DDLRECORDVERSION = "SELECT COUNT(ddlRecordVersion) FROM DDLRecordVersion ddlRecordVersion";
1869 private static final String _SQL_COUNT_DDLRECORDVERSION_WHERE = "SELECT COUNT(ddlRecordVersion) FROM DDLRecordVersion ddlRecordVersion WHERE ";
1870 private static final String _FINDER_COLUMN_RECORDID_RECORDID_2 = "ddlRecordVersion.recordId = ?";
1871 private static final String _FINDER_COLUMN_R_V_RECORDID_2 = "ddlRecordVersion.recordId = ? AND ";
1872 private static final String _FINDER_COLUMN_R_V_VERSION_1 = "ddlRecordVersion.version IS NULL";
1873 private static final String _FINDER_COLUMN_R_V_VERSION_2 = "ddlRecordVersion.version = ?";
1874 private static final String _FINDER_COLUMN_R_V_VERSION_3 = "(ddlRecordVersion.version IS NULL OR ddlRecordVersion.version = ?)";
1875 private static final String _FINDER_COLUMN_R_S_RECORDID_2 = "ddlRecordVersion.recordId = ? AND ";
1876 private static final String _FINDER_COLUMN_R_S_STATUS_2 = "ddlRecordVersion.status = ?";
1877 private static final String _ORDER_BY_ENTITY_ALIAS = "ddlRecordVersion.";
1878 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDLRecordVersion exists with the primary key ";
1879 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDLRecordVersion exists with the key {";
1880 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1881 private static Log _log = LogFactoryUtil.getLog(DDLRecordVersionPersistenceImpl.class);
1882 private static DDLRecordVersion _nullDDLRecordVersion = new DDLRecordVersionImpl() {
1883 @Override
1884 public Object clone() {
1885 return this;
1886 }
1887
1888 @Override
1889 public CacheModel<DDLRecordVersion> toCacheModel() {
1890 return _nullDDLRecordVersionCacheModel;
1891 }
1892 };
1893
1894 private static CacheModel<DDLRecordVersion> _nullDDLRecordVersionCacheModel = new CacheModel<DDLRecordVersion>() {
1895 public DDLRecordVersion toEntityModel() {
1896 return _nullDDLRecordVersion;
1897 }
1898 };
1899 }