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.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.dynamicdatalists.NoSuchRecordSetException;
046 import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
047 import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordSetImpl;
048 import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordSetModelImpl;
049 import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructureLinkPersistence;
050 import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructurePersistence;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057
058
070 public class DDLRecordSetPersistenceImpl extends BasePersistenceImpl<DDLRecordSet>
071 implements DDLRecordSetPersistence {
072
077 public static final String FINDER_CLASS_NAME_ENTITY = DDLRecordSetImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List1";
080 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List2";
082 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
083 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
084 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
085 new String[] {
086 String.class.getName(),
087
088 "java.lang.Integer", "java.lang.Integer",
089 "com.liferay.portal.kernel.util.OrderByComparator"
090 });
091 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
092 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
094 new String[] { String.class.getName() },
095 DDLRecordSetModelImpl.UUID_COLUMN_BITMASK);
096 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
097 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
099 new String[] { String.class.getName() });
100 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
101 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
102 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
103 new String[] { String.class.getName(), Long.class.getName() },
104 DDLRecordSetModelImpl.UUID_COLUMN_BITMASK |
105 DDLRecordSetModelImpl.GROUPID_COLUMN_BITMASK);
106 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
107 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
109 new String[] { String.class.getName(), Long.class.getName() });
110 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
111 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
112 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
113 new String[] {
114 String.class.getName(), Long.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_UUID_C =
120 new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
121 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
122 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
123 new String[] { String.class.getName(), Long.class.getName() },
124 DDLRecordSetModelImpl.UUID_COLUMN_BITMASK |
125 DDLRecordSetModelImpl.COMPANYID_COLUMN_BITMASK);
126 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
127 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
128 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
129 new String[] { String.class.getName(), Long.class.getName() });
130 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
131 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
132 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
133 new String[] {
134 Long.class.getName(),
135
136 "java.lang.Integer", "java.lang.Integer",
137 "com.liferay.portal.kernel.util.OrderByComparator"
138 });
139 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
140 new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
141 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
142 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
143 new String[] { Long.class.getName() },
144 DDLRecordSetModelImpl.GROUPID_COLUMN_BITMASK);
145 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
146 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
147 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
148 new String[] { Long.class.getName() });
149 public static final FinderPath FINDER_PATH_FETCH_BY_G_R = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
150 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
151 FINDER_CLASS_NAME_ENTITY, "fetchByG_R",
152 new String[] { Long.class.getName(), String.class.getName() },
153 DDLRecordSetModelImpl.GROUPID_COLUMN_BITMASK |
154 DDLRecordSetModelImpl.RECORDSETKEY_COLUMN_BITMASK);
155 public static final FinderPath FINDER_PATH_COUNT_BY_G_R = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
156 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_R",
158 new String[] { Long.class.getName(), String.class.getName() });
159 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
160 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
161 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
162 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
163 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, DDLRecordSetImpl.class,
164 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
165 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
166 DDLRecordSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
167 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
168
169
174 public void cacheResult(DDLRecordSet ddlRecordSet) {
175 EntityCacheUtil.putResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
176 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey(), ddlRecordSet);
177
178 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
179 new Object[] {
180 ddlRecordSet.getUuid(), Long.valueOf(ddlRecordSet.getGroupId())
181 }, ddlRecordSet);
182
183 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
184 new Object[] {
185 Long.valueOf(ddlRecordSet.getGroupId()),
186
187 ddlRecordSet.getRecordSetKey()
188 }, ddlRecordSet);
189
190 ddlRecordSet.resetOriginalValues();
191 }
192
193
198 public void cacheResult(List<DDLRecordSet> ddlRecordSets) {
199 for (DDLRecordSet ddlRecordSet : ddlRecordSets) {
200 if (EntityCacheUtil.getResult(
201 DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
202 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey()) == null) {
203 cacheResult(ddlRecordSet);
204 }
205 else {
206 ddlRecordSet.resetOriginalValues();
207 }
208 }
209 }
210
211
218 @Override
219 public void clearCache() {
220 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
221 CacheRegistryUtil.clear(DDLRecordSetImpl.class.getName());
222 }
223
224 EntityCacheUtil.clearCache(DDLRecordSetImpl.class.getName());
225
226 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
227 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
228 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
229 }
230
231
238 @Override
239 public void clearCache(DDLRecordSet ddlRecordSet) {
240 EntityCacheUtil.removeResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
241 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey());
242
243 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
244 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
245
246 clearUniqueFindersCache(ddlRecordSet);
247 }
248
249 @Override
250 public void clearCache(List<DDLRecordSet> ddlRecordSets) {
251 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
252 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
253
254 for (DDLRecordSet ddlRecordSet : ddlRecordSets) {
255 EntityCacheUtil.removeResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
256 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey());
257
258 clearUniqueFindersCache(ddlRecordSet);
259 }
260 }
261
262 protected void clearUniqueFindersCache(DDLRecordSet ddlRecordSet) {
263 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
264 new Object[] {
265 ddlRecordSet.getUuid(), Long.valueOf(ddlRecordSet.getGroupId())
266 });
267
268 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_R,
269 new Object[] {
270 Long.valueOf(ddlRecordSet.getGroupId()),
271
272 ddlRecordSet.getRecordSetKey()
273 });
274 }
275
276
282 public DDLRecordSet create(long recordSetId) {
283 DDLRecordSet ddlRecordSet = new DDLRecordSetImpl();
284
285 ddlRecordSet.setNew(true);
286 ddlRecordSet.setPrimaryKey(recordSetId);
287
288 String uuid = PortalUUIDUtil.generate();
289
290 ddlRecordSet.setUuid(uuid);
291
292 return ddlRecordSet;
293 }
294
295
303 public DDLRecordSet remove(long recordSetId)
304 throws NoSuchRecordSetException, SystemException {
305 return remove(Long.valueOf(recordSetId));
306 }
307
308
316 @Override
317 public DDLRecordSet remove(Serializable primaryKey)
318 throws NoSuchRecordSetException, SystemException {
319 Session session = null;
320
321 try {
322 session = openSession();
323
324 DDLRecordSet ddlRecordSet = (DDLRecordSet)session.get(DDLRecordSetImpl.class,
325 primaryKey);
326
327 if (ddlRecordSet == null) {
328 if (_log.isWarnEnabled()) {
329 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
330 }
331
332 throw new NoSuchRecordSetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
333 primaryKey);
334 }
335
336 return remove(ddlRecordSet);
337 }
338 catch (NoSuchRecordSetException nsee) {
339 throw nsee;
340 }
341 catch (Exception e) {
342 throw processException(e);
343 }
344 finally {
345 closeSession(session);
346 }
347 }
348
349 @Override
350 protected DDLRecordSet removeImpl(DDLRecordSet ddlRecordSet)
351 throws SystemException {
352 ddlRecordSet = toUnwrappedModel(ddlRecordSet);
353
354 Session session = null;
355
356 try {
357 session = openSession();
358
359 if (ddlRecordSet.isCachedModel()) {
360 ddlRecordSet = (DDLRecordSet)session.get(DDLRecordSetImpl.class,
361 ddlRecordSet.getPrimaryKeyObj());
362 }
363
364 session.delete(ddlRecordSet);
365 }
366 catch (Exception e) {
367 throw processException(e);
368 }
369 finally {
370 closeSession(session);
371 }
372
373 clearCache(ddlRecordSet);
374
375 return ddlRecordSet;
376 }
377
378 @Override
379 public DDLRecordSet updateImpl(
380 com.liferay.portlet.dynamicdatalists.model.DDLRecordSet ddlRecordSet)
381 throws SystemException {
382 ddlRecordSet = toUnwrappedModel(ddlRecordSet);
383
384 boolean isNew = ddlRecordSet.isNew();
385
386 DDLRecordSetModelImpl ddlRecordSetModelImpl = (DDLRecordSetModelImpl)ddlRecordSet;
387
388 if (Validator.isNull(ddlRecordSet.getUuid())) {
389 String uuid = PortalUUIDUtil.generate();
390
391 ddlRecordSet.setUuid(uuid);
392 }
393
394 Session session = null;
395
396 try {
397 session = openSession();
398
399 if (ddlRecordSet.isNew()) {
400 session.save(ddlRecordSet);
401
402 ddlRecordSet.setNew(false);
403 }
404 else {
405 session.merge(ddlRecordSet);
406 }
407 }
408 catch (Exception e) {
409 throw processException(e);
410 }
411 finally {
412 closeSession(session);
413 }
414
415 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
416
417 if (isNew || !DDLRecordSetModelImpl.COLUMN_BITMASK_ENABLED) {
418 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
419 }
420
421 else {
422 if ((ddlRecordSetModelImpl.getColumnBitmask() &
423 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
424 Object[] args = new Object[] {
425 ddlRecordSetModelImpl.getOriginalUuid()
426 };
427
428 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
429 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
430 args);
431
432 args = new Object[] { ddlRecordSetModelImpl.getUuid() };
433
434 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
435 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
436 args);
437 }
438
439 if ((ddlRecordSetModelImpl.getColumnBitmask() &
440 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
441 Object[] args = new Object[] {
442 ddlRecordSetModelImpl.getOriginalUuid(),
443 Long.valueOf(ddlRecordSetModelImpl.getOriginalCompanyId())
444 };
445
446 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
447 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
448 args);
449
450 args = new Object[] {
451 ddlRecordSetModelImpl.getUuid(),
452 Long.valueOf(ddlRecordSetModelImpl.getCompanyId())
453 };
454
455 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
456 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
457 args);
458 }
459
460 if ((ddlRecordSetModelImpl.getColumnBitmask() &
461 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
462 Object[] args = new Object[] {
463 Long.valueOf(ddlRecordSetModelImpl.getOriginalGroupId())
464 };
465
466 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
467 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
468 args);
469
470 args = new Object[] {
471 Long.valueOf(ddlRecordSetModelImpl.getGroupId())
472 };
473
474 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
475 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
476 args);
477 }
478 }
479
480 EntityCacheUtil.putResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
481 DDLRecordSetImpl.class, ddlRecordSet.getPrimaryKey(), ddlRecordSet);
482
483 if (isNew) {
484 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
485 new Object[] {
486 ddlRecordSet.getUuid(),
487 Long.valueOf(ddlRecordSet.getGroupId())
488 }, ddlRecordSet);
489
490 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
491 new Object[] {
492 Long.valueOf(ddlRecordSet.getGroupId()),
493
494 ddlRecordSet.getRecordSetKey()
495 }, ddlRecordSet);
496 }
497 else {
498 if ((ddlRecordSetModelImpl.getColumnBitmask() &
499 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
500 Object[] args = new Object[] {
501 ddlRecordSetModelImpl.getOriginalUuid(),
502 Long.valueOf(ddlRecordSetModelImpl.getOriginalGroupId())
503 };
504
505 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
506
507 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
508
509 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
510 new Object[] {
511 ddlRecordSet.getUuid(),
512 Long.valueOf(ddlRecordSet.getGroupId())
513 }, ddlRecordSet);
514 }
515
516 if ((ddlRecordSetModelImpl.getColumnBitmask() &
517 FINDER_PATH_FETCH_BY_G_R.getColumnBitmask()) != 0) {
518 Object[] args = new Object[] {
519 Long.valueOf(ddlRecordSetModelImpl.getOriginalGroupId()),
520
521 ddlRecordSetModelImpl.getOriginalRecordSetKey()
522 };
523
524 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_R, args);
525
526 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_R, args);
527
528 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
529 new Object[] {
530 Long.valueOf(ddlRecordSet.getGroupId()),
531
532 ddlRecordSet.getRecordSetKey()
533 }, ddlRecordSet);
534 }
535 }
536
537 return ddlRecordSet;
538 }
539
540 protected DDLRecordSet toUnwrappedModel(DDLRecordSet ddlRecordSet) {
541 if (ddlRecordSet instanceof DDLRecordSetImpl) {
542 return ddlRecordSet;
543 }
544
545 DDLRecordSetImpl ddlRecordSetImpl = new DDLRecordSetImpl();
546
547 ddlRecordSetImpl.setNew(ddlRecordSet.isNew());
548 ddlRecordSetImpl.setPrimaryKey(ddlRecordSet.getPrimaryKey());
549
550 ddlRecordSetImpl.setUuid(ddlRecordSet.getUuid());
551 ddlRecordSetImpl.setRecordSetId(ddlRecordSet.getRecordSetId());
552 ddlRecordSetImpl.setGroupId(ddlRecordSet.getGroupId());
553 ddlRecordSetImpl.setCompanyId(ddlRecordSet.getCompanyId());
554 ddlRecordSetImpl.setUserId(ddlRecordSet.getUserId());
555 ddlRecordSetImpl.setUserName(ddlRecordSet.getUserName());
556 ddlRecordSetImpl.setCreateDate(ddlRecordSet.getCreateDate());
557 ddlRecordSetImpl.setModifiedDate(ddlRecordSet.getModifiedDate());
558 ddlRecordSetImpl.setDDMStructureId(ddlRecordSet.getDDMStructureId());
559 ddlRecordSetImpl.setRecordSetKey(ddlRecordSet.getRecordSetKey());
560 ddlRecordSetImpl.setName(ddlRecordSet.getName());
561 ddlRecordSetImpl.setDescription(ddlRecordSet.getDescription());
562 ddlRecordSetImpl.setMinDisplayRows(ddlRecordSet.getMinDisplayRows());
563 ddlRecordSetImpl.setScope(ddlRecordSet.getScope());
564
565 return ddlRecordSetImpl;
566 }
567
568
576 @Override
577 public DDLRecordSet findByPrimaryKey(Serializable primaryKey)
578 throws NoSuchModelException, SystemException {
579 return findByPrimaryKey(((Long)primaryKey).longValue());
580 }
581
582
590 public DDLRecordSet findByPrimaryKey(long recordSetId)
591 throws NoSuchRecordSetException, SystemException {
592 DDLRecordSet ddlRecordSet = fetchByPrimaryKey(recordSetId);
593
594 if (ddlRecordSet == null) {
595 if (_log.isWarnEnabled()) {
596 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + recordSetId);
597 }
598
599 throw new NoSuchRecordSetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
600 recordSetId);
601 }
602
603 return ddlRecordSet;
604 }
605
606
613 @Override
614 public DDLRecordSet fetchByPrimaryKey(Serializable primaryKey)
615 throws SystemException {
616 return fetchByPrimaryKey(((Long)primaryKey).longValue());
617 }
618
619
626 public DDLRecordSet fetchByPrimaryKey(long recordSetId)
627 throws SystemException {
628 DDLRecordSet ddlRecordSet = (DDLRecordSet)EntityCacheUtil.getResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
629 DDLRecordSetImpl.class, recordSetId);
630
631 if (ddlRecordSet == _nullDDLRecordSet) {
632 return null;
633 }
634
635 if (ddlRecordSet == null) {
636 Session session = null;
637
638 boolean hasException = false;
639
640 try {
641 session = openSession();
642
643 ddlRecordSet = (DDLRecordSet)session.get(DDLRecordSetImpl.class,
644 Long.valueOf(recordSetId));
645 }
646 catch (Exception e) {
647 hasException = true;
648
649 throw processException(e);
650 }
651 finally {
652 if (ddlRecordSet != null) {
653 cacheResult(ddlRecordSet);
654 }
655 else if (!hasException) {
656 EntityCacheUtil.putResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED,
657 DDLRecordSetImpl.class, recordSetId, _nullDDLRecordSet);
658 }
659
660 closeSession(session);
661 }
662 }
663
664 return ddlRecordSet;
665 }
666
667
674 public List<DDLRecordSet> findByUuid(String uuid) throws SystemException {
675 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
676 }
677
678
691 public List<DDLRecordSet> findByUuid(String uuid, int start, int end)
692 throws SystemException {
693 return findByUuid(uuid, start, end, null);
694 }
695
696
710 public List<DDLRecordSet> findByUuid(String uuid, int start, int end,
711 OrderByComparator orderByComparator) throws SystemException {
712 FinderPath finderPath = null;
713 Object[] finderArgs = null;
714
715 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
716 (orderByComparator == null)) {
717 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
718 finderArgs = new Object[] { uuid };
719 }
720 else {
721 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
722 finderArgs = new Object[] { uuid, start, end, orderByComparator };
723 }
724
725 List<DDLRecordSet> list = (List<DDLRecordSet>)FinderCacheUtil.getResult(finderPath,
726 finderArgs, this);
727
728 if ((list != null) && !list.isEmpty()) {
729 for (DDLRecordSet ddlRecordSet : list) {
730 if (!Validator.equals(uuid, ddlRecordSet.getUuid())) {
731 list = null;
732
733 break;
734 }
735 }
736 }
737
738 if (list == null) {
739 StringBundler query = null;
740
741 if (orderByComparator != null) {
742 query = new StringBundler(3 +
743 (orderByComparator.getOrderByFields().length * 3));
744 }
745 else {
746 query = new StringBundler(2);
747 }
748
749 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
750
751 if (uuid == null) {
752 query.append(_FINDER_COLUMN_UUID_UUID_1);
753 }
754 else {
755 if (uuid.equals(StringPool.BLANK)) {
756 query.append(_FINDER_COLUMN_UUID_UUID_3);
757 }
758 else {
759 query.append(_FINDER_COLUMN_UUID_UUID_2);
760 }
761 }
762
763 if (orderByComparator != null) {
764 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
765 orderByComparator);
766 }
767
768 String sql = query.toString();
769
770 Session session = null;
771
772 try {
773 session = openSession();
774
775 Query q = session.createQuery(sql);
776
777 QueryPos qPos = QueryPos.getInstance(q);
778
779 if (uuid != null) {
780 qPos.add(uuid);
781 }
782
783 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
784 start, end);
785 }
786 catch (Exception e) {
787 throw processException(e);
788 }
789 finally {
790 if (list == null) {
791 FinderCacheUtil.removeResult(finderPath, finderArgs);
792 }
793 else {
794 cacheResult(list);
795
796 FinderCacheUtil.putResult(finderPath, finderArgs, list);
797 }
798
799 closeSession(session);
800 }
801 }
802
803 return list;
804 }
805
806
815 public DDLRecordSet findByUuid_First(String uuid,
816 OrderByComparator orderByComparator)
817 throws NoSuchRecordSetException, SystemException {
818 DDLRecordSet ddlRecordSet = fetchByUuid_First(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_First(String uuid,
845 OrderByComparator orderByComparator) throws SystemException {
846 List<DDLRecordSet> list = findByUuid(uuid, 0, 1, orderByComparator);
847
848 if (!list.isEmpty()) {
849 return list.get(0);
850 }
851
852 return null;
853 }
854
855
864 public DDLRecordSet findByUuid_Last(String uuid,
865 OrderByComparator orderByComparator)
866 throws NoSuchRecordSetException, SystemException {
867 DDLRecordSet ddlRecordSet = fetchByUuid_Last(uuid, orderByComparator);
868
869 if (ddlRecordSet != null) {
870 return ddlRecordSet;
871 }
872
873 StringBundler msg = new StringBundler(4);
874
875 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
876
877 msg.append("uuid=");
878 msg.append(uuid);
879
880 msg.append(StringPool.CLOSE_CURLY_BRACE);
881
882 throw new NoSuchRecordSetException(msg.toString());
883 }
884
885
893 public DDLRecordSet fetchByUuid_Last(String uuid,
894 OrderByComparator orderByComparator) throws SystemException {
895 int count = countByUuid(uuid);
896
897 List<DDLRecordSet> list = findByUuid(uuid, count - 1, count,
898 orderByComparator);
899
900 if (!list.isEmpty()) {
901 return list.get(0);
902 }
903
904 return null;
905 }
906
907
917 public DDLRecordSet[] findByUuid_PrevAndNext(long recordSetId, String uuid,
918 OrderByComparator orderByComparator)
919 throws NoSuchRecordSetException, SystemException {
920 DDLRecordSet ddlRecordSet = findByPrimaryKey(recordSetId);
921
922 Session session = null;
923
924 try {
925 session = openSession();
926
927 DDLRecordSet[] array = new DDLRecordSetImpl[3];
928
929 array[0] = getByUuid_PrevAndNext(session, ddlRecordSet, uuid,
930 orderByComparator, true);
931
932 array[1] = ddlRecordSet;
933
934 array[2] = getByUuid_PrevAndNext(session, ddlRecordSet, uuid,
935 orderByComparator, false);
936
937 return array;
938 }
939 catch (Exception e) {
940 throw processException(e);
941 }
942 finally {
943 closeSession(session);
944 }
945 }
946
947 protected DDLRecordSet getByUuid_PrevAndNext(Session session,
948 DDLRecordSet ddlRecordSet, String uuid,
949 OrderByComparator orderByComparator, boolean previous) {
950 StringBundler query = null;
951
952 if (orderByComparator != null) {
953 query = new StringBundler(6 +
954 (orderByComparator.getOrderByFields().length * 6));
955 }
956 else {
957 query = new StringBundler(3);
958 }
959
960 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
961
962 if (uuid == null) {
963 query.append(_FINDER_COLUMN_UUID_UUID_1);
964 }
965 else {
966 if (uuid.equals(StringPool.BLANK)) {
967 query.append(_FINDER_COLUMN_UUID_UUID_3);
968 }
969 else {
970 query.append(_FINDER_COLUMN_UUID_UUID_2);
971 }
972 }
973
974 if (orderByComparator != null) {
975 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
976
977 if (orderByConditionFields.length > 0) {
978 query.append(WHERE_AND);
979 }
980
981 for (int i = 0; i < orderByConditionFields.length; i++) {
982 query.append(_ORDER_BY_ENTITY_ALIAS);
983 query.append(orderByConditionFields[i]);
984
985 if ((i + 1) < orderByConditionFields.length) {
986 if (orderByComparator.isAscending() ^ previous) {
987 query.append(WHERE_GREATER_THAN_HAS_NEXT);
988 }
989 else {
990 query.append(WHERE_LESSER_THAN_HAS_NEXT);
991 }
992 }
993 else {
994 if (orderByComparator.isAscending() ^ previous) {
995 query.append(WHERE_GREATER_THAN);
996 }
997 else {
998 query.append(WHERE_LESSER_THAN);
999 }
1000 }
1001 }
1002
1003 query.append(ORDER_BY_CLAUSE);
1004
1005 String[] orderByFields = orderByComparator.getOrderByFields();
1006
1007 for (int i = 0; i < orderByFields.length; i++) {
1008 query.append(_ORDER_BY_ENTITY_ALIAS);
1009 query.append(orderByFields[i]);
1010
1011 if ((i + 1) < orderByFields.length) {
1012 if (orderByComparator.isAscending() ^ previous) {
1013 query.append(ORDER_BY_ASC_HAS_NEXT);
1014 }
1015 else {
1016 query.append(ORDER_BY_DESC_HAS_NEXT);
1017 }
1018 }
1019 else {
1020 if (orderByComparator.isAscending() ^ previous) {
1021 query.append(ORDER_BY_ASC);
1022 }
1023 else {
1024 query.append(ORDER_BY_DESC);
1025 }
1026 }
1027 }
1028 }
1029
1030 String sql = query.toString();
1031
1032 Query q = session.createQuery(sql);
1033
1034 q.setFirstResult(0);
1035 q.setMaxResults(2);
1036
1037 QueryPos qPos = QueryPos.getInstance(q);
1038
1039 if (uuid != null) {
1040 qPos.add(uuid);
1041 }
1042
1043 if (orderByComparator != null) {
1044 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordSet);
1045
1046 for (Object value : values) {
1047 qPos.add(value);
1048 }
1049 }
1050
1051 List<DDLRecordSet> list = q.list();
1052
1053 if (list.size() == 2) {
1054 return list.get(1);
1055 }
1056 else {
1057 return null;
1058 }
1059 }
1060
1061
1070 public DDLRecordSet findByUUID_G(String uuid, long groupId)
1071 throws NoSuchRecordSetException, SystemException {
1072 DDLRecordSet ddlRecordSet = fetchByUUID_G(uuid, groupId);
1073
1074 if (ddlRecordSet == null) {
1075 StringBundler msg = new StringBundler(6);
1076
1077 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1078
1079 msg.append("uuid=");
1080 msg.append(uuid);
1081
1082 msg.append(", groupId=");
1083 msg.append(groupId);
1084
1085 msg.append(StringPool.CLOSE_CURLY_BRACE);
1086
1087 if (_log.isWarnEnabled()) {
1088 _log.warn(msg.toString());
1089 }
1090
1091 throw new NoSuchRecordSetException(msg.toString());
1092 }
1093
1094 return ddlRecordSet;
1095 }
1096
1097
1105 public DDLRecordSet fetchByUUID_G(String uuid, long groupId)
1106 throws SystemException {
1107 return fetchByUUID_G(uuid, groupId, true);
1108 }
1109
1110
1119 public DDLRecordSet fetchByUUID_G(String uuid, long groupId,
1120 boolean retrieveFromCache) throws SystemException {
1121 Object[] finderArgs = new Object[] { uuid, groupId };
1122
1123 Object result = null;
1124
1125 if (retrieveFromCache) {
1126 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1127 finderArgs, this);
1128 }
1129
1130 if (result instanceof DDLRecordSet) {
1131 DDLRecordSet ddlRecordSet = (DDLRecordSet)result;
1132
1133 if (!Validator.equals(uuid, ddlRecordSet.getUuid()) ||
1134 (groupId != ddlRecordSet.getGroupId())) {
1135 result = null;
1136 }
1137 }
1138
1139 if (result == null) {
1140 StringBundler query = new StringBundler(3);
1141
1142 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1143
1144 if (uuid == null) {
1145 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1146 }
1147 else {
1148 if (uuid.equals(StringPool.BLANK)) {
1149 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1150 }
1151 else {
1152 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1153 }
1154 }
1155
1156 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1157
1158 String sql = query.toString();
1159
1160 Session session = null;
1161
1162 try {
1163 session = openSession();
1164
1165 Query q = session.createQuery(sql);
1166
1167 QueryPos qPos = QueryPos.getInstance(q);
1168
1169 if (uuid != null) {
1170 qPos.add(uuid);
1171 }
1172
1173 qPos.add(groupId);
1174
1175 List<DDLRecordSet> list = q.list();
1176
1177 result = list;
1178
1179 DDLRecordSet ddlRecordSet = null;
1180
1181 if (list.isEmpty()) {
1182 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1183 finderArgs, list);
1184 }
1185 else {
1186 ddlRecordSet = list.get(0);
1187
1188 cacheResult(ddlRecordSet);
1189
1190 if ((ddlRecordSet.getUuid() == null) ||
1191 !ddlRecordSet.getUuid().equals(uuid) ||
1192 (ddlRecordSet.getGroupId() != groupId)) {
1193 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1194 finderArgs, ddlRecordSet);
1195 }
1196 }
1197
1198 return ddlRecordSet;
1199 }
1200 catch (Exception e) {
1201 throw processException(e);
1202 }
1203 finally {
1204 if (result == null) {
1205 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1206 finderArgs);
1207 }
1208
1209 closeSession(session);
1210 }
1211 }
1212 else {
1213 if (result instanceof List<?>) {
1214 return null;
1215 }
1216 else {
1217 return (DDLRecordSet)result;
1218 }
1219 }
1220 }
1221
1222
1230 public List<DDLRecordSet> findByUuid_C(String uuid, long companyId)
1231 throws SystemException {
1232 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1233 QueryUtil.ALL_POS, null);
1234 }
1235
1236
1250 public List<DDLRecordSet> findByUuid_C(String uuid, long companyId,
1251 int start, int end) throws SystemException {
1252 return findByUuid_C(uuid, companyId, start, end, null);
1253 }
1254
1255
1270 public List<DDLRecordSet> findByUuid_C(String uuid, long companyId,
1271 int start, int end, OrderByComparator orderByComparator)
1272 throws SystemException {
1273 FinderPath finderPath = null;
1274 Object[] finderArgs = null;
1275
1276 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1277 (orderByComparator == null)) {
1278 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1279 finderArgs = new Object[] { uuid, companyId };
1280 }
1281 else {
1282 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1283 finderArgs = new Object[] {
1284 uuid, companyId,
1285
1286 start, end, orderByComparator
1287 };
1288 }
1289
1290 List<DDLRecordSet> list = (List<DDLRecordSet>)FinderCacheUtil.getResult(finderPath,
1291 finderArgs, this);
1292
1293 if ((list != null) && !list.isEmpty()) {
1294 for (DDLRecordSet ddlRecordSet : list) {
1295 if (!Validator.equals(uuid, ddlRecordSet.getUuid()) ||
1296 (companyId != ddlRecordSet.getCompanyId())) {
1297 list = null;
1298
1299 break;
1300 }
1301 }
1302 }
1303
1304 if (list == null) {
1305 StringBundler query = null;
1306
1307 if (orderByComparator != null) {
1308 query = new StringBundler(4 +
1309 (orderByComparator.getOrderByFields().length * 3));
1310 }
1311 else {
1312 query = new StringBundler(3);
1313 }
1314
1315 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1316
1317 if (uuid == null) {
1318 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1319 }
1320 else {
1321 if (uuid.equals(StringPool.BLANK)) {
1322 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1323 }
1324 else {
1325 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1326 }
1327 }
1328
1329 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1330
1331 if (orderByComparator != null) {
1332 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1333 orderByComparator);
1334 }
1335
1336 String sql = query.toString();
1337
1338 Session session = null;
1339
1340 try {
1341 session = openSession();
1342
1343 Query q = session.createQuery(sql);
1344
1345 QueryPos qPos = QueryPos.getInstance(q);
1346
1347 if (uuid != null) {
1348 qPos.add(uuid);
1349 }
1350
1351 qPos.add(companyId);
1352
1353 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
1354 start, end);
1355 }
1356 catch (Exception e) {
1357 throw processException(e);
1358 }
1359 finally {
1360 if (list == null) {
1361 FinderCacheUtil.removeResult(finderPath, finderArgs);
1362 }
1363 else {
1364 cacheResult(list);
1365
1366 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1367 }
1368
1369 closeSession(session);
1370 }
1371 }
1372
1373 return list;
1374 }
1375
1376
1386 public DDLRecordSet findByUuid_C_First(String uuid, long companyId,
1387 OrderByComparator orderByComparator)
1388 throws NoSuchRecordSetException, SystemException {
1389 DDLRecordSet ddlRecordSet = fetchByUuid_C_First(uuid, companyId,
1390 orderByComparator);
1391
1392 if (ddlRecordSet != null) {
1393 return ddlRecordSet;
1394 }
1395
1396 StringBundler msg = new StringBundler(6);
1397
1398 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1399
1400 msg.append("uuid=");
1401 msg.append(uuid);
1402
1403 msg.append(", companyId=");
1404 msg.append(companyId);
1405
1406 msg.append(StringPool.CLOSE_CURLY_BRACE);
1407
1408 throw new NoSuchRecordSetException(msg.toString());
1409 }
1410
1411
1420 public DDLRecordSet fetchByUuid_C_First(String uuid, long companyId,
1421 OrderByComparator orderByComparator) throws SystemException {
1422 List<DDLRecordSet> list = findByUuid_C(uuid, companyId, 0, 1,
1423 orderByComparator);
1424
1425 if (!list.isEmpty()) {
1426 return list.get(0);
1427 }
1428
1429 return null;
1430 }
1431
1432
1442 public DDLRecordSet findByUuid_C_Last(String uuid, long companyId,
1443 OrderByComparator orderByComparator)
1444 throws NoSuchRecordSetException, SystemException {
1445 DDLRecordSet ddlRecordSet = fetchByUuid_C_Last(uuid, companyId,
1446 orderByComparator);
1447
1448 if (ddlRecordSet != null) {
1449 return ddlRecordSet;
1450 }
1451
1452 StringBundler msg = new StringBundler(6);
1453
1454 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1455
1456 msg.append("uuid=");
1457 msg.append(uuid);
1458
1459 msg.append(", companyId=");
1460 msg.append(companyId);
1461
1462 msg.append(StringPool.CLOSE_CURLY_BRACE);
1463
1464 throw new NoSuchRecordSetException(msg.toString());
1465 }
1466
1467
1476 public DDLRecordSet fetchByUuid_C_Last(String uuid, long companyId,
1477 OrderByComparator orderByComparator) throws SystemException {
1478 int count = countByUuid_C(uuid, companyId);
1479
1480 List<DDLRecordSet> list = findByUuid_C(uuid, companyId, count - 1,
1481 count, orderByComparator);
1482
1483 if (!list.isEmpty()) {
1484 return list.get(0);
1485 }
1486
1487 return null;
1488 }
1489
1490
1501 public DDLRecordSet[] findByUuid_C_PrevAndNext(long recordSetId,
1502 String uuid, long companyId, OrderByComparator orderByComparator)
1503 throws NoSuchRecordSetException, SystemException {
1504 DDLRecordSet ddlRecordSet = findByPrimaryKey(recordSetId);
1505
1506 Session session = null;
1507
1508 try {
1509 session = openSession();
1510
1511 DDLRecordSet[] array = new DDLRecordSetImpl[3];
1512
1513 array[0] = getByUuid_C_PrevAndNext(session, ddlRecordSet, uuid,
1514 companyId, orderByComparator, true);
1515
1516 array[1] = ddlRecordSet;
1517
1518 array[2] = getByUuid_C_PrevAndNext(session, ddlRecordSet, uuid,
1519 companyId, orderByComparator, false);
1520
1521 return array;
1522 }
1523 catch (Exception e) {
1524 throw processException(e);
1525 }
1526 finally {
1527 closeSession(session);
1528 }
1529 }
1530
1531 protected DDLRecordSet getByUuid_C_PrevAndNext(Session session,
1532 DDLRecordSet ddlRecordSet, String uuid, long companyId,
1533 OrderByComparator orderByComparator, boolean previous) {
1534 StringBundler query = null;
1535
1536 if (orderByComparator != null) {
1537 query = new StringBundler(6 +
1538 (orderByComparator.getOrderByFields().length * 6));
1539 }
1540 else {
1541 query = new StringBundler(3);
1542 }
1543
1544 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1545
1546 if (uuid == null) {
1547 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1548 }
1549 else {
1550 if (uuid.equals(StringPool.BLANK)) {
1551 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1552 }
1553 else {
1554 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1555 }
1556 }
1557
1558 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1559
1560 if (orderByComparator != null) {
1561 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1562
1563 if (orderByConditionFields.length > 0) {
1564 query.append(WHERE_AND);
1565 }
1566
1567 for (int i = 0; i < orderByConditionFields.length; i++) {
1568 query.append(_ORDER_BY_ENTITY_ALIAS);
1569 query.append(orderByConditionFields[i]);
1570
1571 if ((i + 1) < orderByConditionFields.length) {
1572 if (orderByComparator.isAscending() ^ previous) {
1573 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1574 }
1575 else {
1576 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1577 }
1578 }
1579 else {
1580 if (orderByComparator.isAscending() ^ previous) {
1581 query.append(WHERE_GREATER_THAN);
1582 }
1583 else {
1584 query.append(WHERE_LESSER_THAN);
1585 }
1586 }
1587 }
1588
1589 query.append(ORDER_BY_CLAUSE);
1590
1591 String[] orderByFields = orderByComparator.getOrderByFields();
1592
1593 for (int i = 0; i < orderByFields.length; i++) {
1594 query.append(_ORDER_BY_ENTITY_ALIAS);
1595 query.append(orderByFields[i]);
1596
1597 if ((i + 1) < orderByFields.length) {
1598 if (orderByComparator.isAscending() ^ previous) {
1599 query.append(ORDER_BY_ASC_HAS_NEXT);
1600 }
1601 else {
1602 query.append(ORDER_BY_DESC_HAS_NEXT);
1603 }
1604 }
1605 else {
1606 if (orderByComparator.isAscending() ^ previous) {
1607 query.append(ORDER_BY_ASC);
1608 }
1609 else {
1610 query.append(ORDER_BY_DESC);
1611 }
1612 }
1613 }
1614 }
1615
1616 String sql = query.toString();
1617
1618 Query q = session.createQuery(sql);
1619
1620 q.setFirstResult(0);
1621 q.setMaxResults(2);
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 if (uuid != null) {
1626 qPos.add(uuid);
1627 }
1628
1629 qPos.add(companyId);
1630
1631 if (orderByComparator != null) {
1632 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordSet);
1633
1634 for (Object value : values) {
1635 qPos.add(value);
1636 }
1637 }
1638
1639 List<DDLRecordSet> list = q.list();
1640
1641 if (list.size() == 2) {
1642 return list.get(1);
1643 }
1644 else {
1645 return null;
1646 }
1647 }
1648
1649
1656 public List<DDLRecordSet> findByGroupId(long groupId)
1657 throws SystemException {
1658 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1659 }
1660
1661
1674 public List<DDLRecordSet> findByGroupId(long groupId, int start, int end)
1675 throws SystemException {
1676 return findByGroupId(groupId, start, end, null);
1677 }
1678
1679
1693 public List<DDLRecordSet> findByGroupId(long groupId, int start, int end,
1694 OrderByComparator orderByComparator) throws SystemException {
1695 FinderPath finderPath = null;
1696 Object[] finderArgs = null;
1697
1698 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1699 (orderByComparator == null)) {
1700 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1701 finderArgs = new Object[] { groupId };
1702 }
1703 else {
1704 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1705 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1706 }
1707
1708 List<DDLRecordSet> list = (List<DDLRecordSet>)FinderCacheUtil.getResult(finderPath,
1709 finderArgs, this);
1710
1711 if ((list != null) && !list.isEmpty()) {
1712 for (DDLRecordSet ddlRecordSet : list) {
1713 if ((groupId != ddlRecordSet.getGroupId())) {
1714 list = null;
1715
1716 break;
1717 }
1718 }
1719 }
1720
1721 if (list == null) {
1722 StringBundler query = null;
1723
1724 if (orderByComparator != null) {
1725 query = new StringBundler(3 +
1726 (orderByComparator.getOrderByFields().length * 3));
1727 }
1728 else {
1729 query = new StringBundler(2);
1730 }
1731
1732 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1733
1734 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1735
1736 if (orderByComparator != null) {
1737 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1738 orderByComparator);
1739 }
1740
1741 String sql = query.toString();
1742
1743 Session session = null;
1744
1745 try {
1746 session = openSession();
1747
1748 Query q = session.createQuery(sql);
1749
1750 QueryPos qPos = QueryPos.getInstance(q);
1751
1752 qPos.add(groupId);
1753
1754 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
1755 start, end);
1756 }
1757 catch (Exception e) {
1758 throw processException(e);
1759 }
1760 finally {
1761 if (list == null) {
1762 FinderCacheUtil.removeResult(finderPath, finderArgs);
1763 }
1764 else {
1765 cacheResult(list);
1766
1767 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1768 }
1769
1770 closeSession(session);
1771 }
1772 }
1773
1774 return list;
1775 }
1776
1777
1786 public DDLRecordSet findByGroupId_First(long groupId,
1787 OrderByComparator orderByComparator)
1788 throws NoSuchRecordSetException, SystemException {
1789 DDLRecordSet ddlRecordSet = fetchByGroupId_First(groupId,
1790 orderByComparator);
1791
1792 if (ddlRecordSet != null) {
1793 return ddlRecordSet;
1794 }
1795
1796 StringBundler msg = new StringBundler(4);
1797
1798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1799
1800 msg.append("groupId=");
1801 msg.append(groupId);
1802
1803 msg.append(StringPool.CLOSE_CURLY_BRACE);
1804
1805 throw new NoSuchRecordSetException(msg.toString());
1806 }
1807
1808
1816 public DDLRecordSet fetchByGroupId_First(long groupId,
1817 OrderByComparator orderByComparator) throws SystemException {
1818 List<DDLRecordSet> list = findByGroupId(groupId, 0, 1, orderByComparator);
1819
1820 if (!list.isEmpty()) {
1821 return list.get(0);
1822 }
1823
1824 return null;
1825 }
1826
1827
1836 public DDLRecordSet findByGroupId_Last(long groupId,
1837 OrderByComparator orderByComparator)
1838 throws NoSuchRecordSetException, SystemException {
1839 DDLRecordSet ddlRecordSet = fetchByGroupId_Last(groupId,
1840 orderByComparator);
1841
1842 if (ddlRecordSet != null) {
1843 return ddlRecordSet;
1844 }
1845
1846 StringBundler msg = new StringBundler(4);
1847
1848 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1849
1850 msg.append("groupId=");
1851 msg.append(groupId);
1852
1853 msg.append(StringPool.CLOSE_CURLY_BRACE);
1854
1855 throw new NoSuchRecordSetException(msg.toString());
1856 }
1857
1858
1866 public DDLRecordSet fetchByGroupId_Last(long groupId,
1867 OrderByComparator orderByComparator) throws SystemException {
1868 int count = countByGroupId(groupId);
1869
1870 List<DDLRecordSet> list = findByGroupId(groupId, count - 1, count,
1871 orderByComparator);
1872
1873 if (!list.isEmpty()) {
1874 return list.get(0);
1875 }
1876
1877 return null;
1878 }
1879
1880
1890 public DDLRecordSet[] findByGroupId_PrevAndNext(long recordSetId,
1891 long groupId, OrderByComparator orderByComparator)
1892 throws NoSuchRecordSetException, SystemException {
1893 DDLRecordSet ddlRecordSet = findByPrimaryKey(recordSetId);
1894
1895 Session session = null;
1896
1897 try {
1898 session = openSession();
1899
1900 DDLRecordSet[] array = new DDLRecordSetImpl[3];
1901
1902 array[0] = getByGroupId_PrevAndNext(session, ddlRecordSet, groupId,
1903 orderByComparator, true);
1904
1905 array[1] = ddlRecordSet;
1906
1907 array[2] = getByGroupId_PrevAndNext(session, ddlRecordSet, groupId,
1908 orderByComparator, false);
1909
1910 return array;
1911 }
1912 catch (Exception e) {
1913 throw processException(e);
1914 }
1915 finally {
1916 closeSession(session);
1917 }
1918 }
1919
1920 protected DDLRecordSet getByGroupId_PrevAndNext(Session session,
1921 DDLRecordSet ddlRecordSet, long groupId,
1922 OrderByComparator orderByComparator, boolean previous) {
1923 StringBundler query = null;
1924
1925 if (orderByComparator != null) {
1926 query = new StringBundler(6 +
1927 (orderByComparator.getOrderByFields().length * 6));
1928 }
1929 else {
1930 query = new StringBundler(3);
1931 }
1932
1933 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
1934
1935 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1936
1937 if (orderByComparator != null) {
1938 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1939
1940 if (orderByConditionFields.length > 0) {
1941 query.append(WHERE_AND);
1942 }
1943
1944 for (int i = 0; i < orderByConditionFields.length; i++) {
1945 query.append(_ORDER_BY_ENTITY_ALIAS);
1946 query.append(orderByConditionFields[i]);
1947
1948 if ((i + 1) < orderByConditionFields.length) {
1949 if (orderByComparator.isAscending() ^ previous) {
1950 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1951 }
1952 else {
1953 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1954 }
1955 }
1956 else {
1957 if (orderByComparator.isAscending() ^ previous) {
1958 query.append(WHERE_GREATER_THAN);
1959 }
1960 else {
1961 query.append(WHERE_LESSER_THAN);
1962 }
1963 }
1964 }
1965
1966 query.append(ORDER_BY_CLAUSE);
1967
1968 String[] orderByFields = orderByComparator.getOrderByFields();
1969
1970 for (int i = 0; i < orderByFields.length; i++) {
1971 query.append(_ORDER_BY_ENTITY_ALIAS);
1972 query.append(orderByFields[i]);
1973
1974 if ((i + 1) < orderByFields.length) {
1975 if (orderByComparator.isAscending() ^ previous) {
1976 query.append(ORDER_BY_ASC_HAS_NEXT);
1977 }
1978 else {
1979 query.append(ORDER_BY_DESC_HAS_NEXT);
1980 }
1981 }
1982 else {
1983 if (orderByComparator.isAscending() ^ previous) {
1984 query.append(ORDER_BY_ASC);
1985 }
1986 else {
1987 query.append(ORDER_BY_DESC);
1988 }
1989 }
1990 }
1991 }
1992
1993 String sql = query.toString();
1994
1995 Query q = session.createQuery(sql);
1996
1997 q.setFirstResult(0);
1998 q.setMaxResults(2);
1999
2000 QueryPos qPos = QueryPos.getInstance(q);
2001
2002 qPos.add(groupId);
2003
2004 if (orderByComparator != null) {
2005 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordSet);
2006
2007 for (Object value : values) {
2008 qPos.add(value);
2009 }
2010 }
2011
2012 List<DDLRecordSet> list = q.list();
2013
2014 if (list.size() == 2) {
2015 return list.get(1);
2016 }
2017 else {
2018 return null;
2019 }
2020 }
2021
2022
2029 public List<DDLRecordSet> filterFindByGroupId(long groupId)
2030 throws SystemException {
2031 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2032 QueryUtil.ALL_POS, null);
2033 }
2034
2035
2048 public List<DDLRecordSet> filterFindByGroupId(long groupId, int start,
2049 int end) throws SystemException {
2050 return filterFindByGroupId(groupId, start, end, null);
2051 }
2052
2053
2067 public List<DDLRecordSet> filterFindByGroupId(long groupId, int start,
2068 int end, OrderByComparator orderByComparator) throws SystemException {
2069 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2070 return findByGroupId(groupId, start, end, orderByComparator);
2071 }
2072
2073 StringBundler query = null;
2074
2075 if (orderByComparator != null) {
2076 query = new StringBundler(3 +
2077 (orderByComparator.getOrderByFields().length * 3));
2078 }
2079 else {
2080 query = new StringBundler(2);
2081 }
2082
2083 if (getDB().isSupportsInlineDistinct()) {
2084 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_WHERE);
2085 }
2086 else {
2087 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_1);
2088 }
2089
2090 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2091
2092 if (!getDB().isSupportsInlineDistinct()) {
2093 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_2);
2094 }
2095
2096 if (orderByComparator != null) {
2097 if (getDB().isSupportsInlineDistinct()) {
2098 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2099 orderByComparator);
2100 }
2101 else {
2102 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2103 orderByComparator);
2104 }
2105 }
2106
2107 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2108 DDLRecordSet.class.getName(),
2109 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2110
2111 Session session = null;
2112
2113 try {
2114 session = openSession();
2115
2116 SQLQuery q = session.createSQLQuery(sql);
2117
2118 if (getDB().isSupportsInlineDistinct()) {
2119 q.addEntity(_FILTER_ENTITY_ALIAS, DDLRecordSetImpl.class);
2120 }
2121 else {
2122 q.addEntity(_FILTER_ENTITY_TABLE, DDLRecordSetImpl.class);
2123 }
2124
2125 QueryPos qPos = QueryPos.getInstance(q);
2126
2127 qPos.add(groupId);
2128
2129 return (List<DDLRecordSet>)QueryUtil.list(q, getDialect(), start,
2130 end);
2131 }
2132 catch (Exception e) {
2133 throw processException(e);
2134 }
2135 finally {
2136 closeSession(session);
2137 }
2138 }
2139
2140
2150 public DDLRecordSet[] filterFindByGroupId_PrevAndNext(long recordSetId,
2151 long groupId, OrderByComparator orderByComparator)
2152 throws NoSuchRecordSetException, SystemException {
2153 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2154 return findByGroupId_PrevAndNext(recordSetId, groupId,
2155 orderByComparator);
2156 }
2157
2158 DDLRecordSet ddlRecordSet = findByPrimaryKey(recordSetId);
2159
2160 Session session = null;
2161
2162 try {
2163 session = openSession();
2164
2165 DDLRecordSet[] array = new DDLRecordSetImpl[3];
2166
2167 array[0] = filterGetByGroupId_PrevAndNext(session, ddlRecordSet,
2168 groupId, orderByComparator, true);
2169
2170 array[1] = ddlRecordSet;
2171
2172 array[2] = filterGetByGroupId_PrevAndNext(session, ddlRecordSet,
2173 groupId, orderByComparator, false);
2174
2175 return array;
2176 }
2177 catch (Exception e) {
2178 throw processException(e);
2179 }
2180 finally {
2181 closeSession(session);
2182 }
2183 }
2184
2185 protected DDLRecordSet filterGetByGroupId_PrevAndNext(Session session,
2186 DDLRecordSet ddlRecordSet, long groupId,
2187 OrderByComparator orderByComparator, boolean previous) {
2188 StringBundler query = null;
2189
2190 if (orderByComparator != null) {
2191 query = new StringBundler(6 +
2192 (orderByComparator.getOrderByFields().length * 6));
2193 }
2194 else {
2195 query = new StringBundler(3);
2196 }
2197
2198 if (getDB().isSupportsInlineDistinct()) {
2199 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_WHERE);
2200 }
2201 else {
2202 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_1);
2203 }
2204
2205 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2206
2207 if (!getDB().isSupportsInlineDistinct()) {
2208 query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_2);
2209 }
2210
2211 if (orderByComparator != null) {
2212 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2213
2214 if (orderByConditionFields.length > 0) {
2215 query.append(WHERE_AND);
2216 }
2217
2218 for (int i = 0; i < orderByConditionFields.length; i++) {
2219 if (getDB().isSupportsInlineDistinct()) {
2220 query.append(_ORDER_BY_ENTITY_ALIAS);
2221 }
2222 else {
2223 query.append(_ORDER_BY_ENTITY_TABLE);
2224 }
2225
2226 query.append(orderByConditionFields[i]);
2227
2228 if ((i + 1) < orderByConditionFields.length) {
2229 if (orderByComparator.isAscending() ^ previous) {
2230 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2231 }
2232 else {
2233 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2234 }
2235 }
2236 else {
2237 if (orderByComparator.isAscending() ^ previous) {
2238 query.append(WHERE_GREATER_THAN);
2239 }
2240 else {
2241 query.append(WHERE_LESSER_THAN);
2242 }
2243 }
2244 }
2245
2246 query.append(ORDER_BY_CLAUSE);
2247
2248 String[] orderByFields = orderByComparator.getOrderByFields();
2249
2250 for (int i = 0; i < orderByFields.length; i++) {
2251 if (getDB().isSupportsInlineDistinct()) {
2252 query.append(_ORDER_BY_ENTITY_ALIAS);
2253 }
2254 else {
2255 query.append(_ORDER_BY_ENTITY_TABLE);
2256 }
2257
2258 query.append(orderByFields[i]);
2259
2260 if ((i + 1) < orderByFields.length) {
2261 if (orderByComparator.isAscending() ^ previous) {
2262 query.append(ORDER_BY_ASC_HAS_NEXT);
2263 }
2264 else {
2265 query.append(ORDER_BY_DESC_HAS_NEXT);
2266 }
2267 }
2268 else {
2269 if (orderByComparator.isAscending() ^ previous) {
2270 query.append(ORDER_BY_ASC);
2271 }
2272 else {
2273 query.append(ORDER_BY_DESC);
2274 }
2275 }
2276 }
2277 }
2278
2279 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2280 DDLRecordSet.class.getName(),
2281 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2282
2283 SQLQuery q = session.createSQLQuery(sql);
2284
2285 q.setFirstResult(0);
2286 q.setMaxResults(2);
2287
2288 if (getDB().isSupportsInlineDistinct()) {
2289 q.addEntity(_FILTER_ENTITY_ALIAS, DDLRecordSetImpl.class);
2290 }
2291 else {
2292 q.addEntity(_FILTER_ENTITY_TABLE, DDLRecordSetImpl.class);
2293 }
2294
2295 QueryPos qPos = QueryPos.getInstance(q);
2296
2297 qPos.add(groupId);
2298
2299 if (orderByComparator != null) {
2300 Object[] values = orderByComparator.getOrderByConditionValues(ddlRecordSet);
2301
2302 for (Object value : values) {
2303 qPos.add(value);
2304 }
2305 }
2306
2307 List<DDLRecordSet> list = q.list();
2308
2309 if (list.size() == 2) {
2310 return list.get(1);
2311 }
2312 else {
2313 return null;
2314 }
2315 }
2316
2317
2326 public DDLRecordSet findByG_R(long groupId, String recordSetKey)
2327 throws NoSuchRecordSetException, SystemException {
2328 DDLRecordSet ddlRecordSet = fetchByG_R(groupId, recordSetKey);
2329
2330 if (ddlRecordSet == null) {
2331 StringBundler msg = new StringBundler(6);
2332
2333 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2334
2335 msg.append("groupId=");
2336 msg.append(groupId);
2337
2338 msg.append(", recordSetKey=");
2339 msg.append(recordSetKey);
2340
2341 msg.append(StringPool.CLOSE_CURLY_BRACE);
2342
2343 if (_log.isWarnEnabled()) {
2344 _log.warn(msg.toString());
2345 }
2346
2347 throw new NoSuchRecordSetException(msg.toString());
2348 }
2349
2350 return ddlRecordSet;
2351 }
2352
2353
2361 public DDLRecordSet fetchByG_R(long groupId, String recordSetKey)
2362 throws SystemException {
2363 return fetchByG_R(groupId, recordSetKey, true);
2364 }
2365
2366
2375 public DDLRecordSet fetchByG_R(long groupId, String recordSetKey,
2376 boolean retrieveFromCache) throws SystemException {
2377 Object[] finderArgs = new Object[] { groupId, recordSetKey };
2378
2379 Object result = null;
2380
2381 if (retrieveFromCache) {
2382 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_R,
2383 finderArgs, this);
2384 }
2385
2386 if (result instanceof DDLRecordSet) {
2387 DDLRecordSet ddlRecordSet = (DDLRecordSet)result;
2388
2389 if ((groupId != ddlRecordSet.getGroupId()) ||
2390 !Validator.equals(recordSetKey,
2391 ddlRecordSet.getRecordSetKey())) {
2392 result = null;
2393 }
2394 }
2395
2396 if (result == null) {
2397 StringBundler query = new StringBundler(3);
2398
2399 query.append(_SQL_SELECT_DDLRECORDSET_WHERE);
2400
2401 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
2402
2403 if (recordSetKey == null) {
2404 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_1);
2405 }
2406 else {
2407 if (recordSetKey.equals(StringPool.BLANK)) {
2408 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_3);
2409 }
2410 else {
2411 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_2);
2412 }
2413 }
2414
2415 String sql = query.toString();
2416
2417 Session session = null;
2418
2419 try {
2420 session = openSession();
2421
2422 Query q = session.createQuery(sql);
2423
2424 QueryPos qPos = QueryPos.getInstance(q);
2425
2426 qPos.add(groupId);
2427
2428 if (recordSetKey != null) {
2429 qPos.add(recordSetKey);
2430 }
2431
2432 List<DDLRecordSet> list = q.list();
2433
2434 result = list;
2435
2436 DDLRecordSet ddlRecordSet = null;
2437
2438 if (list.isEmpty()) {
2439 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
2440 finderArgs, list);
2441 }
2442 else {
2443 ddlRecordSet = list.get(0);
2444
2445 cacheResult(ddlRecordSet);
2446
2447 if ((ddlRecordSet.getGroupId() != groupId) ||
2448 (ddlRecordSet.getRecordSetKey() == null) ||
2449 !ddlRecordSet.getRecordSetKey().equals(recordSetKey)) {
2450 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_R,
2451 finderArgs, ddlRecordSet);
2452 }
2453 }
2454
2455 return ddlRecordSet;
2456 }
2457 catch (Exception e) {
2458 throw processException(e);
2459 }
2460 finally {
2461 if (result == null) {
2462 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_R,
2463 finderArgs);
2464 }
2465
2466 closeSession(session);
2467 }
2468 }
2469 else {
2470 if (result instanceof List<?>) {
2471 return null;
2472 }
2473 else {
2474 return (DDLRecordSet)result;
2475 }
2476 }
2477 }
2478
2479
2485 public List<DDLRecordSet> findAll() throws SystemException {
2486 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2487 }
2488
2489
2501 public List<DDLRecordSet> findAll(int start, int end)
2502 throws SystemException {
2503 return findAll(start, end, null);
2504 }
2505
2506
2519 public List<DDLRecordSet> findAll(int start, int end,
2520 OrderByComparator orderByComparator) throws SystemException {
2521 FinderPath finderPath = null;
2522 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2523
2524 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2525 (orderByComparator == null)) {
2526 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2527 finderArgs = FINDER_ARGS_EMPTY;
2528 }
2529 else {
2530 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2531 finderArgs = new Object[] { start, end, orderByComparator };
2532 }
2533
2534 List<DDLRecordSet> list = (List<DDLRecordSet>)FinderCacheUtil.getResult(finderPath,
2535 finderArgs, this);
2536
2537 if (list == null) {
2538 StringBundler query = null;
2539 String sql = null;
2540
2541 if (orderByComparator != null) {
2542 query = new StringBundler(2 +
2543 (orderByComparator.getOrderByFields().length * 3));
2544
2545 query.append(_SQL_SELECT_DDLRECORDSET);
2546
2547 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2548 orderByComparator);
2549
2550 sql = query.toString();
2551 }
2552 else {
2553 sql = _SQL_SELECT_DDLRECORDSET;
2554 }
2555
2556 Session session = null;
2557
2558 try {
2559 session = openSession();
2560
2561 Query q = session.createQuery(sql);
2562
2563 if (orderByComparator == null) {
2564 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
2565 start, end, false);
2566
2567 Collections.sort(list);
2568 }
2569 else {
2570 list = (List<DDLRecordSet>)QueryUtil.list(q, getDialect(),
2571 start, end);
2572 }
2573 }
2574 catch (Exception e) {
2575 throw processException(e);
2576 }
2577 finally {
2578 if (list == null) {
2579 FinderCacheUtil.removeResult(finderPath, finderArgs);
2580 }
2581 else {
2582 cacheResult(list);
2583
2584 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2585 }
2586
2587 closeSession(session);
2588 }
2589 }
2590
2591 return list;
2592 }
2593
2594
2600 public void removeByUuid(String uuid) throws SystemException {
2601 for (DDLRecordSet ddlRecordSet : findByUuid(uuid)) {
2602 remove(ddlRecordSet);
2603 }
2604 }
2605
2606
2614 public DDLRecordSet removeByUUID_G(String uuid, long groupId)
2615 throws NoSuchRecordSetException, SystemException {
2616 DDLRecordSet ddlRecordSet = findByUUID_G(uuid, groupId);
2617
2618 return remove(ddlRecordSet);
2619 }
2620
2621
2628 public void removeByUuid_C(String uuid, long companyId)
2629 throws SystemException {
2630 for (DDLRecordSet ddlRecordSet : findByUuid_C(uuid, companyId)) {
2631 remove(ddlRecordSet);
2632 }
2633 }
2634
2635
2641 public void removeByGroupId(long groupId) throws SystemException {
2642 for (DDLRecordSet ddlRecordSet : findByGroupId(groupId)) {
2643 remove(ddlRecordSet);
2644 }
2645 }
2646
2647
2655 public DDLRecordSet removeByG_R(long groupId, String recordSetKey)
2656 throws NoSuchRecordSetException, SystemException {
2657 DDLRecordSet ddlRecordSet = findByG_R(groupId, recordSetKey);
2658
2659 return remove(ddlRecordSet);
2660 }
2661
2662
2667 public void removeAll() throws SystemException {
2668 for (DDLRecordSet ddlRecordSet : findAll()) {
2669 remove(ddlRecordSet);
2670 }
2671 }
2672
2673
2680 public int countByUuid(String uuid) throws SystemException {
2681 Object[] finderArgs = new Object[] { uuid };
2682
2683 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2684 finderArgs, this);
2685
2686 if (count == null) {
2687 StringBundler query = new StringBundler(2);
2688
2689 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
2690
2691 if (uuid == null) {
2692 query.append(_FINDER_COLUMN_UUID_UUID_1);
2693 }
2694 else {
2695 if (uuid.equals(StringPool.BLANK)) {
2696 query.append(_FINDER_COLUMN_UUID_UUID_3);
2697 }
2698 else {
2699 query.append(_FINDER_COLUMN_UUID_UUID_2);
2700 }
2701 }
2702
2703 String sql = query.toString();
2704
2705 Session session = null;
2706
2707 try {
2708 session = openSession();
2709
2710 Query q = session.createQuery(sql);
2711
2712 QueryPos qPos = QueryPos.getInstance(q);
2713
2714 if (uuid != null) {
2715 qPos.add(uuid);
2716 }
2717
2718 count = (Long)q.uniqueResult();
2719 }
2720 catch (Exception e) {
2721 throw processException(e);
2722 }
2723 finally {
2724 if (count == null) {
2725 count = Long.valueOf(0);
2726 }
2727
2728 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2729 finderArgs, count);
2730
2731 closeSession(session);
2732 }
2733 }
2734
2735 return count.intValue();
2736 }
2737
2738
2746 public int countByUUID_G(String uuid, long groupId)
2747 throws SystemException {
2748 Object[] finderArgs = new Object[] { uuid, groupId };
2749
2750 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2751 finderArgs, this);
2752
2753 if (count == null) {
2754 StringBundler query = new StringBundler(3);
2755
2756 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
2757
2758 if (uuid == null) {
2759 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2760 }
2761 else {
2762 if (uuid.equals(StringPool.BLANK)) {
2763 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2764 }
2765 else {
2766 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2767 }
2768 }
2769
2770 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2771
2772 String sql = query.toString();
2773
2774 Session session = null;
2775
2776 try {
2777 session = openSession();
2778
2779 Query q = session.createQuery(sql);
2780
2781 QueryPos qPos = QueryPos.getInstance(q);
2782
2783 if (uuid != null) {
2784 qPos.add(uuid);
2785 }
2786
2787 qPos.add(groupId);
2788
2789 count = (Long)q.uniqueResult();
2790 }
2791 catch (Exception e) {
2792 throw processException(e);
2793 }
2794 finally {
2795 if (count == null) {
2796 count = Long.valueOf(0);
2797 }
2798
2799 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2800 finderArgs, count);
2801
2802 closeSession(session);
2803 }
2804 }
2805
2806 return count.intValue();
2807 }
2808
2809
2817 public int countByUuid_C(String uuid, long companyId)
2818 throws SystemException {
2819 Object[] finderArgs = new Object[] { uuid, companyId };
2820
2821 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
2822 finderArgs, this);
2823
2824 if (count == null) {
2825 StringBundler query = new StringBundler(3);
2826
2827 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
2828
2829 if (uuid == null) {
2830 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
2831 }
2832 else {
2833 if (uuid.equals(StringPool.BLANK)) {
2834 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
2835 }
2836 else {
2837 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
2838 }
2839 }
2840
2841 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
2842
2843 String sql = query.toString();
2844
2845 Session session = null;
2846
2847 try {
2848 session = openSession();
2849
2850 Query q = session.createQuery(sql);
2851
2852 QueryPos qPos = QueryPos.getInstance(q);
2853
2854 if (uuid != null) {
2855 qPos.add(uuid);
2856 }
2857
2858 qPos.add(companyId);
2859
2860 count = (Long)q.uniqueResult();
2861 }
2862 catch (Exception e) {
2863 throw processException(e);
2864 }
2865 finally {
2866 if (count == null) {
2867 count = Long.valueOf(0);
2868 }
2869
2870 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
2871 finderArgs, count);
2872
2873 closeSession(session);
2874 }
2875 }
2876
2877 return count.intValue();
2878 }
2879
2880
2887 public int countByGroupId(long groupId) throws SystemException {
2888 Object[] finderArgs = new Object[] { groupId };
2889
2890 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2891 finderArgs, this);
2892
2893 if (count == null) {
2894 StringBundler query = new StringBundler(2);
2895
2896 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
2897
2898 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2899
2900 String sql = query.toString();
2901
2902 Session session = null;
2903
2904 try {
2905 session = openSession();
2906
2907 Query q = session.createQuery(sql);
2908
2909 QueryPos qPos = QueryPos.getInstance(q);
2910
2911 qPos.add(groupId);
2912
2913 count = (Long)q.uniqueResult();
2914 }
2915 catch (Exception e) {
2916 throw processException(e);
2917 }
2918 finally {
2919 if (count == null) {
2920 count = Long.valueOf(0);
2921 }
2922
2923 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2924 finderArgs, count);
2925
2926 closeSession(session);
2927 }
2928 }
2929
2930 return count.intValue();
2931 }
2932
2933
2940 public int filterCountByGroupId(long groupId) throws SystemException {
2941 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2942 return countByGroupId(groupId);
2943 }
2944
2945 StringBundler query = new StringBundler(2);
2946
2947 query.append(_FILTER_SQL_COUNT_DDLRECORDSET_WHERE);
2948
2949 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2950
2951 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2952 DDLRecordSet.class.getName(),
2953 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2954
2955 Session session = null;
2956
2957 try {
2958 session = openSession();
2959
2960 SQLQuery q = session.createSQLQuery(sql);
2961
2962 q.addScalar(COUNT_COLUMN_NAME,
2963 com.liferay.portal.kernel.dao.orm.Type.LONG);
2964
2965 QueryPos qPos = QueryPos.getInstance(q);
2966
2967 qPos.add(groupId);
2968
2969 Long count = (Long)q.uniqueResult();
2970
2971 return count.intValue();
2972 }
2973 catch (Exception e) {
2974 throw processException(e);
2975 }
2976 finally {
2977 closeSession(session);
2978 }
2979 }
2980
2981
2989 public int countByG_R(long groupId, String recordSetKey)
2990 throws SystemException {
2991 Object[] finderArgs = new Object[] { groupId, recordSetKey };
2992
2993 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_R,
2994 finderArgs, this);
2995
2996 if (count == null) {
2997 StringBundler query = new StringBundler(3);
2998
2999 query.append(_SQL_COUNT_DDLRECORDSET_WHERE);
3000
3001 query.append(_FINDER_COLUMN_G_R_GROUPID_2);
3002
3003 if (recordSetKey == null) {
3004 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_1);
3005 }
3006 else {
3007 if (recordSetKey.equals(StringPool.BLANK)) {
3008 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_3);
3009 }
3010 else {
3011 query.append(_FINDER_COLUMN_G_R_RECORDSETKEY_2);
3012 }
3013 }
3014
3015 String sql = query.toString();
3016
3017 Session session = null;
3018
3019 try {
3020 session = openSession();
3021
3022 Query q = session.createQuery(sql);
3023
3024 QueryPos qPos = QueryPos.getInstance(q);
3025
3026 qPos.add(groupId);
3027
3028 if (recordSetKey != null) {
3029 qPos.add(recordSetKey);
3030 }
3031
3032 count = (Long)q.uniqueResult();
3033 }
3034 catch (Exception e) {
3035 throw processException(e);
3036 }
3037 finally {
3038 if (count == null) {
3039 count = Long.valueOf(0);
3040 }
3041
3042 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_R, finderArgs,
3043 count);
3044
3045 closeSession(session);
3046 }
3047 }
3048
3049 return count.intValue();
3050 }
3051
3052
3058 public int countAll() throws SystemException {
3059 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3060 FINDER_ARGS_EMPTY, this);
3061
3062 if (count == null) {
3063 Session session = null;
3064
3065 try {
3066 session = openSession();
3067
3068 Query q = session.createQuery(_SQL_COUNT_DDLRECORDSET);
3069
3070 count = (Long)q.uniqueResult();
3071 }
3072 catch (Exception e) {
3073 throw processException(e);
3074 }
3075 finally {
3076 if (count == null) {
3077 count = Long.valueOf(0);
3078 }
3079
3080 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3081 FINDER_ARGS_EMPTY, count);
3082
3083 closeSession(session);
3084 }
3085 }
3086
3087 return count.intValue();
3088 }
3089
3090
3093 public void afterPropertiesSet() {
3094 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3095 com.liferay.portal.util.PropsUtil.get(
3096 "value.object.listener.com.liferay.portlet.dynamicdatalists.model.DDLRecordSet")));
3097
3098 if (listenerClassNames.length > 0) {
3099 try {
3100 List<ModelListener<DDLRecordSet>> listenersList = new ArrayList<ModelListener<DDLRecordSet>>();
3101
3102 for (String listenerClassName : listenerClassNames) {
3103 listenersList.add((ModelListener<DDLRecordSet>)InstanceFactory.newInstance(
3104 listenerClassName));
3105 }
3106
3107 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3108 }
3109 catch (Exception e) {
3110 _log.error(e);
3111 }
3112 }
3113 }
3114
3115 public void destroy() {
3116 EntityCacheUtil.removeCache(DDLRecordSetImpl.class.getName());
3117 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3118 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3119 }
3120
3121 @BeanReference(type = DDLRecordPersistence.class)
3122 protected DDLRecordPersistence ddlRecordPersistence;
3123 @BeanReference(type = DDLRecordSetPersistence.class)
3124 protected DDLRecordSetPersistence ddlRecordSetPersistence;
3125 @BeanReference(type = DDLRecordVersionPersistence.class)
3126 protected DDLRecordVersionPersistence ddlRecordVersionPersistence;
3127 @BeanReference(type = UserPersistence.class)
3128 protected UserPersistence userPersistence;
3129 @BeanReference(type = DDMStructurePersistence.class)
3130 protected DDMStructurePersistence ddmStructurePersistence;
3131 @BeanReference(type = DDMStructureLinkPersistence.class)
3132 protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
3133 private static final String _SQL_SELECT_DDLRECORDSET = "SELECT ddlRecordSet FROM DDLRecordSet ddlRecordSet";
3134 private static final String _SQL_SELECT_DDLRECORDSET_WHERE = "SELECT ddlRecordSet FROM DDLRecordSet ddlRecordSet WHERE ";
3135 private static final String _SQL_COUNT_DDLRECORDSET = "SELECT COUNT(ddlRecordSet) FROM DDLRecordSet ddlRecordSet";
3136 private static final String _SQL_COUNT_DDLRECORDSET_WHERE = "SELECT COUNT(ddlRecordSet) FROM DDLRecordSet ddlRecordSet WHERE ";
3137 private static final String _FINDER_COLUMN_UUID_UUID_1 = "ddlRecordSet.uuid IS NULL";
3138 private static final String _FINDER_COLUMN_UUID_UUID_2 = "ddlRecordSet.uuid = ?";
3139 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ddlRecordSet.uuid IS NULL OR ddlRecordSet.uuid = ?)";
3140 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "ddlRecordSet.uuid IS NULL AND ";
3141 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "ddlRecordSet.uuid = ? AND ";
3142 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(ddlRecordSet.uuid IS NULL OR ddlRecordSet.uuid = ?) AND ";
3143 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "ddlRecordSet.groupId = ?";
3144 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "ddlRecordSet.uuid IS NULL AND ";
3145 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "ddlRecordSet.uuid = ? AND ";
3146 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(ddlRecordSet.uuid IS NULL OR ddlRecordSet.uuid = ?) AND ";
3147 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "ddlRecordSet.companyId = ?";
3148 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "ddlRecordSet.groupId = ?";
3149 private static final String _FINDER_COLUMN_G_R_GROUPID_2 = "ddlRecordSet.groupId = ? AND ";
3150 private static final String _FINDER_COLUMN_G_R_RECORDSETKEY_1 = "ddlRecordSet.recordSetKey IS NULL";
3151 private static final String _FINDER_COLUMN_G_R_RECORDSETKEY_2 = "ddlRecordSet.recordSetKey = ?";
3152 private static final String _FINDER_COLUMN_G_R_RECORDSETKEY_3 = "(ddlRecordSet.recordSetKey IS NULL OR ddlRecordSet.recordSetKey = ?)";
3153 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "ddlRecordSet.recordSetId";
3154 private static final String _FILTER_SQL_SELECT_DDLRECORDSET_WHERE = "SELECT DISTINCT {ddlRecordSet.*} FROM DDLRecordSet ddlRecordSet WHERE ";
3155 private static final String _FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_1 =
3156 "SELECT {DDLRecordSet.*} FROM (SELECT DISTINCT ddlRecordSet.recordSetId FROM DDLRecordSet ddlRecordSet WHERE ";
3157 private static final String _FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_2 =
3158 ") TEMP_TABLE INNER JOIN DDLRecordSet ON TEMP_TABLE.recordSetId = DDLRecordSet.recordSetId";
3159 private static final String _FILTER_SQL_COUNT_DDLRECORDSET_WHERE = "SELECT COUNT(DISTINCT ddlRecordSet.recordSetId) AS COUNT_VALUE FROM DDLRecordSet ddlRecordSet WHERE ";
3160 private static final String _FILTER_ENTITY_ALIAS = "ddlRecordSet";
3161 private static final String _FILTER_ENTITY_TABLE = "DDLRecordSet";
3162 private static final String _ORDER_BY_ENTITY_ALIAS = "ddlRecordSet.";
3163 private static final String _ORDER_BY_ENTITY_TABLE = "DDLRecordSet.";
3164 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDLRecordSet exists with the primary key ";
3165 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDLRecordSet exists with the key {";
3166 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3167 private static Log _log = LogFactoryUtil.getLog(DDLRecordSetPersistenceImpl.class);
3168 private static DDLRecordSet _nullDDLRecordSet = new DDLRecordSetImpl() {
3169 @Override
3170 public Object clone() {
3171 return this;
3172 }
3173
3174 @Override
3175 public CacheModel<DDLRecordSet> toCacheModel() {
3176 return _nullDDLRecordSetCacheModel;
3177 }
3178 };
3179
3180 private static CacheModel<DDLRecordSet> _nullDDLRecordSetCacheModel = new CacheModel<DDLRecordSet>() {
3181 public DDLRecordSet toEntityModel() {
3182 return _nullDDLRecordSet;
3183 }
3184 };
3185 }