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.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042 import com.liferay.portal.service.persistence.BatchSessionUtil;
043 import com.liferay.portal.service.persistence.ResourcePersistence;
044 import com.liferay.portal.service.persistence.UserPersistence;
045 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046
047 import com.liferay.portlet.dynamicdatalists.NoSuchRecordSetException;
048 import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
049 import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordSetImpl;
050 import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordSetModelImpl;
051 import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructureLinkPersistence;
052 import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructurePersistence;
053
054 import java.io.Serializable;
055
056 import java.util.ArrayList;
057 import java.util.Collections;
058 import java.util.List;
059
060
072 public class DDLRecordSetPersistenceImpl extends BasePersistenceImpl<DDLRecordSet>
073 implements DDLRecordSetPersistence {
074
079 public static final String FINDER_CLASS_NAME_ENTITY = DDLRecordSetImpl.class.getName();
080 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List1";
082 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083 ".List2";
084 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
085 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
086 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
087 new String[] {
088 String.class.getName(),
089
090 "java.lang.Integer", "java.lang.Integer",
091 "com.liferay.portal.kernel.util.OrderByComparator"
092 });
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
094 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
096 new String[] { String.class.getName() },
097 DDLRecordSetModelImpl.UUID_COLUMN_BITMASK);
098 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
099 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
101 new String[] { String.class.getName() });
102 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
103 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
104 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
105 new String[] { String.class.getName(), Long.class.getName() },
106 DDLRecordSetModelImpl.UUID_COLUMN_BITMASK |
107 DDLRecordSetModelImpl.GROUPID_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
109 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
111 new String[] { String.class.getName(), Long.class.getName() });
112 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
113 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
114 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
115 new String[] {
116 Long.class.getName(),
117
118 "java.lang.Integer", "java.lang.Integer",
119 "com.liferay.portal.kernel.util.OrderByComparator"
120 });
121 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
122 new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
123 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
124 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
125 new String[] { Long.class.getName() },
126 DDLRecordSetModelImpl.GROUPID_COLUMN_BITMASK);
127 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
128 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
129 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
130 new String[] { Long.class.getName() });
131 public static final FinderPath FINDER_PATH_FETCH_BY_G_R = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
132 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
133 FINDER_CLASS_NAME_ENTITY, "fetchByG_R",
134 new String[] { Long.class.getName(), String.class.getName() },
135 DDLRecordSetModelImpl.GROUPID_COLUMN_BITMASK |
136 DDLRecordSetModelImpl.RECORDSETKEY_COLUMN_BITMASK);
137 public static final FinderPath FINDER_PATH_COUNT_BY_G_R = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
138 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
139 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_R",
140 new String[] { Long.class.getName(), String.class.getName() });
141 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
142 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
143 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
144 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
145 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
146 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
147 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
148 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
149 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
150
151
156 public void cacheResult(DDLRecordSet ddlRecordSet) {
157 EntityCacheUtil.putResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
158 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey(), ddlRecordSet);
159
160 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
161 new Object[] {
162 ddlRecordSet.getUuid(), Long.valueOf(ddlRecordSet.getGroupId())
163 }, ddlRecordSet);
164
165 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
166 new Object[] {
167 Long.valueOf(ddlRecordSet.getGroupId()),
168
169 ddlRecordSet.getRecordSetKey()
170 }, ddlRecordSet);
171
172 ddlRecordSet.resetOriginalValues();
173 }
174
175
180 public void cacheResult(List<DDLRecordSet> ddlRecordSets) {
181 for (DDLRecordSet ddlRecordSet : ddlRecordSets) {
182 if (EntityCacheUtil.getResult(
183 DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
184 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey()) == null) {
185 cacheResult(ddlRecordSet);
186 }
187 else {
188 ddlRecordSet.resetOriginalValues();
189 }
190 }
191 }
192
193
200 @Override
201 public void clearCache() {
202 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
203 CacheRegistryUtil.clear(DDLRecordSetImpl.class.getName());
204 }
205
206 EntityCacheUtil.clearCache(DDLRecordSetImpl.class.getName());
207
208 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
209 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
210 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
211 }
212
213
220 @Override
221 public void clearCache(DDLRecordSet ddlRecordSet) {
222 EntityCacheUtil.removeResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
223 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey());
224
225 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
226 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
227
228 clearUniqueFindersCache(ddlRecordSet);
229 }
230
231 @Override
232 public void clearCache(List<DDLRecordSet> ddlRecordSets) {
233 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
234 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
235
236 for (DDLRecordSet ddlRecordSet : ddlRecordSets) {
237 EntityCacheUtil.removeResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
238 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey());
239
240 clearUniqueFindersCache(ddlRecordSet);
241 }
242 }
243
244 protected void clearUniqueFindersCache(DDLRecordSet ddlRecordSet) {
245 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
246 new Object[] {
247 ddlRecordSet.getUuid(), Long.valueOf(ddlRecordSet.getGroupId())
248 });
249
250 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_R,
251 new Object[] {
252 Long.valueOf(ddlRecordSet.getGroupId()),
253
254 ddlRecordSet.getRecordSetKey()
255 });
256 }
257
258
264 public DDLRecordSet create(long recordSetId) {
265 DDLRecordSet ddlRecordSet = new DDLRecordSetImpl();
266
267 ddlRecordSet.setNew(true);
268 ddlRecordSet.setPrimaryKey(recordSetId);
269
270 String uuid = PortalUUIDUtil.generate();
271
272 ddlRecordSet.setUuid(uuid);
273
274 return ddlRecordSet;
275 }
276
277
285 public DDLRecordSet remove(long recordSetId)
286 throws NoSuchRecordSetException, SystemException {
287 return remove(Long.valueOf(recordSetId));
288 }
289
290
298 @Override
299 public DDLRecordSet remove(Serializable primaryKey)
300 throws NoSuchRecordSetException, SystemException {
301 Session session = null;
302
303 try {
304 session = openSession();
305
306 DDLRecordSet ddlRecordSet = (DDLRecordSet)session.get(DDLRecordSetImpl.class,
307 primaryKey);
308
309 if (ddlRecordSet == null) {
310 if (_log.isWarnEnabled()) {
311 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
312 }
313
314 throw new NoSuchRecordSetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
315 primaryKey);
316 }
317
318 return remove(ddlRecordSet);
319 }
320 catch (NoSuchRecordSetException nsee) {
321 throw nsee;
322 }
323 catch (Exception e) {
324 throw processException(e);
325 }
326 finally {
327 closeSession(session);
328 }
329 }
330
331 @Override
332 protected DDLRecordSet removeImpl(DDLRecordSet ddlRecordSet)
333 throws SystemException {
334 ddlRecordSet = toUnwrappedModel(ddlRecordSet);
335
336 Session session = null;
337
338 try {
339 session = openSession();
340
341 BatchSessionUtil.delete(session, ddlRecordSet);
342 }
343 catch (Exception e) {
344 throw processException(e);
345 }
346 finally {
347 closeSession(session);
348 }
349
350 clearCache(ddlRecordSet);
351
352 return ddlRecordSet;
353 }
354
355 @Override
356 public DDLRecordSet updateImpl(
357 com.liferay.portlet.dynamicdatalists.model.DDLRecordSet ddlRecordSet,
358 boolean merge) throws SystemException {
359 ddlRecordSet = toUnwrappedModel(ddlRecordSet);
360
361 boolean isNew = ddlRecordSet.isNew();
362
363 DDLRecordSetModelImpl ddlRecordSetModelImpl = (DDLRecordSetModelImpl)ddlRecordSet;
364
365 if (Validator.isNull(ddlRecordSet.getUuid())) {
366 String uuid = PortalUUIDUtil.generate();
367
368 ddlRecordSet.setUuid(uuid);
369 }
370
371 Session session = null;
372
373 try {
374 session = openSession();
375
376 BatchSessionUtil.update(session, ddlRecordSet, merge);
377
378 ddlRecordSet.setNew(false);
379 }
380 catch (Exception e) {
381 throw processException(e);
382 }
383 finally {
384 closeSession(session);
385 }
386
387 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
388
389 if (isNew || !DDLRecordSetModelImpl.COLUMN_BITMASK_ENABLED) {
390 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
391 }
392
393 else {
394 if ((ddlRecordSetModelImpl.getColumnBitmask() &
395 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
396 Object[] args = new Object[] {
397 ddlRecordSetModelImpl.getOriginalUuid()
398 };
399
400 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
401 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
402 args);
403
404 args = new Object[] { ddlRecordSetModelImpl.getUuid() };
405
406 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
407 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
408 args);
409 }
410
411 if ((ddlRecordSetModelImpl.getColumnBitmask() &
412 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
413 Object[] args = new Object[] {
414 Long.valueOf(ddlRecordSetModelImpl.getOriginalGroupId())
415 };
416
417 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
418 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
419 args);
420
421 args = new Object[] {
422 Long.valueOf(ddlRecordSetModelImpl.getGroupId())
423 };
424
425 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
426 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
427 args);
428 }
429 }
430
431 EntityCacheUtil.putResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
432 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey(), ddlRecordSet);
433
434 if (isNew) {
435 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
436 new Object[] {
437 ddlRecordSet.getUuid(),
438 Long.valueOf(ddlRecordSet.getGroupId())
439 }, ddlRecordSet);
440
441 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
442 new Object[] {
443 Long.valueOf(ddlRecordSet.getGroupId()),
444
445 ddlRecordSet.getRecordSetKey()
446 }, ddlRecordSet);
447 }
448 else {
449 if ((ddlRecordSetModelImpl.getColumnBitmask() &
450 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
451 Object[] args = new Object[] {
452 ddlRecordSetModelImpl.getOriginalUuid(),
453 Long.valueOf(ddlRecordSetModelImpl.getOriginalGroupId())
454 };
455
456 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
457
458 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
459
460 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
461 new Object[] {
462 ddlRecordSet.getUuid(),
463 Long.valueOf(ddlRecordSet.getGroupId())
464 }, ddlRecordSet);
465 }
466
467 if ((ddlRecordSetModelImpl.getColumnBitmask() &
468 FINDER_PATH_FETCH_BY_G_R.getColumnBitmask()) != 0) {
469 Object[] args = new Object[] {
470 Long.valueOf(ddlRecordSetModelImpl.getOriginalGroupId()),
471
472 ddlRecordSetModelImpl.getOriginalRecordSetKey()
473 };
474
475 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
476
477 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_R, args);
478
479 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
480 new Object[] {
481 Long.valueOf(ddlRecordSet.getGroupId()),
482
483 ddlRecordSet.getRecordSetKey()
484 }, ddlRecordSet);
485 }
486 }
487
488 return ddlRecordSet;
489 }
490
491 protected DDLRecordSet toUnwrappedModel(DDLRecordSet ddlRecordSet) {
492 if (ddlRecordSet instanceof DDLRecordSetImpl) {
493 return ddlRecordSet;
494 }
495
496 DDLRecordSetImpl ddlRecordSetImpl = new DDLRecordSetImpl();
497
498 ddlRecordSetImpl.setNew(ddlRecordSet.isNew());
499 ddlRecordSetImpl.setPrimaryKey(ddlRecordSet.getPrimaryKey());
500
501 ddlRecordSetImpl.setUuid(ddlRecordSet.getUuid());
502 ddlRecordSetImpl.setRecordSetId(ddlRecordSet.getRecordSetId());
503 ddlRecordSetImpl.setGroupId(ddlRecordSet.getGroupId());
504 ddlRecordSetImpl.setCompanyId(ddlRecordSet.getCompanyId());
505 ddlRecordSetImpl.setUserId(ddlRecordSet.getUserId());
506 ddlRecordSetImpl.setUserName(ddlRecordSet.getUserName());
507 ddlRecordSetImpl.setCreateDate(ddlRecordSet.getCreateDate());
508 ddlRecordSetImpl.setModifiedDate(ddlRecordSet.getModifiedDate());
509 ddlRecordSetImpl.setDDMStructureId(ddlRecordSet.getDDMStructureId());
510 ddlRecordSetImpl.setRecordSetKey(ddlRecordSet.getRecordSetKey());
511 ddlRecordSetImpl.setName(ddlRecordSet.getName());
512 ddlRecordSetImpl.setDescription(ddlRecordSet.getDescription());
513 ddlRecordSetImpl.setMinDisplayRows(ddlRecordSet.getMinDisplayRows());
514 ddlRecordSetImpl.setScope(ddlRecordSet.getScope());
515
516 return ddlRecordSetImpl;
517 }
518
519
527 @Override
528 public DDLRecordSet findByPrimaryKey(Serializable primaryKey)
529 throws NoSuchModelException, SystemException {
530 return findByPrimaryKey(((Long)primaryKey).longValue());
531 }
532
533
541 public DDLRecordSet findByPrimaryKey(long recordSetId)
542 throws NoSuchRecordSetException, SystemException {
543 DDLRecordSet ddlRecordSet = fetchByPrimaryKey(recordSetId);
544
545 if (ddlRecordSet == null) {
546 if (_log.isWarnEnabled()) {
547 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + recordSetId);
548 }
549
550 throw new NoSuchRecordSetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
551 recordSetId);
552 }
553
554 return ddlRecordSet;
555 }
556
557
564 @Override
565 public DDLRecordSet fetchByPrimaryKey(Serializable primaryKey)
566 throws SystemException {
567 return fetchByPrimaryKey(((Long)primaryKey).longValue());
568 }
569
570
577 public DDLRecordSet fetchByPrimaryKey(long recordSetId)
578 throws SystemException {
579 DDLRecordSet ddlRecordSet = (DDLRecordSet)EntityCacheUtil.getResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
580 DDLRecordSetImpl.class, recordSetId);
581
582 if (ddlRecordSet == _nullDDLRecordSet) {
583 return null;
584 }
585
586 if (ddlRecordSet == null) {
587 Session session = null;
588
589 boolean hasException = false;
590
591 try {
592 session = openSession();
593
594 ddlRecordSet = (DDLRecordSet)session.get(DDLRecordSetImpl.class,
595 Long.valueOf(recordSetId));
596 }
597 catch (Exception e) {
598 hasException = true;
599
600 throw processException(e);
601 }
602 finally {
603 if (ddlRecordSet != null) {
604 cacheResult(ddlRecordSet);
605 }
606 else if (!hasException) {
607 EntityCacheUtil.putResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
608 DDLRecordSetImpl.class, recordSetId, _nullDDLRecordSet);
609 }
610
611 closeSession(session);
612 }
613 }
614
615 return ddlRecordSet;
616 }
617
618
625 public List<DDLRecordSet> findByUuid(String uuid) throws SystemException {
626 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
627 }
628
629
642 public List<DDLRecordSet> findByUuid(String uuid, int start, int end)
643 throws SystemException {
644 return findByUuid(uuid, start, end, null);
645 }
646
647
661 public List<DDLRecordSet> findByUuid(String uuid, int start, int end,
662 OrderByComparator orderByComparator) throws SystemException {
663 FinderPath finderPath = null;
664 Object[] finderArgs = null;
665
666 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
667 (orderByComparator == null)) {
668 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
669 finderArgs = new Object[] { uuid };
670 }
671 else {
672 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
673 finderArgs = new Object[] { uuid, start, end, orderByComparator };
674 }
675
676 List<DDLRecordSet> list = (List<DDLRecordSet>)FinderCacheUtil.getResult(finderPath,
677 finderArgs, this);
678
679 if ((list != null) && !list.isEmpty()) {
680 for (DDLRecordSet ddlRecordSet : list) {
681 if (!Validator.equals(uuid, ddlRecordSet.getUuid())) {
682 list = null;
683
684 break;
685 }
686 }
687 }
688
689 if (list == null) {
690 StringBundler query = null;
691
692 if (orderByComparator != null) {
693 query = new StringBundler(3 +
694 (orderByComparator.getOrderByFields().length * 3));
695 }
696 else {
697 query = new StringBundler(2);
698 }
699
700 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
701
702 if (uuid == null) {
703 query.append(_FINDER_COLUMN_UUID_UUID_1);
704 }
705 else {
706 if (uuid.equals(StringPool.BLANK)) {
707 query.append(_FINDER_COLUMN_UUID_UUID_3);
708 }
709 else {
710 query.append(_FINDER_COLUMN_UUID_UUID_2);
711 }
712 }
713
714 if (orderByComparator != null) {
715 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
716 orderByComparator);
717 }
718
719 String sql = query.toString();
720
721 Session session = null;
722
723 try {
724 session = openSession();
725
726 Query q = session.createQuery(sql);
727
728 QueryPos qPos = QueryPos.getInstance(q);
729
730 if (uuid != null) {
731 qPos.add(uuid);
732 }
733
734 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
735 start, end);
736 }
737 catch (Exception e) {
738 throw processException(e);
739 }
740 finally {
741 if (list == null) {
742 FinderCacheUtil.removeResult(finderPath, finderArgs);
743 }
744 else {
745 cacheResult(list);
746
747 FinderCacheUtil.putResult(finderPath, finderArgs, list);
748 }
749
750 closeSession(session);
751 }
752 }
753
754 return list;
755 }
756
757
766 public DDLRecordSet findByUuid_First(String uuid,
767 OrderByComparator orderByComparator)
768 throws NoSuchRecordSetException, SystemException {
769 DDLRecordSet ddlRecordSet = fetchByUuid_First(uuid, orderByComparator);
770
771 if (ddlRecordSet != null) {
772 return ddlRecordSet;
773 }
774
775 StringBundler msg = new StringBundler(4);
776
777 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
778
779 msg.append("uuid=");
780 msg.append(uuid);
781
782 msg.append(StringPool.CLOSE_CURLY_BRACE);
783
784 throw new NoSuchRecordSetException(msg.toString());
785 }
786
787
795 public DDLRecordSet fetchByUuid_First(String uuid,
796 OrderByComparator orderByComparator) throws SystemException {
797 List<DDLRecordSet> list = findByUuid(uuid, 0, 1, orderByComparator);
798
799 if (!list.isEmpty()) {
800 return list.get(0);
801 }
802
803 return null;
804 }
805
806
815 public DDLRecordSet findByUuid_Last(String uuid,
816 OrderByComparator orderByComparator)
817 throws NoSuchRecordSetException, SystemException {
818 DDLRecordSet ddlRecordSet = fetchByUuid_Last(uuid, orderByComparator);
819
820 if (ddlRecordSet != null) {
821 return ddlRecordSet;
822 }
823
824 StringBundler msg = new StringBundler(4);
825
826 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
827
828 msg.append("uuid=");
829 msg.append(uuid);
830
831 msg.append(StringPool.CLOSE_CURLY_BRACE);
832
833 throw new NoSuchRecordSetException(msg.toString());
834 }
835
836
844 public DDLRecordSet fetchByUuid_Last(String uuid,
845 OrderByComparator orderByComparator) throws SystemException {
846 int count = countByUuid(uuid);
847
848 List<DDLRecordSet> list = findByUuid(uuid, count - 1, count,
849 orderByComparator);
850
851 if (!list.isEmpty()) {
852 return list.get(0);
853 }
854
855 return null;
856 }
857
858
868 public DDLRecordSet[] findByUuid_PrevAndNext(long recordSetId, String uuid,
869 OrderByComparator orderByComparator)
870 throws NoSuchRecordSetException, SystemException {
871 DDLRecordSet ddlRecordSet = findByPrimaryKey(recordSetId);
872
873 Session session = null;
874
875 try {
876 session = openSession();
877
878 DDLRecordSet[] array = new DDLRecordSetImpl[3];
879
880 array[0] = getByUuid_PrevAndNext(session, ddlRecordSet, uuid,
881 orderByComparator, true);
882
883 array[1] = ddlRecordSet;
884
885 array[2] = getByUuid_PrevAndNext(session, ddlRecordSet, uuid,
886 orderByComparator, false);
887
888 return array;
889 }
890 catch (Exception e) {
891 throw processException(e);
892 }
893 finally {
894 closeSession(session);
895 }
896 }
897
898 protected DDLRecordSet getByUuid_PrevAndNext(Session session,
899 DDLRecordSet ddlRecordSet, String uuid,
900 OrderByComparator orderByComparator, boolean previous) {
901 StringBundler query = null;
902
903 if (orderByComparator != null) {
904 query = new StringBundler(6 +
905 (orderByComparator.getOrderByFields().length * 6));
906 }
907 else {
908 query = new StringBundler(3);
909 }
910
911 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
912
913 if (uuid == null) {
914 query.append(_FINDER_COLUMN_UUID_UUID_1);
915 }
916 else {
917 if (uuid.equals(StringPool.BLANK)) {
918 query.append(_FINDER_COLUMN_UUID_UUID_3);
919 }
920 else {
921 query.append(_FINDER_COLUMN_UUID_UUID_2);
922 }
923 }
924
925 if (orderByComparator != null) {
926 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
927
928 if (orderByConditionFields.length > 0) {
929 query.append(WHERE_AND);
930 }
931
932 for (int i = 0; i < orderByConditionFields.length; i++) {
933 query.append(_ORDER_BY_ENTITY_ALIAS);
934 query.append(orderByConditionFields[i]);
935
936 if ((i + 1) < orderByConditionFields.length) {
937 if (orderByComparator.isAscending() ^ previous) {
938 query.append(WHERE_GREATER_THAN_HAS_NEXT);
939 }
940 else {
941 query.append(WHERE_LESSER_THAN_HAS_NEXT);
942 }
943 }
944 else {
945 if (orderByComparator.isAscending() ^ previous) {
946 query.append(WHERE_GREATER_THAN);
947 }
948 else {
949 query.append(WHERE_LESSER_THAN);
950 }
951 }
952 }
953
954 query.append(ORDER_BY_CLAUSE);
955
956 String[] orderByFields = orderByComparator.getOrderByFields();
957
958 for (int i = 0; i < orderByFields.length; i++) {
959 query.append(_ORDER_BY_ENTITY_ALIAS);
960 query.append(orderByFields[i]);
961
962 if ((i + 1) < orderByFields.length) {
963 if (orderByComparator.isAscending() ^ previous) {
964 query.append(ORDER_BY_ASC_HAS_NEXT);
965 }
966 else {
967 query.append(ORDER_BY_DESC_HAS_NEXT);
968 }
969 }
970 else {
971 if (orderByComparator.isAscending() ^ previous) {
972 query.append(ORDER_BY_ASC);
973 }
974 else {
975 query.append(ORDER_BY_DESC);
976 }
977 }
978 }
979 }
980
981 String sql = query.toString();
982
983 Query q = session.createQuery(sql);
984
985 q.setFirstResult(0);
986 q.setMaxResults(2);
987
988 QueryPos qPos = QueryPos.getInstance(q);
989
990 if (uuid != null) {
991 qPos.add(uuid);
992 }
993
994 if (orderByComparator != null) {
995 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordSet);
996
997 for (Object value : values) {
998 qPos.add(value);
999 }
1000 }
1001
1002 List<DDLRecordSet> list = q.list();
1003
1004 if (list.size() == 2) {
1005 return list.get(1);
1006 }
1007 else {
1008 return null;
1009 }
1010 }
1011
1012
1021 public DDLRecordSet findByUUID_G(String uuid, long groupId)
1022 throws NoSuchRecordSetException, SystemException {
1023 DDLRecordSet ddlRecordSet = fetchByUUID_G(uuid, groupId);
1024
1025 if (ddlRecordSet == null) {
1026 StringBundler msg = new StringBundler(6);
1027
1028 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1029
1030 msg.append("uuid=");
1031 msg.append(uuid);
1032
1033 msg.append(", groupId=");
1034 msg.append(groupId);
1035
1036 msg.append(StringPool.CLOSE_CURLY_BRACE);
1037
1038 if (_log.isWarnEnabled()) {
1039 _log.warn(msg.toString());
1040 }
1041
1042 throw new NoSuchRecordSetException(msg.toString());
1043 }
1044
1045 return ddlRecordSet;
1046 }
1047
1048
1056 public DDLRecordSet fetchByUUID_G(String uuid, long groupId)
1057 throws SystemException {
1058 return fetchByUUID_G(uuid, groupId, true);
1059 }
1060
1061
1070 public DDLRecordSet fetchByUUID_G(String uuid, long groupId,
1071 boolean retrieveFromCache) throws SystemException {
1072 Object[] finderArgs = new Object[] { uuid, groupId };
1073
1074 Object result = null;
1075
1076 if (retrieveFromCache) {
1077 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1078 finderArgs, this);
1079 }
1080
1081 if (result instanceof DDLRecordSet) {
1082 DDLRecordSet ddlRecordSet = (DDLRecordSet)result;
1083
1084 if (!Validator.equals(uuid, ddlRecordSet.getUuid()) ||
1085 (groupId != ddlRecordSet.getGroupId())) {
1086 result = null;
1087 }
1088 }
1089
1090 if (result == null) {
1091 StringBundler query = new StringBundler(3);
1092
1093 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1094
1095 if (uuid == null) {
1096 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1097 }
1098 else {
1099 if (uuid.equals(StringPool.BLANK)) {
1100 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1101 }
1102 else {
1103 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1104 }
1105 }
1106
1107 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1108
1109 String sql = query.toString();
1110
1111 Session session = null;
1112
1113 try {
1114 session = openSession();
1115
1116 Query q = session.createQuery(sql);
1117
1118 QueryPos qPos = QueryPos.getInstance(q);
1119
1120 if (uuid != null) {
1121 qPos.add(uuid);
1122 }
1123
1124 qPos.add(groupId);
1125
1126 List<DDLRecordSet> list = q.list();
1127
1128 result = list;
1129
1130 DDLRecordSet ddlRecordSet = null;
1131
1132 if (list.isEmpty()) {
1133 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1134 finderArgs, list);
1135 }
1136 else {
1137 ddlRecordSet = list.get(0);
1138
1139 cacheResult(ddlRecordSet);
1140
1141 if ((ddlRecordSet.getUuid() == null) ||
1142 !ddlRecordSet.getUuid().equals(uuid) ||
1143 (ddlRecordSet.getGroupId() != groupId)) {
1144 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1145 finderArgs, ddlRecordSet);
1146 }
1147 }
1148
1149 return ddlRecordSet;
1150 }
1151 catch (Exception e) {
1152 throw processException(e);
1153 }
1154 finally {
1155 if (result == null) {
1156 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1157 finderArgs);
1158 }
1159
1160 closeSession(session);
1161 }
1162 }
1163 else {
1164 if (result instanceof List<?>) {
1165 return null;
1166 }
1167 else {
1168 return (DDLRecordSet)result;
1169 }
1170 }
1171 }
1172
1173
1180 public List<DDLRecordSet> findByGroupId(long groupId)
1181 throws SystemException {
1182 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1183 }
1184
1185
1198 public List<DDLRecordSet> findByGroupId(long groupId, int start, int end)
1199 throws SystemException {
1200 return findByGroupId(groupId, start, end, null);
1201 }
1202
1203
1217 public List<DDLRecordSet> findByGroupId(long groupId, int start, int end,
1218 OrderByComparator orderByComparator) throws SystemException {
1219 FinderPath finderPath = null;
1220 Object[] finderArgs = null;
1221
1222 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1223 (orderByComparator == null)) {
1224 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1225 finderArgs = new Object[] { groupId };
1226 }
1227 else {
1228 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1229 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1230 }
1231
1232 List<DDLRecordSet> list = (List<DDLRecordSet>)FinderCacheUtil.getResult(finderPath,
1233 finderArgs, this);
1234
1235 if ((list != null) && !list.isEmpty()) {
1236 for (DDLRecordSet ddlRecordSet : list) {
1237 if ((groupId != ddlRecordSet.getGroupId())) {
1238 list = null;
1239
1240 break;
1241 }
1242 }
1243 }
1244
1245 if (list == null) {
1246 StringBundler query = null;
1247
1248 if (orderByComparator != null) {
1249 query = new StringBundler(3 +
1250 (orderByComparator.getOrderByFields().length * 3));
1251 }
1252 else {
1253 query = new StringBundler(2);
1254 }
1255
1256 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1257
1258 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1259
1260 if (orderByComparator != null) {
1261 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1262 orderByComparator);
1263 }
1264
1265 String sql = query.toString();
1266
1267 Session session = null;
1268
1269 try {
1270 session = openSession();
1271
1272 Query q = session.createQuery(sql);
1273
1274 QueryPos qPos = QueryPos.getInstance(q);
1275
1276 qPos.add(groupId);
1277
1278 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
1279 start, end);
1280 }
1281 catch (Exception e) {
1282 throw processException(e);
1283 }
1284 finally {
1285 if (list == null) {
1286 FinderCacheUtil.removeResult(finderPath, finderArgs);
1287 }
1288 else {
1289 cacheResult(list);
1290
1291 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1292 }
1293
1294 closeSession(session);
1295 }
1296 }
1297
1298 return list;
1299 }
1300
1301
1310 public DDLRecordSet findByGroupId_First(long groupId,
1311 OrderByComparator orderByComparator)
1312 throws NoSuchRecordSetException, SystemException {
1313 DDLRecordSet ddlRecordSet = fetchByGroupId_First(groupId,
1314 orderByComparator);
1315
1316 if (ddlRecordSet != null) {
1317 return ddlRecordSet;
1318 }
1319
1320 StringBundler msg = new StringBundler(4);
1321
1322 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1323
1324 msg.append("groupId=");
1325 msg.append(groupId);
1326
1327 msg.append(StringPool.CLOSE_CURLY_BRACE);
1328
1329 throw new NoSuchRecordSetException(msg.toString());
1330 }
1331
1332
1340 public DDLRecordSet fetchByGroupId_First(long groupId,
1341 OrderByComparator orderByComparator) throws SystemException {
1342 List<DDLRecordSet> list = findByGroupId(groupId, 0, 1, orderByComparator);
1343
1344 if (!list.isEmpty()) {
1345 return list.get(0);
1346 }
1347
1348 return null;
1349 }
1350
1351
1360 public DDLRecordSet findByGroupId_Last(long groupId,
1361 OrderByComparator orderByComparator)
1362 throws NoSuchRecordSetException, SystemException {
1363 DDLRecordSet ddlRecordSet = fetchByGroupId_Last(groupId,
1364 orderByComparator);
1365
1366 if (ddlRecordSet != null) {
1367 return ddlRecordSet;
1368 }
1369
1370 StringBundler msg = new StringBundler(4);
1371
1372 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1373
1374 msg.append("groupId=");
1375 msg.append(groupId);
1376
1377 msg.append(StringPool.CLOSE_CURLY_BRACE);
1378
1379 throw new NoSuchRecordSetException(msg.toString());
1380 }
1381
1382
1390 public DDLRecordSet fetchByGroupId_Last(long groupId,
1391 OrderByComparator orderByComparator) throws SystemException {
1392 int count = countByGroupId(groupId);
1393
1394 List<DDLRecordSet> list = findByGroupId(groupId, count - 1, count,
1395 orderByComparator);
1396
1397 if (!list.isEmpty()) {
1398 return list.get(0);
1399 }
1400
1401 return null;
1402 }
1403
1404
1414 public DDLRecordSet[] findByGroupId_PrevAndNext(long recordSetId,
1415 long groupId, OrderByComparator orderByComparator)
1416 throws NoSuchRecordSetException, SystemException {
1417 DDLRecordSet ddlRecordSet = findByPrimaryKey(recordSetId);
1418
1419 Session session = null;
1420
1421 try {
1422 session = openSession();
1423
1424 DDLRecordSet[] array = new DDLRecordSetImpl[3];
1425
1426 array[0] = getByGroupId_PrevAndNext(session, ddlRecordSet, groupId,
1427 orderByComparator, true);
1428
1429 array[1] = ddlRecordSet;
1430
1431 array[2] = getByGroupId_PrevAndNext(session, ddlRecordSet, groupId,
1432 orderByComparator, false);
1433
1434 return array;
1435 }
1436 catch (Exception e) {
1437 throw processException(e);
1438 }
1439 finally {
1440 closeSession(session);
1441 }
1442 }
1443
1444 protected DDLRecordSet getByGroupId_PrevAndNext(Session session,
1445 DDLRecordSet ddlRecordSet, long groupId,
1446 OrderByComparator orderByComparator, boolean previous) {
1447 StringBundler query = null;
1448
1449 if (orderByComparator != null) {
1450 query = new StringBundler(6 +
1451 (orderByComparator.getOrderByFields().length * 6));
1452 }
1453 else {
1454 query = new StringBundler(3);
1455 }
1456
1457 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1458
1459 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1460
1461 if (orderByComparator != null) {
1462 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1463
1464 if (orderByConditionFields.length > 0) {
1465 query.append(WHERE_AND);
1466 }
1467
1468 for (int i = 0; i < orderByConditionFields.length; i++) {
1469 query.append(_ORDER_BY_ENTITY_ALIAS);
1470 query.append(orderByConditionFields[i]);
1471
1472 if ((i + 1) < orderByConditionFields.length) {
1473 if (orderByComparator.isAscending() ^ previous) {
1474 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1475 }
1476 else {
1477 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1478 }
1479 }
1480 else {
1481 if (orderByComparator.isAscending() ^ previous) {
1482 query.append(WHERE_GREATER_THAN);
1483 }
1484 else {
1485 query.append(WHERE_LESSER_THAN);
1486 }
1487 }
1488 }
1489
1490 query.append(ORDER_BY_CLAUSE);
1491
1492 String[] orderByFields = orderByComparator.getOrderByFields();
1493
1494 for (int i = 0; i < orderByFields.length; i++) {
1495 query.append(_ORDER_BY_ENTITY_ALIAS);
1496 query.append(orderByFields[i]);
1497
1498 if ((i + 1) < orderByFields.length) {
1499 if (orderByComparator.isAscending() ^ previous) {
1500 query.append(ORDER_BY_ASC_HAS_NEXT);
1501 }
1502 else {
1503 query.append(ORDER_BY_DESC_HAS_NEXT);
1504 }
1505 }
1506 else {
1507 if (orderByComparator.isAscending() ^ previous) {
1508 query.append(ORDER_BY_ASC);
1509 }
1510 else {
1511 query.append(ORDER_BY_DESC);
1512 }
1513 }
1514 }
1515 }
1516
1517 String sql = query.toString();
1518
1519 Query q = session.createQuery(sql);
1520
1521 q.setFirstResult(0);
1522 q.setMaxResults(2);
1523
1524 QueryPos qPos = QueryPos.getInstance(q);
1525
1526 qPos.add(groupId);
1527
1528 if (orderByComparator != null) {
1529 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordSet);
1530
1531 for (Object value : values) {
1532 qPos.add(value);
1533 }
1534 }
1535
1536 List<DDLRecordSet> list = q.list();
1537
1538 if (list.size() == 2) {
1539 return list.get(1);
1540 }
1541 else {
1542 return null;
1543 }
1544 }
1545
1546
1553 public List<DDLRecordSet> filterFindByGroupId(long groupId)
1554 throws SystemException {
1555 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1556 QueryUtil.ALL_POS, null);
1557 }
1558
1559
1572 public List<DDLRecordSet> filterFindByGroupId(long groupId, int start,
1573 int end) throws SystemException {
1574 return filterFindByGroupId(groupId, start, end, null);
1575 }
1576
1577
1591 public List<DDLRecordSet> filterFindByGroupId(long groupId, int start,
1592 int end, OrderByComparator orderByComparator) throws SystemException {
1593 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1594 return findByGroupId(groupId, start, end, orderByComparator);
1595 }
1596
1597 StringBundler query = null;
1598
1599 if (orderByComparator != null) {
1600 query = new StringBundler(3 +
1601 (orderByComparator.getOrderByFields().length * 3));
1602 }
1603 else {
1604 query = new StringBundler(2);
1605 }
1606
1607 if (getDB().isSupportsInlineDistinct()) {
1608 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_WHERE);
1609 }
1610 else {
1611 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_1);
1612 }
1613
1614 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1615
1616 if (!getDB().isSupportsInlineDistinct()) {
1617 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_2);
1618 }
1619
1620 if (orderByComparator != null) {
1621 if (getDB().isSupportsInlineDistinct()) {
1622 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1623 orderByComparator);
1624 }
1625 else {
1626 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1627 orderByComparator);
1628 }
1629 }
1630
1631 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1632 DDLRecordSet.class.getName(),
1633 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1634
1635 Session session = null;
1636
1637 try {
1638 session = openSession();
1639
1640 SQLQuery q = session.createSQLQuery(sql);
1641
1642 if (getDB().isSupportsInlineDistinct()) {
1643 q.addEntity(_FILTER_ENTITY_ALIAS, DDLRecordSetImpl.class);
1644 }
1645 else {
1646 q.addEntity(_FILTER_ENTITY_TABLE, DDLRecordSetImpl.class);
1647 }
1648
1649 QueryPos qPos = QueryPos.getInstance(q);
1650
1651 qPos.add(groupId);
1652
1653 return (List<DDLRecordSet>)QueryUtil.list(q, getDialect(), start,
1654 end);
1655 }
1656 catch (Exception e) {
1657 throw processException(e);
1658 }
1659 finally {
1660 closeSession(session);
1661 }
1662 }
1663
1664
1674 public DDLRecordSet[] filterFindByGroupId_PrevAndNext(long recordSetId,
1675 long groupId, OrderByComparator orderByComparator)
1676 throws NoSuchRecordSetException, SystemException {
1677 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1678 return findByGroupId_PrevAndNext(recordSetId, groupId,
1679 orderByComparator);
1680 }
1681
1682 DDLRecordSet ddlRecordSet = findByPrimaryKey(recordSetId);
1683
1684 Session session = null;
1685
1686 try {
1687 session = openSession();
1688
1689 DDLRecordSet[] array = new DDLRecordSetImpl[3];
1690
1691 array[0] = filterGetByGroupId_PrevAndNext(session, ddlRecordSet,
1692 groupId, orderByComparator, true);
1693
1694 array[1] = ddlRecordSet;
1695
1696 array[2] = filterGetByGroupId_PrevAndNext(session, ddlRecordSet,
1697 groupId, orderByComparator, false);
1698
1699 return array;
1700 }
1701 catch (Exception e) {
1702 throw processException(e);
1703 }
1704 finally {
1705 closeSession(session);
1706 }
1707 }
1708
1709 protected DDLRecordSet filterGetByGroupId_PrevAndNext(Session session,
1710 DDLRecordSet ddlRecordSet, long groupId,
1711 OrderByComparator orderByComparator, boolean previous) {
1712 StringBundler query = null;
1713
1714 if (orderByComparator != null) {
1715 query = new StringBundler(6 +
1716 (orderByComparator.getOrderByFields().length * 6));
1717 }
1718 else {
1719 query = new StringBundler(3);
1720 }
1721
1722 if (getDB().isSupportsInlineDistinct()) {
1723 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_WHERE);
1724 }
1725 else {
1726 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_1);
1727 }
1728
1729 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1730
1731 if (!getDB().isSupportsInlineDistinct()) {
1732 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_2);
1733 }
1734
1735 if (orderByComparator != null) {
1736 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1737
1738 if (orderByConditionFields.length > 0) {
1739 query.append(WHERE_AND);
1740 }
1741
1742 for (int i = 0; i < orderByConditionFields.length; i++) {
1743 if (getDB().isSupportsInlineDistinct()) {
1744 query.append(_ORDER_BY_ENTITY_ALIAS);
1745 }
1746 else {
1747 query.append(_ORDER_BY_ENTITY_TABLE);
1748 }
1749
1750 query.append(orderByConditionFields[i]);
1751
1752 if ((i + 1) < orderByConditionFields.length) {
1753 if (orderByComparator.isAscending() ^ previous) {
1754 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1755 }
1756 else {
1757 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1758 }
1759 }
1760 else {
1761 if (orderByComparator.isAscending() ^ previous) {
1762 query.append(WHERE_GREATER_THAN);
1763 }
1764 else {
1765 query.append(WHERE_LESSER_THAN);
1766 }
1767 }
1768 }
1769
1770 query.append(ORDER_BY_CLAUSE);
1771
1772 String[] orderByFields = orderByComparator.getOrderByFields();
1773
1774 for (int i = 0; i < orderByFields.length; i++) {
1775 if (getDB().isSupportsInlineDistinct()) {
1776 query.append(_ORDER_BY_ENTITY_ALIAS);
1777 }
1778 else {
1779 query.append(_ORDER_BY_ENTITY_TABLE);
1780 }
1781
1782 query.append(orderByFields[i]);
1783
1784 if ((i + 1) < orderByFields.length) {
1785 if (orderByComparator.isAscending() ^ previous) {
1786 query.append(ORDER_BY_ASC_HAS_NEXT);
1787 }
1788 else {
1789 query.append(ORDER_BY_DESC_HAS_NEXT);
1790 }
1791 }
1792 else {
1793 if (orderByComparator.isAscending() ^ previous) {
1794 query.append(ORDER_BY_ASC);
1795 }
1796 else {
1797 query.append(ORDER_BY_DESC);
1798 }
1799 }
1800 }
1801 }
1802
1803 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1804 DDLRecordSet.class.getName(),
1805 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1806
1807 SQLQuery q = session.createSQLQuery(sql);
1808
1809 q.setFirstResult(0);
1810 q.setMaxResults(2);
1811
1812 if (getDB().isSupportsInlineDistinct()) {
1813 q.addEntity(_FILTER_ENTITY_ALIAS, DDLRecordSetImpl.class);
1814 }
1815 else {
1816 q.addEntity(_FILTER_ENTITY_TABLE, DDLRecordSetImpl.class);
1817 }
1818
1819 QueryPos qPos = QueryPos.getInstance(q);
1820
1821 qPos.add(groupId);
1822
1823 if (orderByComparator != null) {
1824 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordSet);
1825
1826 for (Object value : values) {
1827 qPos.add(value);
1828 }
1829 }
1830
1831 List<DDLRecordSet> list = q.list();
1832
1833 if (list.size() == 2) {
1834 return list.get(1);
1835 }
1836 else {
1837 return null;
1838 }
1839 }
1840
1841
1850 public DDLRecordSet findByG_R(long groupId, String recordSetKey)
1851 throws NoSuchRecordSetException, SystemException {
1852 DDLRecordSet ddlRecordSet = fetchByG_R(groupId, recordSetKey);
1853
1854 if (ddlRecordSet == null) {
1855 StringBundler msg = new StringBundler(6);
1856
1857 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1858
1859 msg.append("groupId=");
1860 msg.append(groupId);
1861
1862 msg.append(", recordSetKey=");
1863 msg.append(recordSetKey);
1864
1865 msg.append(StringPool.CLOSE_CURLY_BRACE);
1866
1867 if (_log.isWarnEnabled()) {
1868 _log.warn(msg.toString());
1869 }
1870
1871 throw new NoSuchRecordSetException(msg.toString());
1872 }
1873
1874 return ddlRecordSet;
1875 }
1876
1877
1885 public DDLRecordSet fetchByG_R(long groupId, String recordSetKey)
1886 throws SystemException {
1887 return fetchByG_R(groupId, recordSetKey, true);
1888 }
1889
1890
1899 public DDLRecordSet fetchByG_R(long groupId, String recordSetKey,
1900 boolean retrieveFromCache) throws SystemException {
1901 Object[] finderArgs = new Object[] { groupId, recordSetKey };
1902
1903 Object result = null;
1904
1905 if (retrieveFromCache) {
1906 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_R,
1907 finderArgs, this);
1908 }
1909
1910 if (result instanceof DDLRecordSet) {
1911 DDLRecordSet ddlRecordSet = (DDLRecordSet)result;
1912
1913 if ((groupId != ddlRecordSet.getGroupId()) ||
1914 !Validator.equals(recordSetKey,
1915 ddlRecordSet.getRecordSetKey())) {
1916 result = null;
1917 }
1918 }
1919
1920 if (result == null) {
1921 StringBundler query = new StringBundler(3);
1922
1923 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1924
1925 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
1926
1927 if (recordSetKey == null) {
1928 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_1);
1929 }
1930 else {
1931 if (recordSetKey.equals(StringPool.BLANK)) {
1932 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_3);
1933 }
1934 else {
1935 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_2);
1936 }
1937 }
1938
1939 String sql = query.toString();
1940
1941 Session session = null;
1942
1943 try {
1944 session = openSession();
1945
1946 Query q = session.createQuery(sql);
1947
1948 QueryPos qPos = QueryPos.getInstance(q);
1949
1950 qPos.add(groupId);
1951
1952 if (recordSetKey != null) {
1953 qPos.add(recordSetKey);
1954 }
1955
1956 List<DDLRecordSet> list = q.list();
1957
1958 result = list;
1959
1960 DDLRecordSet ddlRecordSet = null;
1961
1962 if (list.isEmpty()) {
1963 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
1964 finderArgs, list);
1965 }
1966 else {
1967 ddlRecordSet = list.get(0);
1968
1969 cacheResult(ddlRecordSet);
1970
1971 if ((ddlRecordSet.getGroupId() != groupId) ||
1972 (ddlRecordSet.getRecordSetKey() == null) ||
1973 !ddlRecordSet.getRecordSetKey().equals(recordSetKey)) {
1974 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
1975 finderArgs, ddlRecordSet);
1976 }
1977 }
1978
1979 return ddlRecordSet;
1980 }
1981 catch (Exception e) {
1982 throw processException(e);
1983 }
1984 finally {
1985 if (result == null) {
1986 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_R,
1987 finderArgs);
1988 }
1989
1990 closeSession(session);
1991 }
1992 }
1993 else {
1994 if (result instanceof List<?>) {
1995 return null;
1996 }
1997 else {
1998 return (DDLRecordSet)result;
1999 }
2000 }
2001 }
2002
2003
2009 public List<DDLRecordSet> findAll() throws SystemException {
2010 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2011 }
2012
2013
2025 public List<DDLRecordSet> findAll(int start, int end)
2026 throws SystemException {
2027 return findAll(start, end, null);
2028 }
2029
2030
2043 public List<DDLRecordSet> findAll(int start, int end,
2044 OrderByComparator orderByComparator) throws SystemException {
2045 FinderPath finderPath = null;
2046 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2047
2048 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2049 (orderByComparator == null)) {
2050 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2051 finderArgs = FINDER_ARGS_EMPTY;
2052 }
2053 else {
2054 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2055 finderArgs = new Object[] { start, end, orderByComparator };
2056 }
2057
2058 List<DDLRecordSet> list = (List<DDLRecordSet>)FinderCacheUtil.getResult(finderPath,
2059 finderArgs, this);
2060
2061 if (list == null) {
2062 StringBundler query = null;
2063 String sql = null;
2064
2065 if (orderByComparator != null) {
2066 query = new StringBundler(2 +
2067 (orderByComparator.getOrderByFields().length * 3));
2068
2069 query.append(_SQL_SELECT_DDLRECORDSET);
2070
2071 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2072 orderByComparator);
2073
2074 sql = query.toString();
2075 }
2076 else {
2077 sql = _SQL_SELECT_DDLRECORDSET;
2078 }
2079
2080 Session session = null;
2081
2082 try {
2083 session = openSession();
2084
2085 Query q = session.createQuery(sql);
2086
2087 if (orderByComparator == null) {
2088 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
2089 start, end, false);
2090
2091 Collections.sort(list);
2092 }
2093 else {
2094 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
2095 start, end);
2096 }
2097 }
2098 catch (Exception e) {
2099 throw processException(e);
2100 }
2101 finally {
2102 if (list == null) {
2103 FinderCacheUtil.removeResult(finderPath, finderArgs);
2104 }
2105 else {
2106 cacheResult(list);
2107
2108 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2109 }
2110
2111 closeSession(session);
2112 }
2113 }
2114
2115 return list;
2116 }
2117
2118
2124 public void removeByUuid(String uuid) throws SystemException {
2125 for (DDLRecordSet ddlRecordSet : findByUuid(uuid)) {
2126 remove(ddlRecordSet);
2127 }
2128 }
2129
2130
2138 public DDLRecordSet removeByUUID_G(String uuid, long groupId)
2139 throws NoSuchRecordSetException, SystemException {
2140 DDLRecordSet ddlRecordSet = findByUUID_G(uuid, groupId);
2141
2142 return remove(ddlRecordSet);
2143 }
2144
2145
2151 public void removeByGroupId(long groupId) throws SystemException {
2152 for (DDLRecordSet ddlRecordSet : findByGroupId(groupId)) {
2153 remove(ddlRecordSet);
2154 }
2155 }
2156
2157
2165 public DDLRecordSet removeByG_R(long groupId, String recordSetKey)
2166 throws NoSuchRecordSetException, SystemException {
2167 DDLRecordSet ddlRecordSet = findByG_R(groupId, recordSetKey);
2168
2169 return remove(ddlRecordSet);
2170 }
2171
2172
2177 public void removeAll() throws SystemException {
2178 for (DDLRecordSet ddlRecordSet : findAll()) {
2179 remove(ddlRecordSet);
2180 }
2181 }
2182
2183
2190 public int countByUuid(String uuid) throws SystemException {
2191 Object[] finderArgs = new Object[] { uuid };
2192
2193 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2194 finderArgs, this);
2195
2196 if (count == null) {
2197 StringBundler query = new StringBundler(2);
2198
2199 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
2200
2201 if (uuid == null) {
2202 query.append(_FINDER_COLUMN_UUID_UUID_1);
2203 }
2204 else {
2205 if (uuid.equals(StringPool.BLANK)) {
2206 query.append(_FINDER_COLUMN_UUID_UUID_3);
2207 }
2208 else {
2209 query.append(_FINDER_COLUMN_UUID_UUID_2);
2210 }
2211 }
2212
2213 String sql = query.toString();
2214
2215 Session session = null;
2216
2217 try {
2218 session = openSession();
2219
2220 Query q = session.createQuery(sql);
2221
2222 QueryPos qPos = QueryPos.getInstance(q);
2223
2224 if (uuid != null) {
2225 qPos.add(uuid);
2226 }
2227
2228 count = (Long)q.uniqueResult();
2229 }
2230 catch (Exception e) {
2231 throw processException(e);
2232 }
2233 finally {
2234 if (count == null) {
2235 count = Long.valueOf(0);
2236 }
2237
2238 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2239 finderArgs, count);
2240
2241 closeSession(session);
2242 }
2243 }
2244
2245 return count.intValue();
2246 }
2247
2248
2256 public int countByUUID_G(String uuid, long groupId)
2257 throws SystemException {
2258 Object[] finderArgs = new Object[] { uuid, groupId };
2259
2260 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2261 finderArgs, this);
2262
2263 if (count == null) {
2264 StringBundler query = new StringBundler(3);
2265
2266 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
2267
2268 if (uuid == null) {
2269 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2270 }
2271 else {
2272 if (uuid.equals(StringPool.BLANK)) {
2273 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2274 }
2275 else {
2276 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2277 }
2278 }
2279
2280 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2281
2282 String sql = query.toString();
2283
2284 Session session = null;
2285
2286 try {
2287 session = openSession();
2288
2289 Query q = session.createQuery(sql);
2290
2291 QueryPos qPos = QueryPos.getInstance(q);
2292
2293 if (uuid != null) {
2294 qPos.add(uuid);
2295 }
2296
2297 qPos.add(groupId);
2298
2299 count = (Long)q.uniqueResult();
2300 }
2301 catch (Exception e) {
2302 throw processException(e);
2303 }
2304 finally {
2305 if (count == null) {
2306 count = Long.valueOf(0);
2307 }
2308
2309 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2310 finderArgs, count);
2311
2312 closeSession(session);
2313 }
2314 }
2315
2316 return count.intValue();
2317 }
2318
2319
2326 public int countByGroupId(long groupId) throws SystemException {
2327 Object[] finderArgs = new Object[] { groupId };
2328
2329 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2330 finderArgs, this);
2331
2332 if (count == null) {
2333 StringBundler query = new StringBundler(2);
2334
2335 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
2336
2337 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2338
2339 String sql = query.toString();
2340
2341 Session session = null;
2342
2343 try {
2344 session = openSession();
2345
2346 Query q = session.createQuery(sql);
2347
2348 QueryPos qPos = QueryPos.getInstance(q);
2349
2350 qPos.add(groupId);
2351
2352 count = (Long)q.uniqueResult();
2353 }
2354 catch (Exception e) {
2355 throw processException(e);
2356 }
2357 finally {
2358 if (count == null) {
2359 count = Long.valueOf(0);
2360 }
2361
2362 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2363 finderArgs, count);
2364
2365 closeSession(session);
2366 }
2367 }
2368
2369 return count.intValue();
2370 }
2371
2372
2379 public int filterCountByGroupId(long groupId) throws SystemException {
2380 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2381 return countByGroupId(groupId);
2382 }
2383
2384 StringBundler query = new StringBundler(2);
2385
2386 query.append(_FILTER_SQL_COUNT_DDLRECORDSET_WHERE);
2387
2388 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2389
2390 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2391 DDLRecordSet.class.getName(),
2392 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2393
2394 Session session = null;
2395
2396 try {
2397 session = openSession();
2398
2399 SQLQuery q = session.createSQLQuery(sql);
2400
2401 q.addScalar(COUNT_COLUMN_NAME,
2402 com.liferay.portal.kernel.dao.orm.Type.LONG);
2403
2404 QueryPos qPos = QueryPos.getInstance(q);
2405
2406 qPos.add(groupId);
2407
2408 Long count = (Long)q.uniqueResult();
2409
2410 return count.intValue();
2411 }
2412 catch (Exception e) {
2413 throw processException(e);
2414 }
2415 finally {
2416 closeSession(session);
2417 }
2418 }
2419
2420
2428 public int countByG_R(long groupId, String recordSetKey)
2429 throws SystemException {
2430 Object[] finderArgs = new Object[] { groupId, recordSetKey };
2431
2432 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
2433 finderArgs, this);
2434
2435 if (count == null) {
2436 StringBundler query = new StringBundler(3);
2437
2438 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
2439
2440 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2441
2442 if (recordSetKey == null) {
2443 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_1);
2444 }
2445 else {
2446 if (recordSetKey.equals(StringPool.BLANK)) {
2447 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_3);
2448 }
2449 else {
2450 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_2);
2451 }
2452 }
2453
2454 String sql = query.toString();
2455
2456 Session session = null;
2457
2458 try {
2459 session = openSession();
2460
2461 Query q = session.createQuery(sql);
2462
2463 QueryPos qPos = QueryPos.getInstance(q);
2464
2465 qPos.add(groupId);
2466
2467 if (recordSetKey != null) {
2468 qPos.add(recordSetKey);
2469 }
2470
2471 count = (Long)q.uniqueResult();
2472 }
2473 catch (Exception e) {
2474 throw processException(e);
2475 }
2476 finally {
2477 if (count == null) {
2478 count = Long.valueOf(0);
2479 }
2480
2481 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
2482 count);
2483
2484 closeSession(session);
2485 }
2486 }
2487
2488 return count.intValue();
2489 }
2490
2491
2497 public int countAll() throws SystemException {
2498 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2499 FINDER_ARGS_EMPTY, this);
2500
2501 if (count == null) {
2502 Session session = null;
2503
2504 try {
2505 session = openSession();
2506
2507 Query q = session.createQuery(_SQL_COUNT_DDLRECORDSET);
2508
2509 count = (Long)q.uniqueResult();
2510 }
2511 catch (Exception e) {
2512 throw processException(e);
2513 }
2514 finally {
2515 if (count == null) {
2516 count = Long.valueOf(0);
2517 }
2518
2519 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2520 FINDER_ARGS_EMPTY, count);
2521
2522 closeSession(session);
2523 }
2524 }
2525
2526 return count.intValue();
2527 }
2528
2529
2532 public void afterPropertiesSet() {
2533 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2534 com.liferay.portal.util.PropsUtil.get(
2535 "value.object.listener.com.liferay.portlet.dynamicdatalists.model.DDLRecordSet")));
2536
2537 if (listenerClassNames.length > 0) {
2538 try {
2539 List<ModelListener<DDLRecordSet>> listenersList = new ArrayList<ModelListener<DDLRecordSet>>();
2540
2541 for (String listenerClassName : listenerClassNames) {
2542 listenersList.add((ModelListener<DDLRecordSet>)InstanceFactory.newInstance(
2543 listenerClassName));
2544 }
2545
2546 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2547 }
2548 catch (Exception e) {
2549 _log.error(e);
2550 }
2551 }
2552 }
2553
2554 public void destroy() {
2555 EntityCacheUtil.removeCache(DDLRecordSetImpl.class.getName());
2556 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2557 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2558 }
2559
2560 @BeanReference(type = DDLRecordPersistence.class)
2561 protected DDLRecordPersistence ddlRecordPersistence;
2562 @BeanReference(type = DDLRecordSetPersistence.class)
2563 protected DDLRecordSetPersistence ddlRecordSetPersistence;
2564 @BeanReference(type = DDLRecordVersionPersistence.class)
2565 protected DDLRecordVersionPersistence ddlRecordVersionPersistence;
2566 @BeanReference(type = ResourcePersistence.class)
2567 protected ResourcePersistence resourcePersistence;
2568 @BeanReference(type = UserPersistence.class)
2569 protected UserPersistence userPersistence;
2570 @BeanReference(type = DDMStructurePersistence.class)
2571 protected DDMStructurePersistence ddmStructurePersistence;
2572 @BeanReference(type = DDMStructureLinkPersistence.class)
2573 protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
2574 private static final String _SQL_SELECT_DDLRECORDSET = "SELECT ddlRecordSet FROM DDLRecordSet ddlRecordSet";
2575 private static final String _SQL_SELECT_DDLRECORDSET_WHERE = "SELECT ddlRecordSet FROM DDLRecordSet ddlRecordSet WHERE ";
2576 private static final String _SQL_COUNT_DDLRECORDSET = "SELECT COUNT(ddlRecordSet) FROM DDLRecordSet ddlRecordSet";
2577 private static final String _SQL_COUNT_DDLRECORDSET_WHERE = "SELECT COUNT(ddlRecordSet) FROM DDLRecordSet ddlRecordSet WHERE ";
2578 private static final String _FINDER_COLUMN_UUID_UUID_1 = "ddlRecordSet.uuid IS NULL";
2579 private static final String _FINDER_COLUMN_UUID_UUID_2 = "ddlRecordSet.uuid = ?";
2580 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ddlRecordSet.uuid IS NULL OR ddlRecordSet.uuid = ?)";
2581 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "ddlRecordSet.uuid IS NULL AND ";
2582 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "ddlRecordSet.uuid = ? AND ";
2583 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(ddlRecordSet.uuid IS NULL OR ddlRecordSet.uuid = ?) AND ";
2584 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "ddlRecordSet.groupId = ?";
2585 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "ddlRecordSet.groupId = ?";
2586 private static final String _FINDER_COLUMN_G_R_GROUPID_2 = "ddlRecordSet.groupId = ? AND ";
2587 private static final String _FINDER_COLUMN_G_R_RECORDSETKEY_1 = "ddlRecordSet.recordSetKey IS NULL";
2588 private static final String _FINDER_COLUMN_G_R_RECORDSETKEY_2 = "ddlRecordSet.recordSetKey = ?";
2589 private static final String _FINDER_COLUMN_G_R_RECORDSETKEY_3 = "(ddlRecordSet.recordSetKey IS NULL OR ddlRecordSet.recordSetKey = ?)";
2590 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "ddlRecordSet.recordSetId";
2591 private static final String _FILTER_SQL_SELECT_DDLRECORDSET_WHERE = "SELECT DISTINCT {ddlRecordSet.*} FROM DDLRecordSet ddlRecordSet WHERE ";
2592 private static final String _FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_1 =
2593 "SELECT {DDLRecordSet.*} FROM (SELECT DISTINCT ddlRecordSet.recordSetId FROM DDLRecordSet ddlRecordSet WHERE ";
2594 private static final String _FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_2 =
2595 ") TEMP_TABLE INNER JOIN DDLRecordSet ON TEMP_TABLE.recordSetId = DDLRecordSet.recordSetId";
2596 private static final String _FILTER_SQL_COUNT_DDLRECORDSET_WHERE = "SELECT COUNT(DISTINCT ddlRecordSet.recordSetId) AS COUNT_VALUE FROM DDLRecordSet ddlRecordSet WHERE ";
2597 private static final String _FILTER_ENTITY_ALIAS = "ddlRecordSet";
2598 private static final String _FILTER_ENTITY_TABLE = "DDLRecordSet";
2599 private static final String _ORDER_BY_ENTITY_ALIAS = "ddlRecordSet.";
2600 private static final String _ORDER_BY_ENTITY_TABLE = "DDLRecordSet.";
2601 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDLRecordSet exists with the primary key ";
2602 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDLRecordSet exists with the key {";
2603 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2604 private static Log _log = LogFactoryUtil.getLog(DDLRecordSetPersistenceImpl.class);
2605 private static DDLRecordSet _nullDDLRecordSet = new DDLRecordSetImpl() {
2606 @Override
2607 public Object clone() {
2608 return this;
2609 }
2610
2611 @Override
2612 public CacheModel<DDLRecordSet> toCacheModel() {
2613 return _nullDDLRecordSetCacheModel;
2614 }
2615 };
2616
2617 private static CacheModel<DDLRecordSet> _nullDDLRecordSetCacheModel = new CacheModel<DDLRecordSet>() {
2618 public DDLRecordSet toEntityModel() {
2619 return _nullDDLRecordSet;
2620 }
2621 };
2622 }