001
014
015 package com.liferay.portlet.mobiledevicerules.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.LayoutPersistence;
044 import com.liferay.portal.service.persistence.LayoutSetPersistence;
045 import com.liferay.portal.service.persistence.ResourcePersistence;
046 import com.liferay.portal.service.persistence.UserPersistence;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048
049 import com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException;
050 import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance;
051 import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleGroupInstanceImpl;
052 import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleGroupInstanceModelImpl;
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 MDRRuleGroupInstancePersistenceImpl extends BasePersistenceImpl<MDRRuleGroupInstance>
073 implements MDRRuleGroupInstancePersistence {
074
079 public static final String FINDER_CLASS_NAME_ENTITY = MDRRuleGroupInstanceImpl.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(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
085 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
086 MDRRuleGroupInstanceImpl.class,
087 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
088 new String[] {
089 String.class.getName(),
090
091 "java.lang.Integer", "java.lang.Integer",
092 "com.liferay.portal.kernel.util.OrderByComparator"
093 });
094 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
095 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
096 MDRRuleGroupInstanceImpl.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
098 new String[] { String.class.getName() },
099 MDRRuleGroupInstanceModelImpl.UUID_COLUMN_BITMASK);
100 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
101 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
103 new String[] { String.class.getName() });
104 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
105 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
106 MDRRuleGroupInstanceImpl.class, FINDER_CLASS_NAME_ENTITY,
107 "fetchByUUID_G",
108 new String[] { String.class.getName(), Long.class.getName() },
109 MDRRuleGroupInstanceModelImpl.UUID_COLUMN_BITMASK |
110 MDRRuleGroupInstanceModelImpl.GROUPID_COLUMN_BITMASK);
111 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
112 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
113 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
114 new String[] { String.class.getName(), Long.class.getName() });
115 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPID =
116 new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
117 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
118 MDRRuleGroupInstanceImpl.class,
119 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRuleGroupId",
120 new String[] {
121 Long.class.getName(),
122
123 "java.lang.Integer", "java.lang.Integer",
124 "com.liferay.portal.kernel.util.OrderByComparator"
125 });
126 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID =
127 new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
128 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
129 MDRRuleGroupInstanceImpl.class,
130 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRuleGroupId",
131 new String[] { Long.class.getName() },
132 MDRRuleGroupInstanceModelImpl.RULEGROUPID_COLUMN_BITMASK);
133 public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
134 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRuleGroupId",
136 new String[] { Long.class.getName() });
137 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
138 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
139 MDRRuleGroupInstanceImpl.class,
140 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
141 new String[] {
142 Long.class.getName(), Long.class.getName(),
143
144 "java.lang.Integer", "java.lang.Integer",
145 "com.liferay.portal.kernel.util.OrderByComparator"
146 });
147 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
148 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
149 MDRRuleGroupInstanceImpl.class,
150 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
151 new String[] { Long.class.getName(), Long.class.getName() },
152 MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
153 MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK);
154 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
155 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
156 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
157 new String[] { Long.class.getName(), Long.class.getName() });
158 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
159 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
160 MDRRuleGroupInstanceImpl.class,
161 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_C",
162 new String[] {
163 Long.class.getName(), Long.class.getName(), Long.class.getName(),
164
165 "java.lang.Integer", "java.lang.Integer",
166 "com.liferay.portal.kernel.util.OrderByComparator"
167 });
168 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
169 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
170 MDRRuleGroupInstanceImpl.class,
171 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
172 new String[] {
173 Long.class.getName(), Long.class.getName(), Long.class.getName()
174 },
175 MDRRuleGroupInstanceModelImpl.GROUPID_COLUMN_BITMASK |
176 MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
177 MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK);
178 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
179 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
180 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
181 new String[] {
182 Long.class.getName(), Long.class.getName(), Long.class.getName()
183 });
184 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_R = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
185 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
186 MDRRuleGroupInstanceImpl.class, FINDER_CLASS_NAME_ENTITY,
187 "fetchByC_C_R",
188 new String[] {
189 Long.class.getName(), Long.class.getName(), Long.class.getName()
190 },
191 MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
192 MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK |
193 MDRRuleGroupInstanceModelImpl.RULEGROUPID_COLUMN_BITMASK);
194 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_R = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
195 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
196 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_R",
197 new String[] {
198 Long.class.getName(), Long.class.getName(), Long.class.getName()
199 });
200 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
201 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
202 MDRRuleGroupInstanceImpl.class,
203 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
204 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
205 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
206 MDRRuleGroupInstanceImpl.class,
207 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
208 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
209 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
210 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
211
212
217 public void cacheResult(MDRRuleGroupInstance mdrRuleGroupInstance) {
218 EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
219 MDRRuleGroupInstanceImpl.class,
220 mdrRuleGroupInstance.getPrimaryKey(), mdrRuleGroupInstance);
221
222 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
223 new Object[] {
224 mdrRuleGroupInstance.getUuid(),
225 Long.valueOf(mdrRuleGroupInstance.getGroupId())
226 }, mdrRuleGroupInstance);
227
228 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
229 new Object[] {
230 Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
231 Long.valueOf(mdrRuleGroupInstance.getClassPK()),
232 Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
233 }, mdrRuleGroupInstance);
234
235 mdrRuleGroupInstance.resetOriginalValues();
236 }
237
238
243 public void cacheResult(List<MDRRuleGroupInstance> mdrRuleGroupInstances) {
244 for (MDRRuleGroupInstance mdrRuleGroupInstance : mdrRuleGroupInstances) {
245 if (EntityCacheUtil.getResult(
246 MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
247 MDRRuleGroupInstanceImpl.class,
248 mdrRuleGroupInstance.getPrimaryKey()) == null) {
249 cacheResult(mdrRuleGroupInstance);
250 }
251 else {
252 mdrRuleGroupInstance.resetOriginalValues();
253 }
254 }
255 }
256
257
264 @Override
265 public void clearCache() {
266 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
267 CacheRegistryUtil.clear(MDRRuleGroupInstanceImpl.class.getName());
268 }
269
270 EntityCacheUtil.clearCache(MDRRuleGroupInstanceImpl.class.getName());
271
272 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
273 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
274 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
275 }
276
277
284 @Override
285 public void clearCache(MDRRuleGroupInstance mdrRuleGroupInstance) {
286 EntityCacheUtil.removeResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
287 MDRRuleGroupInstanceImpl.class, mdrRuleGroupInstance.getPrimaryKey());
288
289 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
290 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
291
292 clearUniqueFindersCache(mdrRuleGroupInstance);
293 }
294
295 @Override
296 public void clearCache(List<MDRRuleGroupInstance> mdrRuleGroupInstances) {
297 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
298 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
299
300 for (MDRRuleGroupInstance mdrRuleGroupInstance : mdrRuleGroupInstances) {
301 EntityCacheUtil.removeResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
302 MDRRuleGroupInstanceImpl.class,
303 mdrRuleGroupInstance.getPrimaryKey());
304
305 clearUniqueFindersCache(mdrRuleGroupInstance);
306 }
307 }
308
309 protected void clearUniqueFindersCache(
310 MDRRuleGroupInstance mdrRuleGroupInstance) {
311 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
312 new Object[] {
313 mdrRuleGroupInstance.getUuid(),
314 Long.valueOf(mdrRuleGroupInstance.getGroupId())
315 });
316
317 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R,
318 new Object[] {
319 Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
320 Long.valueOf(mdrRuleGroupInstance.getClassPK()),
321 Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
322 });
323 }
324
325
331 public MDRRuleGroupInstance create(long ruleGroupInstanceId) {
332 MDRRuleGroupInstance mdrRuleGroupInstance = new MDRRuleGroupInstanceImpl();
333
334 mdrRuleGroupInstance.setNew(true);
335 mdrRuleGroupInstance.setPrimaryKey(ruleGroupInstanceId);
336
337 String uuid = PortalUUIDUtil.generate();
338
339 mdrRuleGroupInstance.setUuid(uuid);
340
341 return mdrRuleGroupInstance;
342 }
343
344
352 public MDRRuleGroupInstance remove(long ruleGroupInstanceId)
353 throws NoSuchRuleGroupInstanceException, SystemException {
354 return remove(Long.valueOf(ruleGroupInstanceId));
355 }
356
357
365 @Override
366 public MDRRuleGroupInstance remove(Serializable primaryKey)
367 throws NoSuchRuleGroupInstanceException, SystemException {
368 Session session = null;
369
370 try {
371 session = openSession();
372
373 MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)session.get(MDRRuleGroupInstanceImpl.class,
374 primaryKey);
375
376 if (mdrRuleGroupInstance == null) {
377 if (_log.isWarnEnabled()) {
378 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
379 }
380
381 throw new NoSuchRuleGroupInstanceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
382 primaryKey);
383 }
384
385 return remove(mdrRuleGroupInstance);
386 }
387 catch (NoSuchRuleGroupInstanceException nsee) {
388 throw nsee;
389 }
390 catch (Exception e) {
391 throw processException(e);
392 }
393 finally {
394 closeSession(session);
395 }
396 }
397
398 @Override
399 protected MDRRuleGroupInstance removeImpl(
400 MDRRuleGroupInstance mdrRuleGroupInstance) throws SystemException {
401 mdrRuleGroupInstance = toUnwrappedModel(mdrRuleGroupInstance);
402
403 Session session = null;
404
405 try {
406 session = openSession();
407
408 BatchSessionUtil.delete(session, mdrRuleGroupInstance);
409 }
410 catch (Exception e) {
411 throw processException(e);
412 }
413 finally {
414 closeSession(session);
415 }
416
417 clearCache(mdrRuleGroupInstance);
418
419 return mdrRuleGroupInstance;
420 }
421
422 @Override
423 public MDRRuleGroupInstance updateImpl(
424 com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance mdrRuleGroupInstance,
425 boolean merge) throws SystemException {
426 mdrRuleGroupInstance = toUnwrappedModel(mdrRuleGroupInstance);
427
428 boolean isNew = mdrRuleGroupInstance.isNew();
429
430 MDRRuleGroupInstanceModelImpl mdrRuleGroupInstanceModelImpl = (MDRRuleGroupInstanceModelImpl)mdrRuleGroupInstance;
431
432 if (Validator.isNull(mdrRuleGroupInstance.getUuid())) {
433 String uuid = PortalUUIDUtil.generate();
434
435 mdrRuleGroupInstance.setUuid(uuid);
436 }
437
438 Session session = null;
439
440 try {
441 session = openSession();
442
443 BatchSessionUtil.update(session, mdrRuleGroupInstance, merge);
444
445 mdrRuleGroupInstance.setNew(false);
446 }
447 catch (Exception e) {
448 throw processException(e);
449 }
450 finally {
451 closeSession(session);
452 }
453
454 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
455
456 if (isNew || !MDRRuleGroupInstanceModelImpl.COLUMN_BITMASK_ENABLED) {
457 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
458 }
459 else {
460 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
461 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
462 Object[] args = new Object[] {
463 mdrRuleGroupInstanceModelImpl.getOriginalUuid()
464 };
465
466 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
467 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
468 args);
469
470 args = new Object[] { mdrRuleGroupInstanceModelImpl.getUuid() };
471
472 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
473 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
474 args);
475 }
476
477 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
478 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID.getColumnBitmask()) != 0) {
479 Object[] args = new Object[] {
480 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalRuleGroupId())
481 };
482
483 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
484 args);
485 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID,
486 args);
487
488 args = new Object[] {
489 Long.valueOf(mdrRuleGroupInstanceModelImpl.getRuleGroupId())
490 };
491
492 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
493 args);
494 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID,
495 args);
496 }
497
498 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
499 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
500 Object[] args = new Object[] {
501 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
502 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK())
503 };
504
505 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
506 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
507 args);
508
509 args = new Object[] {
510 Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassNameId()),
511 Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassPK())
512 };
513
514 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
515 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
516 args);
517 }
518
519 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
520 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
521 Object[] args = new Object[] {
522 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalGroupId()),
523 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
524 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK())
525 };
526
527 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
528 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
529 args);
530
531 args = new Object[] {
532 Long.valueOf(mdrRuleGroupInstanceModelImpl.getGroupId()),
533 Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassNameId()),
534 Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassPK())
535 };
536
537 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
538 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
539 args);
540 }
541 }
542
543 EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
544 MDRRuleGroupInstanceImpl.class,
545 mdrRuleGroupInstance.getPrimaryKey(), mdrRuleGroupInstance);
546
547 if (isNew) {
548 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
549 new Object[] {
550 mdrRuleGroupInstance.getUuid(),
551 Long.valueOf(mdrRuleGroupInstance.getGroupId())
552 }, mdrRuleGroupInstance);
553
554 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
555 new Object[] {
556 Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
557 Long.valueOf(mdrRuleGroupInstance.getClassPK()),
558 Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
559 }, mdrRuleGroupInstance);
560 }
561 else {
562 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
563 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
564 Object[] args = new Object[] {
565 mdrRuleGroupInstanceModelImpl.getOriginalUuid(),
566 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalGroupId())
567 };
568
569 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
570 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
571
572 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
573 new Object[] {
574 mdrRuleGroupInstance.getUuid(),
575 Long.valueOf(mdrRuleGroupInstance.getGroupId())
576 }, mdrRuleGroupInstance);
577 }
578
579 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
580 FINDER_PATH_FETCH_BY_C_C_R.getColumnBitmask()) != 0) {
581 Object[] args = new Object[] {
582 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
583 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK()),
584 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalRuleGroupId())
585 };
586
587 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_R, args);
588 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R, args);
589
590 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
591 new Object[] {
592 Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
593 Long.valueOf(mdrRuleGroupInstance.getClassPK()),
594 Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
595 }, mdrRuleGroupInstance);
596 }
597 }
598
599 return mdrRuleGroupInstance;
600 }
601
602 protected MDRRuleGroupInstance toUnwrappedModel(
603 MDRRuleGroupInstance mdrRuleGroupInstance) {
604 if (mdrRuleGroupInstance instanceof MDRRuleGroupInstanceImpl) {
605 return mdrRuleGroupInstance;
606 }
607
608 MDRRuleGroupInstanceImpl mdrRuleGroupInstanceImpl = new MDRRuleGroupInstanceImpl();
609
610 mdrRuleGroupInstanceImpl.setNew(mdrRuleGroupInstance.isNew());
611 mdrRuleGroupInstanceImpl.setPrimaryKey(mdrRuleGroupInstance.getPrimaryKey());
612
613 mdrRuleGroupInstanceImpl.setUuid(mdrRuleGroupInstance.getUuid());
614 mdrRuleGroupInstanceImpl.setRuleGroupInstanceId(mdrRuleGroupInstance.getRuleGroupInstanceId());
615 mdrRuleGroupInstanceImpl.setGroupId(mdrRuleGroupInstance.getGroupId());
616 mdrRuleGroupInstanceImpl.setCompanyId(mdrRuleGroupInstance.getCompanyId());
617 mdrRuleGroupInstanceImpl.setUserId(mdrRuleGroupInstance.getUserId());
618 mdrRuleGroupInstanceImpl.setUserName(mdrRuleGroupInstance.getUserName());
619 mdrRuleGroupInstanceImpl.setCreateDate(mdrRuleGroupInstance.getCreateDate());
620 mdrRuleGroupInstanceImpl.setModifiedDate(mdrRuleGroupInstance.getModifiedDate());
621 mdrRuleGroupInstanceImpl.setClassNameId(mdrRuleGroupInstance.getClassNameId());
622 mdrRuleGroupInstanceImpl.setClassPK(mdrRuleGroupInstance.getClassPK());
623 mdrRuleGroupInstanceImpl.setRuleGroupId(mdrRuleGroupInstance.getRuleGroupId());
624 mdrRuleGroupInstanceImpl.setPriority(mdrRuleGroupInstance.getPriority());
625
626 return mdrRuleGroupInstanceImpl;
627 }
628
629
637 @Override
638 public MDRRuleGroupInstance findByPrimaryKey(Serializable primaryKey)
639 throws NoSuchModelException, SystemException {
640 return findByPrimaryKey(((Long)primaryKey).longValue());
641 }
642
643
651 public MDRRuleGroupInstance findByPrimaryKey(long ruleGroupInstanceId)
652 throws NoSuchRuleGroupInstanceException, SystemException {
653 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByPrimaryKey(ruleGroupInstanceId);
654
655 if (mdrRuleGroupInstance == null) {
656 if (_log.isWarnEnabled()) {
657 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
658 ruleGroupInstanceId);
659 }
660
661 throw new NoSuchRuleGroupInstanceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
662 ruleGroupInstanceId);
663 }
664
665 return mdrRuleGroupInstance;
666 }
667
668
675 @Override
676 public MDRRuleGroupInstance fetchByPrimaryKey(Serializable primaryKey)
677 throws SystemException {
678 return fetchByPrimaryKey(((Long)primaryKey).longValue());
679 }
680
681
688 public MDRRuleGroupInstance fetchByPrimaryKey(long ruleGroupInstanceId)
689 throws SystemException {
690 MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)EntityCacheUtil.getResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
691 MDRRuleGroupInstanceImpl.class, ruleGroupInstanceId);
692
693 if (mdrRuleGroupInstance == _nullMDRRuleGroupInstance) {
694 return null;
695 }
696
697 if (mdrRuleGroupInstance == null) {
698 Session session = null;
699
700 boolean hasException = false;
701
702 try {
703 session = openSession();
704
705 mdrRuleGroupInstance = (MDRRuleGroupInstance)session.get(MDRRuleGroupInstanceImpl.class,
706 Long.valueOf(ruleGroupInstanceId));
707 }
708 catch (Exception e) {
709 hasException = true;
710
711 throw processException(e);
712 }
713 finally {
714 if (mdrRuleGroupInstance != null) {
715 cacheResult(mdrRuleGroupInstance);
716 }
717 else if (!hasException) {
718 EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
719 MDRRuleGroupInstanceImpl.class, ruleGroupInstanceId,
720 _nullMDRRuleGroupInstance);
721 }
722
723 closeSession(session);
724 }
725 }
726
727 return mdrRuleGroupInstance;
728 }
729
730
737 public List<MDRRuleGroupInstance> findByUuid(String uuid)
738 throws SystemException {
739 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
740 }
741
742
755 public List<MDRRuleGroupInstance> findByUuid(String uuid, int start, int end)
756 throws SystemException {
757 return findByUuid(uuid, start, end, null);
758 }
759
760
774 public List<MDRRuleGroupInstance> findByUuid(String uuid, int start,
775 int end, OrderByComparator orderByComparator) throws SystemException {
776 FinderPath finderPath = null;
777 Object[] finderArgs = null;
778
779 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
780 (orderByComparator == null)) {
781 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
782 finderArgs = new Object[] { uuid };
783 }
784 else {
785 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
786 finderArgs = new Object[] { uuid, start, end, orderByComparator };
787 }
788
789 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
790 finderArgs, this);
791
792 if ((list != null) && !list.isEmpty()) {
793 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
794 if (!Validator.equals(uuid, mdrRuleGroupInstance.getUuid())) {
795 list = null;
796
797 break;
798 }
799 }
800 }
801
802 if (list == null) {
803 StringBundler query = null;
804
805 if (orderByComparator != null) {
806 query = new StringBundler(3 +
807 (orderByComparator.getOrderByFields().length * 3));
808 }
809 else {
810 query = new StringBundler(2);
811 }
812
813 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
814
815 if (uuid == null) {
816 query.append(_FINDER_COLUMN_UUID_UUID_1);
817 }
818 else {
819 if (uuid.equals(StringPool.BLANK)) {
820 query.append(_FINDER_COLUMN_UUID_UUID_3);
821 }
822 else {
823 query.append(_FINDER_COLUMN_UUID_UUID_2);
824 }
825 }
826
827 if (orderByComparator != null) {
828 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
829 orderByComparator);
830 }
831
832 String sql = query.toString();
833
834 Session session = null;
835
836 try {
837 session = openSession();
838
839 Query q = session.createQuery(sql);
840
841 QueryPos qPos = QueryPos.getInstance(q);
842
843 if (uuid != null) {
844 qPos.add(uuid);
845 }
846
847 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
848 getDialect(), start, end);
849 }
850 catch (Exception e) {
851 throw processException(e);
852 }
853 finally {
854 if (list == null) {
855 FinderCacheUtil.removeResult(finderPath, finderArgs);
856 }
857 else {
858 cacheResult(list);
859
860 FinderCacheUtil.putResult(finderPath, finderArgs, list);
861 }
862
863 closeSession(session);
864 }
865 }
866
867 return list;
868 }
869
870
883 public MDRRuleGroupInstance findByUuid_First(String uuid,
884 OrderByComparator orderByComparator)
885 throws NoSuchRuleGroupInstanceException, SystemException {
886 List<MDRRuleGroupInstance> list = findByUuid(uuid, 0, 1,
887 orderByComparator);
888
889 if (list.isEmpty()) {
890 StringBundler msg = new StringBundler(4);
891
892 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
893
894 msg.append("uuid=");
895 msg.append(uuid);
896
897 msg.append(StringPool.CLOSE_CURLY_BRACE);
898
899 throw new NoSuchRuleGroupInstanceException(msg.toString());
900 }
901 else {
902 return list.get(0);
903 }
904 }
905
906
919 public MDRRuleGroupInstance findByUuid_Last(String uuid,
920 OrderByComparator orderByComparator)
921 throws NoSuchRuleGroupInstanceException, SystemException {
922 int count = countByUuid(uuid);
923
924 List<MDRRuleGroupInstance> list = findByUuid(uuid, count - 1, count,
925 orderByComparator);
926
927 if (list.isEmpty()) {
928 StringBundler msg = new StringBundler(4);
929
930 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
931
932 msg.append("uuid=");
933 msg.append(uuid);
934
935 msg.append(StringPool.CLOSE_CURLY_BRACE);
936
937 throw new NoSuchRuleGroupInstanceException(msg.toString());
938 }
939 else {
940 return list.get(0);
941 }
942 }
943
944
958 public MDRRuleGroupInstance[] findByUuid_PrevAndNext(
959 long ruleGroupInstanceId, String uuid,
960 OrderByComparator orderByComparator)
961 throws NoSuchRuleGroupInstanceException, SystemException {
962 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
963
964 Session session = null;
965
966 try {
967 session = openSession();
968
969 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
970
971 array[0] = getByUuid_PrevAndNext(session, mdrRuleGroupInstance,
972 uuid, orderByComparator, true);
973
974 array[1] = mdrRuleGroupInstance;
975
976 array[2] = getByUuid_PrevAndNext(session, mdrRuleGroupInstance,
977 uuid, orderByComparator, false);
978
979 return array;
980 }
981 catch (Exception e) {
982 throw processException(e);
983 }
984 finally {
985 closeSession(session);
986 }
987 }
988
989 protected MDRRuleGroupInstance getByUuid_PrevAndNext(Session session,
990 MDRRuleGroupInstance mdrRuleGroupInstance, String uuid,
991 OrderByComparator orderByComparator, boolean previous) {
992 StringBundler query = null;
993
994 if (orderByComparator != null) {
995 query = new StringBundler(6 +
996 (orderByComparator.getOrderByFields().length * 6));
997 }
998 else {
999 query = new StringBundler(3);
1000 }
1001
1002 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1003
1004 if (uuid == null) {
1005 query.append(_FINDER_COLUMN_UUID_UUID_1);
1006 }
1007 else {
1008 if (uuid.equals(StringPool.BLANK)) {
1009 query.append(_FINDER_COLUMN_UUID_UUID_3);
1010 }
1011 else {
1012 query.append(_FINDER_COLUMN_UUID_UUID_2);
1013 }
1014 }
1015
1016 if (orderByComparator != null) {
1017 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1018
1019 if (orderByConditionFields.length > 0) {
1020 query.append(WHERE_AND);
1021 }
1022
1023 for (int i = 0; i < orderByConditionFields.length; i++) {
1024 query.append(_ORDER_BY_ENTITY_ALIAS);
1025 query.append(orderByConditionFields[i]);
1026
1027 if ((i + 1) < orderByConditionFields.length) {
1028 if (orderByComparator.isAscending() ^ previous) {
1029 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1030 }
1031 else {
1032 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1033 }
1034 }
1035 else {
1036 if (orderByComparator.isAscending() ^ previous) {
1037 query.append(WHERE_GREATER_THAN);
1038 }
1039 else {
1040 query.append(WHERE_LESSER_THAN);
1041 }
1042 }
1043 }
1044
1045 query.append(ORDER_BY_CLAUSE);
1046
1047 String[] orderByFields = orderByComparator.getOrderByFields();
1048
1049 for (int i = 0; i < orderByFields.length; i++) {
1050 query.append(_ORDER_BY_ENTITY_ALIAS);
1051 query.append(orderByFields[i]);
1052
1053 if ((i + 1) < orderByFields.length) {
1054 if (orderByComparator.isAscending() ^ previous) {
1055 query.append(ORDER_BY_ASC_HAS_NEXT);
1056 }
1057 else {
1058 query.append(ORDER_BY_DESC_HAS_NEXT);
1059 }
1060 }
1061 else {
1062 if (orderByComparator.isAscending() ^ previous) {
1063 query.append(ORDER_BY_ASC);
1064 }
1065 else {
1066 query.append(ORDER_BY_DESC);
1067 }
1068 }
1069 }
1070 }
1071
1072 String sql = query.toString();
1073
1074 Query q = session.createQuery(sql);
1075
1076 q.setFirstResult(0);
1077 q.setMaxResults(2);
1078
1079 QueryPos qPos = QueryPos.getInstance(q);
1080
1081 if (uuid != null) {
1082 qPos.add(uuid);
1083 }
1084
1085 if (orderByComparator != null) {
1086 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
1087
1088 for (Object value : values) {
1089 qPos.add(value);
1090 }
1091 }
1092
1093 List<MDRRuleGroupInstance> list = q.list();
1094
1095 if (list.size() == 2) {
1096 return list.get(1);
1097 }
1098 else {
1099 return null;
1100 }
1101 }
1102
1103
1112 public MDRRuleGroupInstance findByUUID_G(String uuid, long groupId)
1113 throws NoSuchRuleGroupInstanceException, SystemException {
1114 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUUID_G(uuid, groupId);
1115
1116 if (mdrRuleGroupInstance == null) {
1117 StringBundler msg = new StringBundler(6);
1118
1119 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1120
1121 msg.append("uuid=");
1122 msg.append(uuid);
1123
1124 msg.append(", groupId=");
1125 msg.append(groupId);
1126
1127 msg.append(StringPool.CLOSE_CURLY_BRACE);
1128
1129 if (_log.isWarnEnabled()) {
1130 _log.warn(msg.toString());
1131 }
1132
1133 throw new NoSuchRuleGroupInstanceException(msg.toString());
1134 }
1135
1136 return mdrRuleGroupInstance;
1137 }
1138
1139
1147 public MDRRuleGroupInstance fetchByUUID_G(String uuid, long groupId)
1148 throws SystemException {
1149 return fetchByUUID_G(uuid, groupId, true);
1150 }
1151
1152
1161 public MDRRuleGroupInstance fetchByUUID_G(String uuid, long groupId,
1162 boolean retrieveFromCache) throws SystemException {
1163 Object[] finderArgs = new Object[] { uuid, groupId };
1164
1165 Object result = null;
1166
1167 if (retrieveFromCache) {
1168 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1169 finderArgs, this);
1170 }
1171
1172 if (result instanceof MDRRuleGroupInstance) {
1173 MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)result;
1174
1175 if (!Validator.equals(uuid, mdrRuleGroupInstance.getUuid()) ||
1176 (groupId != mdrRuleGroupInstance.getGroupId())) {
1177 result = null;
1178 }
1179 }
1180
1181 if (result == null) {
1182 StringBundler query = new StringBundler(3);
1183
1184 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1185
1186 if (uuid == null) {
1187 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1188 }
1189 else {
1190 if (uuid.equals(StringPool.BLANK)) {
1191 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1192 }
1193 else {
1194 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1195 }
1196 }
1197
1198 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1199
1200 String sql = query.toString();
1201
1202 Session session = null;
1203
1204 try {
1205 session = openSession();
1206
1207 Query q = session.createQuery(sql);
1208
1209 QueryPos qPos = QueryPos.getInstance(q);
1210
1211 if (uuid != null) {
1212 qPos.add(uuid);
1213 }
1214
1215 qPos.add(groupId);
1216
1217 List<MDRRuleGroupInstance> list = q.list();
1218
1219 result = list;
1220
1221 MDRRuleGroupInstance mdrRuleGroupInstance = null;
1222
1223 if (list.isEmpty()) {
1224 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1225 finderArgs, list);
1226 }
1227 else {
1228 mdrRuleGroupInstance = list.get(0);
1229
1230 cacheResult(mdrRuleGroupInstance);
1231
1232 if ((mdrRuleGroupInstance.getUuid() == null) ||
1233 !mdrRuleGroupInstance.getUuid().equals(uuid) ||
1234 (mdrRuleGroupInstance.getGroupId() != groupId)) {
1235 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1236 finderArgs, mdrRuleGroupInstance);
1237 }
1238 }
1239
1240 return mdrRuleGroupInstance;
1241 }
1242 catch (Exception e) {
1243 throw processException(e);
1244 }
1245 finally {
1246 if (result == null) {
1247 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1248 finderArgs);
1249 }
1250
1251 closeSession(session);
1252 }
1253 }
1254 else {
1255 if (result instanceof List<?>) {
1256 return null;
1257 }
1258 else {
1259 return (MDRRuleGroupInstance)result;
1260 }
1261 }
1262 }
1263
1264
1271 public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId)
1272 throws SystemException {
1273 return findByRuleGroupId(ruleGroupId, QueryUtil.ALL_POS,
1274 QueryUtil.ALL_POS, null);
1275 }
1276
1277
1290 public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId,
1291 int start, int end) throws SystemException {
1292 return findByRuleGroupId(ruleGroupId, start, end, null);
1293 }
1294
1295
1309 public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId,
1310 int start, int end, OrderByComparator orderByComparator)
1311 throws SystemException {
1312 FinderPath finderPath = null;
1313 Object[] finderArgs = null;
1314
1315 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1316 (orderByComparator == null)) {
1317 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID;
1318 finderArgs = new Object[] { ruleGroupId };
1319 }
1320 else {
1321 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPID;
1322 finderArgs = new Object[] { ruleGroupId, start, end, orderByComparator };
1323 }
1324
1325 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
1326 finderArgs, this);
1327
1328 if ((list != null) && !list.isEmpty()) {
1329 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
1330 if ((ruleGroupId != mdrRuleGroupInstance.getRuleGroupId())) {
1331 list = null;
1332
1333 break;
1334 }
1335 }
1336 }
1337
1338 if (list == null) {
1339 StringBundler query = null;
1340
1341 if (orderByComparator != null) {
1342 query = new StringBundler(3 +
1343 (orderByComparator.getOrderByFields().length * 3));
1344 }
1345 else {
1346 query = new StringBundler(2);
1347 }
1348
1349 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1350
1351 query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
1352
1353 if (orderByComparator != null) {
1354 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1355 orderByComparator);
1356 }
1357
1358 String sql = query.toString();
1359
1360 Session session = null;
1361
1362 try {
1363 session = openSession();
1364
1365 Query q = session.createQuery(sql);
1366
1367 QueryPos qPos = QueryPos.getInstance(q);
1368
1369 qPos.add(ruleGroupId);
1370
1371 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
1372 getDialect(), start, end);
1373 }
1374 catch (Exception e) {
1375 throw processException(e);
1376 }
1377 finally {
1378 if (list == null) {
1379 FinderCacheUtil.removeResult(finderPath, finderArgs);
1380 }
1381 else {
1382 cacheResult(list);
1383
1384 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1385 }
1386
1387 closeSession(session);
1388 }
1389 }
1390
1391 return list;
1392 }
1393
1394
1407 public MDRRuleGroupInstance findByRuleGroupId_First(long ruleGroupId,
1408 OrderByComparator orderByComparator)
1409 throws NoSuchRuleGroupInstanceException, SystemException {
1410 List<MDRRuleGroupInstance> list = findByRuleGroupId(ruleGroupId, 0, 1,
1411 orderByComparator);
1412
1413 if (list.isEmpty()) {
1414 StringBundler msg = new StringBundler(4);
1415
1416 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1417
1418 msg.append("ruleGroupId=");
1419 msg.append(ruleGroupId);
1420
1421 msg.append(StringPool.CLOSE_CURLY_BRACE);
1422
1423 throw new NoSuchRuleGroupInstanceException(msg.toString());
1424 }
1425 else {
1426 return list.get(0);
1427 }
1428 }
1429
1430
1443 public MDRRuleGroupInstance findByRuleGroupId_Last(long ruleGroupId,
1444 OrderByComparator orderByComparator)
1445 throws NoSuchRuleGroupInstanceException, SystemException {
1446 int count = countByRuleGroupId(ruleGroupId);
1447
1448 List<MDRRuleGroupInstance> list = findByRuleGroupId(ruleGroupId,
1449 count - 1, count, orderByComparator);
1450
1451 if (list.isEmpty()) {
1452 StringBundler msg = new StringBundler(4);
1453
1454 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1455
1456 msg.append("ruleGroupId=");
1457 msg.append(ruleGroupId);
1458
1459 msg.append(StringPool.CLOSE_CURLY_BRACE);
1460
1461 throw new NoSuchRuleGroupInstanceException(msg.toString());
1462 }
1463 else {
1464 return list.get(0);
1465 }
1466 }
1467
1468
1482 public MDRRuleGroupInstance[] findByRuleGroupId_PrevAndNext(
1483 long ruleGroupInstanceId, long ruleGroupId,
1484 OrderByComparator orderByComparator)
1485 throws NoSuchRuleGroupInstanceException, SystemException {
1486 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
1487
1488 Session session = null;
1489
1490 try {
1491 session = openSession();
1492
1493 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
1494
1495 array[0] = getByRuleGroupId_PrevAndNext(session,
1496 mdrRuleGroupInstance, ruleGroupId, orderByComparator, true);
1497
1498 array[1] = mdrRuleGroupInstance;
1499
1500 array[2] = getByRuleGroupId_PrevAndNext(session,
1501 mdrRuleGroupInstance, ruleGroupId, orderByComparator, false);
1502
1503 return array;
1504 }
1505 catch (Exception e) {
1506 throw processException(e);
1507 }
1508 finally {
1509 closeSession(session);
1510 }
1511 }
1512
1513 protected MDRRuleGroupInstance getByRuleGroupId_PrevAndNext(
1514 Session session, MDRRuleGroupInstance mdrRuleGroupInstance,
1515 long ruleGroupId, OrderByComparator orderByComparator, boolean previous) {
1516 StringBundler query = null;
1517
1518 if (orderByComparator != null) {
1519 query = new StringBundler(6 +
1520 (orderByComparator.getOrderByFields().length * 6));
1521 }
1522 else {
1523 query = new StringBundler(3);
1524 }
1525
1526 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1527
1528 query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
1529
1530 if (orderByComparator != null) {
1531 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1532
1533 if (orderByConditionFields.length > 0) {
1534 query.append(WHERE_AND);
1535 }
1536
1537 for (int i = 0; i < orderByConditionFields.length; i++) {
1538 query.append(_ORDER_BY_ENTITY_ALIAS);
1539 query.append(orderByConditionFields[i]);
1540
1541 if ((i + 1) < orderByConditionFields.length) {
1542 if (orderByComparator.isAscending() ^ previous) {
1543 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1544 }
1545 else {
1546 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1547 }
1548 }
1549 else {
1550 if (orderByComparator.isAscending() ^ previous) {
1551 query.append(WHERE_GREATER_THAN);
1552 }
1553 else {
1554 query.append(WHERE_LESSER_THAN);
1555 }
1556 }
1557 }
1558
1559 query.append(ORDER_BY_CLAUSE);
1560
1561 String[] orderByFields = orderByComparator.getOrderByFields();
1562
1563 for (int i = 0; i < orderByFields.length; i++) {
1564 query.append(_ORDER_BY_ENTITY_ALIAS);
1565 query.append(orderByFields[i]);
1566
1567 if ((i + 1) < orderByFields.length) {
1568 if (orderByComparator.isAscending() ^ previous) {
1569 query.append(ORDER_BY_ASC_HAS_NEXT);
1570 }
1571 else {
1572 query.append(ORDER_BY_DESC_HAS_NEXT);
1573 }
1574 }
1575 else {
1576 if (orderByComparator.isAscending() ^ previous) {
1577 query.append(ORDER_BY_ASC);
1578 }
1579 else {
1580 query.append(ORDER_BY_DESC);
1581 }
1582 }
1583 }
1584 }
1585
1586 String sql = query.toString();
1587
1588 Query q = session.createQuery(sql);
1589
1590 q.setFirstResult(0);
1591 q.setMaxResults(2);
1592
1593 QueryPos qPos = QueryPos.getInstance(q);
1594
1595 qPos.add(ruleGroupId);
1596
1597 if (orderByComparator != null) {
1598 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
1599
1600 for (Object value : values) {
1601 qPos.add(value);
1602 }
1603 }
1604
1605 List<MDRRuleGroupInstance> list = q.list();
1606
1607 if (list.size() == 2) {
1608 return list.get(1);
1609 }
1610 else {
1611 return null;
1612 }
1613 }
1614
1615
1623 public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK)
1624 throws SystemException {
1625 return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
1626 QueryUtil.ALL_POS, null);
1627 }
1628
1629
1643 public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK,
1644 int start, int end) throws SystemException {
1645 return findByC_C(classNameId, classPK, start, end, null);
1646 }
1647
1648
1663 public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK,
1664 int start, int end, OrderByComparator orderByComparator)
1665 throws SystemException {
1666 FinderPath finderPath = null;
1667 Object[] finderArgs = null;
1668
1669 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1670 (orderByComparator == null)) {
1671 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
1672 finderArgs = new Object[] { classNameId, classPK };
1673 }
1674 else {
1675 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
1676 finderArgs = new Object[] {
1677 classNameId, classPK,
1678
1679 start, end, orderByComparator
1680 };
1681 }
1682
1683 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
1684 finderArgs, this);
1685
1686 if ((list != null) && !list.isEmpty()) {
1687 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
1688 if ((classNameId != mdrRuleGroupInstance.getClassNameId()) ||
1689 (classPK != mdrRuleGroupInstance.getClassPK())) {
1690 list = null;
1691
1692 break;
1693 }
1694 }
1695 }
1696
1697 if (list == null) {
1698 StringBundler query = null;
1699
1700 if (orderByComparator != null) {
1701 query = new StringBundler(4 +
1702 (orderByComparator.getOrderByFields().length * 3));
1703 }
1704 else {
1705 query = new StringBundler(3);
1706 }
1707
1708 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1709
1710 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1711
1712 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1713
1714 if (orderByComparator != null) {
1715 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1716 orderByComparator);
1717 }
1718
1719 String sql = query.toString();
1720
1721 Session session = null;
1722
1723 try {
1724 session = openSession();
1725
1726 Query q = session.createQuery(sql);
1727
1728 QueryPos qPos = QueryPos.getInstance(q);
1729
1730 qPos.add(classNameId);
1731
1732 qPos.add(classPK);
1733
1734 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
1735 getDialect(), start, end);
1736 }
1737 catch (Exception e) {
1738 throw processException(e);
1739 }
1740 finally {
1741 if (list == null) {
1742 FinderCacheUtil.removeResult(finderPath, finderArgs);
1743 }
1744 else {
1745 cacheResult(list);
1746
1747 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1748 }
1749
1750 closeSession(session);
1751 }
1752 }
1753
1754 return list;
1755 }
1756
1757
1771 public MDRRuleGroupInstance findByC_C_First(long classNameId, long classPK,
1772 OrderByComparator orderByComparator)
1773 throws NoSuchRuleGroupInstanceException, SystemException {
1774 List<MDRRuleGroupInstance> list = findByC_C(classNameId, classPK, 0, 1,
1775 orderByComparator);
1776
1777 if (list.isEmpty()) {
1778 StringBundler msg = new StringBundler(6);
1779
1780 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1781
1782 msg.append("classNameId=");
1783 msg.append(classNameId);
1784
1785 msg.append(", classPK=");
1786 msg.append(classPK);
1787
1788 msg.append(StringPool.CLOSE_CURLY_BRACE);
1789
1790 throw new NoSuchRuleGroupInstanceException(msg.toString());
1791 }
1792 else {
1793 return list.get(0);
1794 }
1795 }
1796
1797
1811 public MDRRuleGroupInstance findByC_C_Last(long classNameId, long classPK,
1812 OrderByComparator orderByComparator)
1813 throws NoSuchRuleGroupInstanceException, SystemException {
1814 int count = countByC_C(classNameId, classPK);
1815
1816 List<MDRRuleGroupInstance> list = findByC_C(classNameId, classPK,
1817 count - 1, count, orderByComparator);
1818
1819 if (list.isEmpty()) {
1820 StringBundler msg = new StringBundler(6);
1821
1822 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1823
1824 msg.append("classNameId=");
1825 msg.append(classNameId);
1826
1827 msg.append(", classPK=");
1828 msg.append(classPK);
1829
1830 msg.append(StringPool.CLOSE_CURLY_BRACE);
1831
1832 throw new NoSuchRuleGroupInstanceException(msg.toString());
1833 }
1834 else {
1835 return list.get(0);
1836 }
1837 }
1838
1839
1854 public MDRRuleGroupInstance[] findByC_C_PrevAndNext(
1855 long ruleGroupInstanceId, long classNameId, long classPK,
1856 OrderByComparator orderByComparator)
1857 throws NoSuchRuleGroupInstanceException, SystemException {
1858 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
1859
1860 Session session = null;
1861
1862 try {
1863 session = openSession();
1864
1865 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
1866
1867 array[0] = getByC_C_PrevAndNext(session, mdrRuleGroupInstance,
1868 classNameId, classPK, orderByComparator, true);
1869
1870 array[1] = mdrRuleGroupInstance;
1871
1872 array[2] = getByC_C_PrevAndNext(session, mdrRuleGroupInstance,
1873 classNameId, classPK, orderByComparator, false);
1874
1875 return array;
1876 }
1877 catch (Exception e) {
1878 throw processException(e);
1879 }
1880 finally {
1881 closeSession(session);
1882 }
1883 }
1884
1885 protected MDRRuleGroupInstance getByC_C_PrevAndNext(Session session,
1886 MDRRuleGroupInstance mdrRuleGroupInstance, long classNameId,
1887 long classPK, OrderByComparator orderByComparator, boolean previous) {
1888 StringBundler query = null;
1889
1890 if (orderByComparator != null) {
1891 query = new StringBundler(6 +
1892 (orderByComparator.getOrderByFields().length * 6));
1893 }
1894 else {
1895 query = new StringBundler(3);
1896 }
1897
1898 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1899
1900 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1901
1902 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1903
1904 if (orderByComparator != null) {
1905 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1906
1907 if (orderByConditionFields.length > 0) {
1908 query.append(WHERE_AND);
1909 }
1910
1911 for (int i = 0; i < orderByConditionFields.length; i++) {
1912 query.append(_ORDER_BY_ENTITY_ALIAS);
1913 query.append(orderByConditionFields[i]);
1914
1915 if ((i + 1) < orderByConditionFields.length) {
1916 if (orderByComparator.isAscending() ^ previous) {
1917 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1918 }
1919 else {
1920 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1921 }
1922 }
1923 else {
1924 if (orderByComparator.isAscending() ^ previous) {
1925 query.append(WHERE_GREATER_THAN);
1926 }
1927 else {
1928 query.append(WHERE_LESSER_THAN);
1929 }
1930 }
1931 }
1932
1933 query.append(ORDER_BY_CLAUSE);
1934
1935 String[] orderByFields = orderByComparator.getOrderByFields();
1936
1937 for (int i = 0; i < orderByFields.length; i++) {
1938 query.append(_ORDER_BY_ENTITY_ALIAS);
1939 query.append(orderByFields[i]);
1940
1941 if ((i + 1) < orderByFields.length) {
1942 if (orderByComparator.isAscending() ^ previous) {
1943 query.append(ORDER_BY_ASC_HAS_NEXT);
1944 }
1945 else {
1946 query.append(ORDER_BY_DESC_HAS_NEXT);
1947 }
1948 }
1949 else {
1950 if (orderByComparator.isAscending() ^ previous) {
1951 query.append(ORDER_BY_ASC);
1952 }
1953 else {
1954 query.append(ORDER_BY_DESC);
1955 }
1956 }
1957 }
1958 }
1959
1960 String sql = query.toString();
1961
1962 Query q = session.createQuery(sql);
1963
1964 q.setFirstResult(0);
1965 q.setMaxResults(2);
1966
1967 QueryPos qPos = QueryPos.getInstance(q);
1968
1969 qPos.add(classNameId);
1970
1971 qPos.add(classPK);
1972
1973 if (orderByComparator != null) {
1974 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
1975
1976 for (Object value : values) {
1977 qPos.add(value);
1978 }
1979 }
1980
1981 List<MDRRuleGroupInstance> list = q.list();
1982
1983 if (list.size() == 2) {
1984 return list.get(1);
1985 }
1986 else {
1987 return null;
1988 }
1989 }
1990
1991
2000 public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
2001 long classNameId, long classPK) throws SystemException {
2002 return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
2003 QueryUtil.ALL_POS, null);
2004 }
2005
2006
2021 public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
2022 long classNameId, long classPK, int start, int end)
2023 throws SystemException {
2024 return findByG_C_C(groupId, classNameId, classPK, start, end, null);
2025 }
2026
2027
2043 public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
2044 long classNameId, long classPK, int start, int end,
2045 OrderByComparator orderByComparator) throws SystemException {
2046 FinderPath finderPath = null;
2047 Object[] finderArgs = null;
2048
2049 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2050 (orderByComparator == null)) {
2051 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
2052 finderArgs = new Object[] { groupId, classNameId, classPK };
2053 }
2054 else {
2055 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
2056 finderArgs = new Object[] {
2057 groupId, classNameId, classPK,
2058
2059 start, end, orderByComparator
2060 };
2061 }
2062
2063 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
2064 finderArgs, this);
2065
2066 if ((list != null) && !list.isEmpty()) {
2067 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
2068 if ((groupId != mdrRuleGroupInstance.getGroupId()) ||
2069 (classNameId != mdrRuleGroupInstance.getClassNameId()) ||
2070 (classPK != mdrRuleGroupInstance.getClassPK())) {
2071 list = null;
2072
2073 break;
2074 }
2075 }
2076 }
2077
2078 if (list == null) {
2079 StringBundler query = null;
2080
2081 if (orderByComparator != null) {
2082 query = new StringBundler(5 +
2083 (orderByComparator.getOrderByFields().length * 3));
2084 }
2085 else {
2086 query = new StringBundler(4);
2087 }
2088
2089 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2090
2091 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
2092
2093 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
2094
2095 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
2096
2097 if (orderByComparator != null) {
2098 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2099 orderByComparator);
2100 }
2101
2102 String sql = query.toString();
2103
2104 Session session = null;
2105
2106 try {
2107 session = openSession();
2108
2109 Query q = session.createQuery(sql);
2110
2111 QueryPos qPos = QueryPos.getInstance(q);
2112
2113 qPos.add(groupId);
2114
2115 qPos.add(classNameId);
2116
2117 qPos.add(classPK);
2118
2119 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
2120 getDialect(), start, end);
2121 }
2122 catch (Exception e) {
2123 throw processException(e);
2124 }
2125 finally {
2126 if (list == null) {
2127 FinderCacheUtil.removeResult(finderPath, finderArgs);
2128 }
2129 else {
2130 cacheResult(list);
2131
2132 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2133 }
2134
2135 closeSession(session);
2136 }
2137 }
2138
2139 return list;
2140 }
2141
2142
2157 public MDRRuleGroupInstance findByG_C_C_First(long groupId,
2158 long classNameId, long classPK, OrderByComparator orderByComparator)
2159 throws NoSuchRuleGroupInstanceException, SystemException {
2160 List<MDRRuleGroupInstance> list = findByG_C_C(groupId, classNameId,
2161 classPK, 0, 1, orderByComparator);
2162
2163 if (list.isEmpty()) {
2164 StringBundler msg = new StringBundler(8);
2165
2166 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2167
2168 msg.append("groupId=");
2169 msg.append(groupId);
2170
2171 msg.append(", classNameId=");
2172 msg.append(classNameId);
2173
2174 msg.append(", classPK=");
2175 msg.append(classPK);
2176
2177 msg.append(StringPool.CLOSE_CURLY_BRACE);
2178
2179 throw new NoSuchRuleGroupInstanceException(msg.toString());
2180 }
2181 else {
2182 return list.get(0);
2183 }
2184 }
2185
2186
2201 public MDRRuleGroupInstance findByG_C_C_Last(long groupId,
2202 long classNameId, long classPK, OrderByComparator orderByComparator)
2203 throws NoSuchRuleGroupInstanceException, SystemException {
2204 int count = countByG_C_C(groupId, classNameId, classPK);
2205
2206 List<MDRRuleGroupInstance> list = findByG_C_C(groupId, classNameId,
2207 classPK, count - 1, count, orderByComparator);
2208
2209 if (list.isEmpty()) {
2210 StringBundler msg = new StringBundler(8);
2211
2212 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2213
2214 msg.append("groupId=");
2215 msg.append(groupId);
2216
2217 msg.append(", classNameId=");
2218 msg.append(classNameId);
2219
2220 msg.append(", classPK=");
2221 msg.append(classPK);
2222
2223 msg.append(StringPool.CLOSE_CURLY_BRACE);
2224
2225 throw new NoSuchRuleGroupInstanceException(msg.toString());
2226 }
2227 else {
2228 return list.get(0);
2229 }
2230 }
2231
2232
2248 public MDRRuleGroupInstance[] findByG_C_C_PrevAndNext(
2249 long ruleGroupInstanceId, long groupId, long classNameId, long classPK,
2250 OrderByComparator orderByComparator)
2251 throws NoSuchRuleGroupInstanceException, SystemException {
2252 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
2253
2254 Session session = null;
2255
2256 try {
2257 session = openSession();
2258
2259 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
2260
2261 array[0] = getByG_C_C_PrevAndNext(session, mdrRuleGroupInstance,
2262 groupId, classNameId, classPK, orderByComparator, true);
2263
2264 array[1] = mdrRuleGroupInstance;
2265
2266 array[2] = getByG_C_C_PrevAndNext(session, mdrRuleGroupInstance,
2267 groupId, classNameId, classPK, orderByComparator, false);
2268
2269 return array;
2270 }
2271 catch (Exception e) {
2272 throw processException(e);
2273 }
2274 finally {
2275 closeSession(session);
2276 }
2277 }
2278
2279 protected MDRRuleGroupInstance getByG_C_C_PrevAndNext(Session session,
2280 MDRRuleGroupInstance mdrRuleGroupInstance, long groupId,
2281 long classNameId, long classPK, OrderByComparator orderByComparator,
2282 boolean previous) {
2283 StringBundler query = null;
2284
2285 if (orderByComparator != null) {
2286 query = new StringBundler(6 +
2287 (orderByComparator.getOrderByFields().length * 6));
2288 }
2289 else {
2290 query = new StringBundler(3);
2291 }
2292
2293 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2294
2295 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
2296
2297 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
2298
2299 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
2300
2301 if (orderByComparator != null) {
2302 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2303
2304 if (orderByConditionFields.length > 0) {
2305 query.append(WHERE_AND);
2306 }
2307
2308 for (int i = 0; i < orderByConditionFields.length; i++) {
2309 query.append(_ORDER_BY_ENTITY_ALIAS);
2310 query.append(orderByConditionFields[i]);
2311
2312 if ((i + 1) < orderByConditionFields.length) {
2313 if (orderByComparator.isAscending() ^ previous) {
2314 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2315 }
2316 else {
2317 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2318 }
2319 }
2320 else {
2321 if (orderByComparator.isAscending() ^ previous) {
2322 query.append(WHERE_GREATER_THAN);
2323 }
2324 else {
2325 query.append(WHERE_LESSER_THAN);
2326 }
2327 }
2328 }
2329
2330 query.append(ORDER_BY_CLAUSE);
2331
2332 String[] orderByFields = orderByComparator.getOrderByFields();
2333
2334 for (int i = 0; i < orderByFields.length; i++) {
2335 query.append(_ORDER_BY_ENTITY_ALIAS);
2336 query.append(orderByFields[i]);
2337
2338 if ((i + 1) < orderByFields.length) {
2339 if (orderByComparator.isAscending() ^ previous) {
2340 query.append(ORDER_BY_ASC_HAS_NEXT);
2341 }
2342 else {
2343 query.append(ORDER_BY_DESC_HAS_NEXT);
2344 }
2345 }
2346 else {
2347 if (orderByComparator.isAscending() ^ previous) {
2348 query.append(ORDER_BY_ASC);
2349 }
2350 else {
2351 query.append(ORDER_BY_DESC);
2352 }
2353 }
2354 }
2355 }
2356
2357 String sql = query.toString();
2358
2359 Query q = session.createQuery(sql);
2360
2361 q.setFirstResult(0);
2362 q.setMaxResults(2);
2363
2364 QueryPos qPos = QueryPos.getInstance(q);
2365
2366 qPos.add(groupId);
2367
2368 qPos.add(classNameId);
2369
2370 qPos.add(classPK);
2371
2372 if (orderByComparator != null) {
2373 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
2374
2375 for (Object value : values) {
2376 qPos.add(value);
2377 }
2378 }
2379
2380 List<MDRRuleGroupInstance> list = q.list();
2381
2382 if (list.size() == 2) {
2383 return list.get(1);
2384 }
2385 else {
2386 return null;
2387 }
2388 }
2389
2390
2399 public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
2400 long classNameId, long classPK) throws SystemException {
2401 return filterFindByG_C_C(groupId, classNameId, classPK,
2402 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2403 }
2404
2405
2420 public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
2421 long classNameId, long classPK, int start, int end)
2422 throws SystemException {
2423 return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
2424 }
2425
2426
2442 public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
2443 long classNameId, long classPK, int start, int end,
2444 OrderByComparator orderByComparator) throws SystemException {
2445 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2446 return findByG_C_C(groupId, classNameId, classPK, start, end,
2447 orderByComparator);
2448 }
2449
2450 StringBundler query = null;
2451
2452 if (orderByComparator != null) {
2453 query = new StringBundler(5 +
2454 (orderByComparator.getOrderByFields().length * 3));
2455 }
2456 else {
2457 query = new StringBundler(4);
2458 }
2459
2460 if (getDB().isSupportsInlineDistinct()) {
2461 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2462 }
2463 else {
2464 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
2465 }
2466
2467 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
2468
2469 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
2470
2471 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
2472
2473 if (!getDB().isSupportsInlineDistinct()) {
2474 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
2475 }
2476
2477 if (orderByComparator != null) {
2478 if (getDB().isSupportsInlineDistinct()) {
2479 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2480 orderByComparator);
2481 }
2482 else {
2483 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2484 orderByComparator);
2485 }
2486 }
2487
2488 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2489 MDRRuleGroupInstance.class.getName(),
2490 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2491
2492 Session session = null;
2493
2494 try {
2495 session = openSession();
2496
2497 SQLQuery q = session.createSQLQuery(sql);
2498
2499 if (getDB().isSupportsInlineDistinct()) {
2500 q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
2501 }
2502 else {
2503 q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
2504 }
2505
2506 QueryPos qPos = QueryPos.getInstance(q);
2507
2508 qPos.add(groupId);
2509
2510 qPos.add(classNameId);
2511
2512 qPos.add(classPK);
2513
2514 return (List<MDRRuleGroupInstance>)QueryUtil.list(q, getDialect(),
2515 start, end);
2516 }
2517 catch (Exception e) {
2518 throw processException(e);
2519 }
2520 finally {
2521 closeSession(session);
2522 }
2523 }
2524
2525
2537 public MDRRuleGroupInstance[] filterFindByG_C_C_PrevAndNext(
2538 long ruleGroupInstanceId, long groupId, long classNameId, long classPK,
2539 OrderByComparator orderByComparator)
2540 throws NoSuchRuleGroupInstanceException, SystemException {
2541 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2542 return findByG_C_C_PrevAndNext(ruleGroupInstanceId, groupId,
2543 classNameId, classPK, orderByComparator);
2544 }
2545
2546 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
2547
2548 Session session = null;
2549
2550 try {
2551 session = openSession();
2552
2553 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
2554
2555 array[0] = filterGetByG_C_C_PrevAndNext(session,
2556 mdrRuleGroupInstance, groupId, classNameId, classPK,
2557 orderByComparator, true);
2558
2559 array[1] = mdrRuleGroupInstance;
2560
2561 array[2] = filterGetByG_C_C_PrevAndNext(session,
2562 mdrRuleGroupInstance, groupId, classNameId, classPK,
2563 orderByComparator, false);
2564
2565 return array;
2566 }
2567 catch (Exception e) {
2568 throw processException(e);
2569 }
2570 finally {
2571 closeSession(session);
2572 }
2573 }
2574
2575 protected MDRRuleGroupInstance filterGetByG_C_C_PrevAndNext(
2576 Session session, MDRRuleGroupInstance mdrRuleGroupInstance,
2577 long groupId, long classNameId, long classPK,
2578 OrderByComparator orderByComparator, boolean previous) {
2579 StringBundler query = null;
2580
2581 if (orderByComparator != null) {
2582 query = new StringBundler(6 +
2583 (orderByComparator.getOrderByFields().length * 6));
2584 }
2585 else {
2586 query = new StringBundler(3);
2587 }
2588
2589 if (getDB().isSupportsInlineDistinct()) {
2590 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2591 }
2592 else {
2593 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
2594 }
2595
2596 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
2597
2598 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
2599
2600 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
2601
2602 if (!getDB().isSupportsInlineDistinct()) {
2603 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
2604 }
2605
2606 if (orderByComparator != null) {
2607 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2608
2609 if (orderByConditionFields.length > 0) {
2610 query.append(WHERE_AND);
2611 }
2612
2613 for (int i = 0; i < orderByConditionFields.length; i++) {
2614 if (getDB().isSupportsInlineDistinct()) {
2615 query.append(_ORDER_BY_ENTITY_ALIAS);
2616 }
2617 else {
2618 query.append(_ORDER_BY_ENTITY_TABLE);
2619 }
2620
2621 query.append(orderByConditionFields[i]);
2622
2623 if ((i + 1) < orderByConditionFields.length) {
2624 if (orderByComparator.isAscending() ^ previous) {
2625 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2626 }
2627 else {
2628 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2629 }
2630 }
2631 else {
2632 if (orderByComparator.isAscending() ^ previous) {
2633 query.append(WHERE_GREATER_THAN);
2634 }
2635 else {
2636 query.append(WHERE_LESSER_THAN);
2637 }
2638 }
2639 }
2640
2641 query.append(ORDER_BY_CLAUSE);
2642
2643 String[] orderByFields = orderByComparator.getOrderByFields();
2644
2645 for (int i = 0; i < orderByFields.length; i++) {
2646 if (getDB().isSupportsInlineDistinct()) {
2647 query.append(_ORDER_BY_ENTITY_ALIAS);
2648 }
2649 else {
2650 query.append(_ORDER_BY_ENTITY_TABLE);
2651 }
2652
2653 query.append(orderByFields[i]);
2654
2655 if ((i + 1) < orderByFields.length) {
2656 if (orderByComparator.isAscending() ^ previous) {
2657 query.append(ORDER_BY_ASC_HAS_NEXT);
2658 }
2659 else {
2660 query.append(ORDER_BY_DESC_HAS_NEXT);
2661 }
2662 }
2663 else {
2664 if (orderByComparator.isAscending() ^ previous) {
2665 query.append(ORDER_BY_ASC);
2666 }
2667 else {
2668 query.append(ORDER_BY_DESC);
2669 }
2670 }
2671 }
2672 }
2673
2674 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2675 MDRRuleGroupInstance.class.getName(),
2676 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2677
2678 SQLQuery q = session.createSQLQuery(sql);
2679
2680 q.setFirstResult(0);
2681 q.setMaxResults(2);
2682
2683 if (getDB().isSupportsInlineDistinct()) {
2684 q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
2685 }
2686 else {
2687 q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
2688 }
2689
2690 QueryPos qPos = QueryPos.getInstance(q);
2691
2692 qPos.add(groupId);
2693
2694 qPos.add(classNameId);
2695
2696 qPos.add(classPK);
2697
2698 if (orderByComparator != null) {
2699 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
2700
2701 for (Object value : values) {
2702 qPos.add(value);
2703 }
2704 }
2705
2706 List<MDRRuleGroupInstance> list = q.list();
2707
2708 if (list.size() == 2) {
2709 return list.get(1);
2710 }
2711 else {
2712 return null;
2713 }
2714 }
2715
2716
2726 public MDRRuleGroupInstance findByC_C_R(long classNameId, long classPK,
2727 long ruleGroupId)
2728 throws NoSuchRuleGroupInstanceException, SystemException {
2729 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByC_C_R(classNameId,
2730 classPK, ruleGroupId);
2731
2732 if (mdrRuleGroupInstance == null) {
2733 StringBundler msg = new StringBundler(8);
2734
2735 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2736
2737 msg.append("classNameId=");
2738 msg.append(classNameId);
2739
2740 msg.append(", classPK=");
2741 msg.append(classPK);
2742
2743 msg.append(", ruleGroupId=");
2744 msg.append(ruleGroupId);
2745
2746 msg.append(StringPool.CLOSE_CURLY_BRACE);
2747
2748 if (_log.isWarnEnabled()) {
2749 _log.warn(msg.toString());
2750 }
2751
2752 throw new NoSuchRuleGroupInstanceException(msg.toString());
2753 }
2754
2755 return mdrRuleGroupInstance;
2756 }
2757
2758
2767 public MDRRuleGroupInstance fetchByC_C_R(long classNameId, long classPK,
2768 long ruleGroupId) throws SystemException {
2769 return fetchByC_C_R(classNameId, classPK, ruleGroupId, true);
2770 }
2771
2772
2782 public MDRRuleGroupInstance fetchByC_C_R(long classNameId, long classPK,
2783 long ruleGroupId, boolean retrieveFromCache) throws SystemException {
2784 Object[] finderArgs = new Object[] { classNameId, classPK, ruleGroupId };
2785
2786 Object result = null;
2787
2788 if (retrieveFromCache) {
2789 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_R,
2790 finderArgs, this);
2791 }
2792
2793 if (result instanceof MDRRuleGroupInstance) {
2794 MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)result;
2795
2796 if ((classNameId != mdrRuleGroupInstance.getClassNameId()) ||
2797 (classPK != mdrRuleGroupInstance.getClassPK()) ||
2798 (ruleGroupId != mdrRuleGroupInstance.getRuleGroupId())) {
2799 result = null;
2800 }
2801 }
2802
2803 if (result == null) {
2804 StringBundler query = new StringBundler(4);
2805
2806 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2807
2808 query.append(_FINDER_COLUMN_C_C_R_CLASSNAMEID_2);
2809
2810 query.append(_FINDER_COLUMN_C_C_R_CLASSPK_2);
2811
2812 query.append(_FINDER_COLUMN_C_C_R_RULEGROUPID_2);
2813
2814 String sql = query.toString();
2815
2816 Session session = null;
2817
2818 try {
2819 session = openSession();
2820
2821 Query q = session.createQuery(sql);
2822
2823 QueryPos qPos = QueryPos.getInstance(q);
2824
2825 qPos.add(classNameId);
2826
2827 qPos.add(classPK);
2828
2829 qPos.add(ruleGroupId);
2830
2831 List<MDRRuleGroupInstance> list = q.list();
2832
2833 result = list;
2834
2835 MDRRuleGroupInstance mdrRuleGroupInstance = null;
2836
2837 if (list.isEmpty()) {
2838 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
2839 finderArgs, list);
2840 }
2841 else {
2842 mdrRuleGroupInstance = list.get(0);
2843
2844 cacheResult(mdrRuleGroupInstance);
2845
2846 if ((mdrRuleGroupInstance.getClassNameId() != classNameId) ||
2847 (mdrRuleGroupInstance.getClassPK() != classPK) ||
2848 (mdrRuleGroupInstance.getRuleGroupId() != ruleGroupId)) {
2849 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
2850 finderArgs, mdrRuleGroupInstance);
2851 }
2852 }
2853
2854 return mdrRuleGroupInstance;
2855 }
2856 catch (Exception e) {
2857 throw processException(e);
2858 }
2859 finally {
2860 if (result == null) {
2861 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R,
2862 finderArgs);
2863 }
2864
2865 closeSession(session);
2866 }
2867 }
2868 else {
2869 if (result instanceof List<?>) {
2870 return null;
2871 }
2872 else {
2873 return (MDRRuleGroupInstance)result;
2874 }
2875 }
2876 }
2877
2878
2884 public List<MDRRuleGroupInstance> findAll() throws SystemException {
2885 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2886 }
2887
2888
2900 public List<MDRRuleGroupInstance> findAll(int start, int end)
2901 throws SystemException {
2902 return findAll(start, end, null);
2903 }
2904
2905
2918 public List<MDRRuleGroupInstance> findAll(int start, int end,
2919 OrderByComparator orderByComparator) throws SystemException {
2920 FinderPath finderPath = null;
2921 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2922
2923 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2924 (orderByComparator == null)) {
2925 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2926 finderArgs = FINDER_ARGS_EMPTY;
2927 }
2928 else {
2929 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2930 finderArgs = new Object[] { start, end, orderByComparator };
2931 }
2932
2933 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
2934 finderArgs, this);
2935
2936 if (list == null) {
2937 StringBundler query = null;
2938 String sql = null;
2939
2940 if (orderByComparator != null) {
2941 query = new StringBundler(2 +
2942 (orderByComparator.getOrderByFields().length * 3));
2943
2944 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE);
2945
2946 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2947 orderByComparator);
2948
2949 sql = query.toString();
2950 }
2951 else {
2952 sql = _SQL_SELECT_MDRRULEGROUPINSTANCE;
2953 }
2954
2955 Session session = null;
2956
2957 try {
2958 session = openSession();
2959
2960 Query q = session.createQuery(sql);
2961
2962 if (orderByComparator == null) {
2963 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
2964 getDialect(), start, end, false);
2965
2966 Collections.sort(list);
2967 }
2968 else {
2969 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
2970 getDialect(), start, end);
2971 }
2972 }
2973 catch (Exception e) {
2974 throw processException(e);
2975 }
2976 finally {
2977 if (list == null) {
2978 FinderCacheUtil.removeResult(finderPath, finderArgs);
2979 }
2980 else {
2981 cacheResult(list);
2982
2983 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2984 }
2985
2986 closeSession(session);
2987 }
2988 }
2989
2990 return list;
2991 }
2992
2993
2999 public void removeByUuid(String uuid) throws SystemException {
3000 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByUuid(uuid)) {
3001 remove(mdrRuleGroupInstance);
3002 }
3003 }
3004
3005
3012 public void removeByUUID_G(String uuid, long groupId)
3013 throws NoSuchRuleGroupInstanceException, SystemException {
3014 MDRRuleGroupInstance mdrRuleGroupInstance = findByUUID_G(uuid, groupId);
3015
3016 remove(mdrRuleGroupInstance);
3017 }
3018
3019
3025 public void removeByRuleGroupId(long ruleGroupId) throws SystemException {
3026 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByRuleGroupId(
3027 ruleGroupId)) {
3028 remove(mdrRuleGroupInstance);
3029 }
3030 }
3031
3032
3039 public void removeByC_C(long classNameId, long classPK)
3040 throws SystemException {
3041 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByC_C(
3042 classNameId, classPK)) {
3043 remove(mdrRuleGroupInstance);
3044 }
3045 }
3046
3047
3055 public void removeByG_C_C(long groupId, long classNameId, long classPK)
3056 throws SystemException {
3057 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByG_C_C(groupId,
3058 classNameId, classPK)) {
3059 remove(mdrRuleGroupInstance);
3060 }
3061 }
3062
3063
3071 public void removeByC_C_R(long classNameId, long classPK, long ruleGroupId)
3072 throws NoSuchRuleGroupInstanceException, SystemException {
3073 MDRRuleGroupInstance mdrRuleGroupInstance = findByC_C_R(classNameId,
3074 classPK, ruleGroupId);
3075
3076 remove(mdrRuleGroupInstance);
3077 }
3078
3079
3084 public void removeAll() throws SystemException {
3085 for (MDRRuleGroupInstance mdrRuleGroupInstance : findAll()) {
3086 remove(mdrRuleGroupInstance);
3087 }
3088 }
3089
3090
3097 public int countByUuid(String uuid) throws SystemException {
3098 Object[] finderArgs = new Object[] { uuid };
3099
3100 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3101 finderArgs, this);
3102
3103 if (count == null) {
3104 StringBundler query = new StringBundler(2);
3105
3106 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
3107
3108 if (uuid == null) {
3109 query.append(_FINDER_COLUMN_UUID_UUID_1);
3110 }
3111 else {
3112 if (uuid.equals(StringPool.BLANK)) {
3113 query.append(_FINDER_COLUMN_UUID_UUID_3);
3114 }
3115 else {
3116 query.append(_FINDER_COLUMN_UUID_UUID_2);
3117 }
3118 }
3119
3120 String sql = query.toString();
3121
3122 Session session = null;
3123
3124 try {
3125 session = openSession();
3126
3127 Query q = session.createQuery(sql);
3128
3129 QueryPos qPos = QueryPos.getInstance(q);
3130
3131 if (uuid != null) {
3132 qPos.add(uuid);
3133 }
3134
3135 count = (Long)q.uniqueResult();
3136 }
3137 catch (Exception e) {
3138 throw processException(e);
3139 }
3140 finally {
3141 if (count == null) {
3142 count = Long.valueOf(0);
3143 }
3144
3145 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3146 finderArgs, count);
3147
3148 closeSession(session);
3149 }
3150 }
3151
3152 return count.intValue();
3153 }
3154
3155
3163 public int countByUUID_G(String uuid, long groupId)
3164 throws SystemException {
3165 Object[] finderArgs = new Object[] { uuid, groupId };
3166
3167 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3168 finderArgs, this);
3169
3170 if (count == null) {
3171 StringBundler query = new StringBundler(3);
3172
3173 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
3174
3175 if (uuid == null) {
3176 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3177 }
3178 else {
3179 if (uuid.equals(StringPool.BLANK)) {
3180 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3181 }
3182 else {
3183 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3184 }
3185 }
3186
3187 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3188
3189 String sql = query.toString();
3190
3191 Session session = null;
3192
3193 try {
3194 session = openSession();
3195
3196 Query q = session.createQuery(sql);
3197
3198 QueryPos qPos = QueryPos.getInstance(q);
3199
3200 if (uuid != null) {
3201 qPos.add(uuid);
3202 }
3203
3204 qPos.add(groupId);
3205
3206 count = (Long)q.uniqueResult();
3207 }
3208 catch (Exception e) {
3209 throw processException(e);
3210 }
3211 finally {
3212 if (count == null) {
3213 count = Long.valueOf(0);
3214 }
3215
3216 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3217 finderArgs, count);
3218
3219 closeSession(session);
3220 }
3221 }
3222
3223 return count.intValue();
3224 }
3225
3226
3233 public int countByRuleGroupId(long ruleGroupId) throws SystemException {
3234 Object[] finderArgs = new Object[] { ruleGroupId };
3235
3236 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
3237 finderArgs, this);
3238
3239 if (count == null) {
3240 StringBundler query = new StringBundler(2);
3241
3242 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
3243
3244 query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
3245
3246 String sql = query.toString();
3247
3248 Session session = null;
3249
3250 try {
3251 session = openSession();
3252
3253 Query q = session.createQuery(sql);
3254
3255 QueryPos qPos = QueryPos.getInstance(q);
3256
3257 qPos.add(ruleGroupId);
3258
3259 count = (Long)q.uniqueResult();
3260 }
3261 catch (Exception e) {
3262 throw processException(e);
3263 }
3264 finally {
3265 if (count == null) {
3266 count = Long.valueOf(0);
3267 }
3268
3269 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
3270 finderArgs, count);
3271
3272 closeSession(session);
3273 }
3274 }
3275
3276 return count.intValue();
3277 }
3278
3279
3287 public int countByC_C(long classNameId, long classPK)
3288 throws SystemException {
3289 Object[] finderArgs = new Object[] { classNameId, classPK };
3290
3291 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
3292 finderArgs, this);
3293
3294 if (count == null) {
3295 StringBundler query = new StringBundler(3);
3296
3297 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
3298
3299 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3300
3301 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3302
3303 String sql = query.toString();
3304
3305 Session session = null;
3306
3307 try {
3308 session = openSession();
3309
3310 Query q = session.createQuery(sql);
3311
3312 QueryPos qPos = QueryPos.getInstance(q);
3313
3314 qPos.add(classNameId);
3315
3316 qPos.add(classPK);
3317
3318 count = (Long)q.uniqueResult();
3319 }
3320 catch (Exception e) {
3321 throw processException(e);
3322 }
3323 finally {
3324 if (count == null) {
3325 count = Long.valueOf(0);
3326 }
3327
3328 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
3329 count);
3330
3331 closeSession(session);
3332 }
3333 }
3334
3335 return count.intValue();
3336 }
3337
3338
3347 public int countByG_C_C(long groupId, long classNameId, long classPK)
3348 throws SystemException {
3349 Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
3350
3351 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
3352 finderArgs, this);
3353
3354 if (count == null) {
3355 StringBundler query = new StringBundler(4);
3356
3357 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
3358
3359 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3360
3361 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3362
3363 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3364
3365 String sql = query.toString();
3366
3367 Session session = null;
3368
3369 try {
3370 session = openSession();
3371
3372 Query q = session.createQuery(sql);
3373
3374 QueryPos qPos = QueryPos.getInstance(q);
3375
3376 qPos.add(groupId);
3377
3378 qPos.add(classNameId);
3379
3380 qPos.add(classPK);
3381
3382 count = (Long)q.uniqueResult();
3383 }
3384 catch (Exception e) {
3385 throw processException(e);
3386 }
3387 finally {
3388 if (count == null) {
3389 count = Long.valueOf(0);
3390 }
3391
3392 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
3393 finderArgs, count);
3394
3395 closeSession(session);
3396 }
3397 }
3398
3399 return count.intValue();
3400 }
3401
3402
3411 public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
3412 throws SystemException {
3413 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3414 return countByG_C_C(groupId, classNameId, classPK);
3415 }
3416
3417 StringBundler query = new StringBundler(4);
3418
3419 query.append(_FILTER_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
3420
3421 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3422
3423 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3424
3425 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3426
3427 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3428 MDRRuleGroupInstance.class.getName(),
3429 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3430
3431 Session session = null;
3432
3433 try {
3434 session = openSession();
3435
3436 SQLQuery q = session.createSQLQuery(sql);
3437
3438 q.addScalar(COUNT_COLUMN_NAME,
3439 com.liferay.portal.kernel.dao.orm.Type.LONG);
3440
3441 QueryPos qPos = QueryPos.getInstance(q);
3442
3443 qPos.add(groupId);
3444
3445 qPos.add(classNameId);
3446
3447 qPos.add(classPK);
3448
3449 Long count = (Long)q.uniqueResult();
3450
3451 return count.intValue();
3452 }
3453 catch (Exception e) {
3454 throw processException(e);
3455 }
3456 finally {
3457 closeSession(session);
3458 }
3459 }
3460
3461
3470 public int countByC_C_R(long classNameId, long classPK, long ruleGroupId)
3471 throws SystemException {
3472 Object[] finderArgs = new Object[] { classNameId, classPK, ruleGroupId };
3473
3474 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_R,
3475 finderArgs, this);
3476
3477 if (count == null) {
3478 StringBundler query = new StringBundler(4);
3479
3480 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
3481
3482 query.append(_FINDER_COLUMN_C_C_R_CLASSNAMEID_2);
3483
3484 query.append(_FINDER_COLUMN_C_C_R_CLASSPK_2);
3485
3486 query.append(_FINDER_COLUMN_C_C_R_RULEGROUPID_2);
3487
3488 String sql = query.toString();
3489
3490 Session session = null;
3491
3492 try {
3493 session = openSession();
3494
3495 Query q = session.createQuery(sql);
3496
3497 QueryPos qPos = QueryPos.getInstance(q);
3498
3499 qPos.add(classNameId);
3500
3501 qPos.add(classPK);
3502
3503 qPos.add(ruleGroupId);
3504
3505 count = (Long)q.uniqueResult();
3506 }
3507 catch (Exception e) {
3508 throw processException(e);
3509 }
3510 finally {
3511 if (count == null) {
3512 count = Long.valueOf(0);
3513 }
3514
3515 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_R,
3516 finderArgs, count);
3517
3518 closeSession(session);
3519 }
3520 }
3521
3522 return count.intValue();
3523 }
3524
3525
3531 public int countAll() throws SystemException {
3532 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3533 FINDER_ARGS_EMPTY, this);
3534
3535 if (count == null) {
3536 Session session = null;
3537
3538 try {
3539 session = openSession();
3540
3541 Query q = session.createQuery(_SQL_COUNT_MDRRULEGROUPINSTANCE);
3542
3543 count = (Long)q.uniqueResult();
3544 }
3545 catch (Exception e) {
3546 throw processException(e);
3547 }
3548 finally {
3549 if (count == null) {
3550 count = Long.valueOf(0);
3551 }
3552
3553 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3554 FINDER_ARGS_EMPTY, count);
3555
3556 closeSession(session);
3557 }
3558 }
3559
3560 return count.intValue();
3561 }
3562
3563
3566 public void afterPropertiesSet() {
3567 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3568 com.liferay.portal.util.PropsUtil.get(
3569 "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance")));
3570
3571 if (listenerClassNames.length > 0) {
3572 try {
3573 List<ModelListener<MDRRuleGroupInstance>> listenersList = new ArrayList<ModelListener<MDRRuleGroupInstance>>();
3574
3575 for (String listenerClassName : listenerClassNames) {
3576 listenersList.add((ModelListener<MDRRuleGroupInstance>)InstanceFactory.newInstance(
3577 listenerClassName));
3578 }
3579
3580 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3581 }
3582 catch (Exception e) {
3583 _log.error(e);
3584 }
3585 }
3586 }
3587
3588 public void destroy() {
3589 EntityCacheUtil.removeCache(MDRRuleGroupInstanceImpl.class.getName());
3590 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3591 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3592 }
3593
3594 @BeanReference(type = MDRActionPersistence.class)
3595 protected MDRActionPersistence mdrActionPersistence;
3596 @BeanReference(type = MDRRulePersistence.class)
3597 protected MDRRulePersistence mdrRulePersistence;
3598 @BeanReference(type = MDRRuleGroupPersistence.class)
3599 protected MDRRuleGroupPersistence mdrRuleGroupPersistence;
3600 @BeanReference(type = MDRRuleGroupInstancePersistence.class)
3601 protected MDRRuleGroupInstancePersistence mdrRuleGroupInstancePersistence;
3602 @BeanReference(type = LayoutPersistence.class)
3603 protected LayoutPersistence layoutPersistence;
3604 @BeanReference(type = LayoutSetPersistence.class)
3605 protected LayoutSetPersistence layoutSetPersistence;
3606 @BeanReference(type = ResourcePersistence.class)
3607 protected ResourcePersistence resourcePersistence;
3608 @BeanReference(type = UserPersistence.class)
3609 protected UserPersistence userPersistence;
3610 private static final String _SQL_SELECT_MDRRULEGROUPINSTANCE = "SELECT mdrRuleGroupInstance FROM MDRRuleGroupInstance mdrRuleGroupInstance";
3611 private static final String _SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE = "SELECT mdrRuleGroupInstance FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
3612 private static final String _SQL_COUNT_MDRRULEGROUPINSTANCE = "SELECT COUNT(mdrRuleGroupInstance) FROM MDRRuleGroupInstance mdrRuleGroupInstance";
3613 private static final String _SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE = "SELECT COUNT(mdrRuleGroupInstance) FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
3614 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrRuleGroupInstance.uuid IS NULL";
3615 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrRuleGroupInstance.uuid = ?";
3616 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrRuleGroupInstance.uuid IS NULL OR mdrRuleGroupInstance.uuid = ?)";
3617 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrRuleGroupInstance.uuid IS NULL AND ";
3618 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrRuleGroupInstance.uuid = ? AND ";
3619 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrRuleGroupInstance.uuid IS NULL OR mdrRuleGroupInstance.uuid = ?) AND ";
3620 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrRuleGroupInstance.groupId = ?";
3621 private static final String _FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2 = "mdrRuleGroupInstance.ruleGroupId = ?";
3622 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
3623 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ?";
3624 private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "mdrRuleGroupInstance.groupId = ? AND ";
3625 private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
3626 private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ?";
3627 private static final String _FINDER_COLUMN_C_C_R_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
3628 private static final String _FINDER_COLUMN_C_C_R_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ? AND ";
3629 private static final String _FINDER_COLUMN_C_C_R_RULEGROUPID_2 = "mdrRuleGroupInstance.ruleGroupId = ?";
3630 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mdrRuleGroupInstance.ruleGroupInstanceId";
3631 private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE = "SELECT DISTINCT {mdrRuleGroupInstance.*} FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
3632 private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1 =
3633 "SELECT {MDRRuleGroupInstance.*} FROM (SELECT DISTINCT mdrRuleGroupInstance.ruleGroupInstanceId FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
3634 private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2 =
3635 ") TEMP_TABLE INNER JOIN MDRRuleGroupInstance ON TEMP_TABLE.ruleGroupInstanceId = MDRRuleGroupInstance.ruleGroupInstanceId";
3636 private static final String _FILTER_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE = "SELECT COUNT(DISTINCT mdrRuleGroupInstance.ruleGroupInstanceId) AS COUNT_VALUE FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
3637 private static final String _FILTER_ENTITY_ALIAS = "mdrRuleGroupInstance";
3638 private static final String _FILTER_ENTITY_TABLE = "MDRRuleGroupInstance";
3639 private static final String _ORDER_BY_ENTITY_ALIAS = "mdrRuleGroupInstance.";
3640 private static final String _ORDER_BY_ENTITY_TABLE = "MDRRuleGroupInstance.";
3641 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRRuleGroupInstance exists with the primary key ";
3642 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRRuleGroupInstance exists with the key {";
3643 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3644 private static Log _log = LogFactoryUtil.getLog(MDRRuleGroupInstancePersistenceImpl.class);
3645 private static MDRRuleGroupInstance _nullMDRRuleGroupInstance = new MDRRuleGroupInstanceImpl() {
3646 @Override
3647 public Object clone() {
3648 return this;
3649 }
3650
3651 @Override
3652 public CacheModel<MDRRuleGroupInstance> toCacheModel() {
3653 return _nullMDRRuleGroupInstanceCacheModel;
3654 }
3655 };
3656
3657 private static CacheModel<MDRRuleGroupInstance> _nullMDRRuleGroupInstanceCacheModel =
3658 new CacheModel<MDRRuleGroupInstance>() {
3659 public MDRRuleGroupInstance toEntityModel() {
3660 return _nullMDRRuleGroupInstance;
3661 }
3662 };
3663 }