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.LayoutPersistence;
043 import com.liferay.portal.service.persistence.LayoutSetPersistence;
044 import com.liferay.portal.service.persistence.UserPersistence;
045 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046
047 import com.liferay.portlet.mobiledevicerules.NoSuchRuleGroupInstanceException;
048 import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance;
049 import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleGroupInstanceImpl;
050 import com.liferay.portlet.mobiledevicerules.model.impl.MDRRuleGroupInstanceModelImpl;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057
058
070 public class MDRRuleGroupInstancePersistenceImpl extends BasePersistenceImpl<MDRRuleGroupInstance>
071 implements MDRRuleGroupInstancePersistence {
072
077 public static final String FINDER_CLASS_NAME_ENTITY = MDRRuleGroupInstanceImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List1";
080 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List2";
082 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
083 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
084 MDRRuleGroupInstanceImpl.class,
085 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
086 new String[] {
087 String.class.getName(),
088
089 "java.lang.Integer", "java.lang.Integer",
090 "com.liferay.portal.kernel.util.OrderByComparator"
091 });
092 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
093 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
094 MDRRuleGroupInstanceImpl.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
096 new String[] { String.class.getName() },
097 MDRRuleGroupInstanceModelImpl.UUID_COLUMN_BITMASK);
098 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
099 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
101 new String[] { String.class.getName() });
102 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
103 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
104 MDRRuleGroupInstanceImpl.class, FINDER_CLASS_NAME_ENTITY,
105 "fetchByUUID_G",
106 new String[] { String.class.getName(), Long.class.getName() },
107 MDRRuleGroupInstanceModelImpl.UUID_COLUMN_BITMASK |
108 MDRRuleGroupInstanceModelImpl.GROUPID_COLUMN_BITMASK);
109 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
110 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
111 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
112 new String[] { String.class.getName(), Long.class.getName() });
113 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
114 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
115 MDRRuleGroupInstanceImpl.class,
116 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
117 new String[] {
118 String.class.getName(), Long.class.getName(),
119
120 "java.lang.Integer", "java.lang.Integer",
121 "com.liferay.portal.kernel.util.OrderByComparator"
122 });
123 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
124 new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
125 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
126 MDRRuleGroupInstanceImpl.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
128 new String[] { String.class.getName(), Long.class.getName() },
129 MDRRuleGroupInstanceModelImpl.UUID_COLUMN_BITMASK |
130 MDRRuleGroupInstanceModelImpl.COMPANYID_COLUMN_BITMASK);
131 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
132 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
133 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
134 new String[] { String.class.getName(), Long.class.getName() });
135 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
136 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
137 MDRRuleGroupInstanceImpl.class,
138 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
139 new String[] {
140 Long.class.getName(),
141
142 "java.lang.Integer", "java.lang.Integer",
143 "com.liferay.portal.kernel.util.OrderByComparator"
144 });
145 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
146 new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
147 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
148 MDRRuleGroupInstanceImpl.class,
149 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
150 new String[] { Long.class.getName() },
151 MDRRuleGroupInstanceModelImpl.GROUPID_COLUMN_BITMASK);
152 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
153 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
154 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
155 new String[] { Long.class.getName() });
156 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPID =
157 new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
158 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
159 MDRRuleGroupInstanceImpl.class,
160 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByRuleGroupId",
161 new String[] {
162 Long.class.getName(),
163
164 "java.lang.Integer", "java.lang.Integer",
165 "com.liferay.portal.kernel.util.OrderByComparator"
166 });
167 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID =
168 new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
169 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
170 MDRRuleGroupInstanceImpl.class,
171 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRuleGroupId",
172 new String[] { Long.class.getName() },
173 MDRRuleGroupInstanceModelImpl.RULEGROUPID_COLUMN_BITMASK);
174 public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPID = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
175 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
176 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRuleGroupId",
177 new String[] { Long.class.getName() });
178 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
179 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
180 MDRRuleGroupInstanceImpl.class,
181 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
182 new String[] {
183 Long.class.getName(), Long.class.getName(),
184
185 "java.lang.Integer", "java.lang.Integer",
186 "com.liferay.portal.kernel.util.OrderByComparator"
187 });
188 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
189 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
190 MDRRuleGroupInstanceImpl.class,
191 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
192 new String[] { Long.class.getName(), Long.class.getName() },
193 MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
194 MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK);
195 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
196 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
197 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
198 new String[] { Long.class.getName(), Long.class.getName() });
199 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
200 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
201 MDRRuleGroupInstanceImpl.class,
202 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_C",
203 new String[] {
204 Long.class.getName(), Long.class.getName(), Long.class.getName(),
205
206 "java.lang.Integer", "java.lang.Integer",
207 "com.liferay.portal.kernel.util.OrderByComparator"
208 });
209 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
210 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
211 MDRRuleGroupInstanceImpl.class,
212 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C",
213 new String[] {
214 Long.class.getName(), Long.class.getName(), Long.class.getName()
215 },
216 MDRRuleGroupInstanceModelImpl.GROUPID_COLUMN_BITMASK |
217 MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
218 MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK);
219 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
220 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
221 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C",
222 new String[] {
223 Long.class.getName(), Long.class.getName(), Long.class.getName()
224 });
225 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_R = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
226 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
227 MDRRuleGroupInstanceImpl.class, FINDER_CLASS_NAME_ENTITY,
228 "fetchByC_C_R",
229 new String[] {
230 Long.class.getName(), Long.class.getName(), Long.class.getName()
231 },
232 MDRRuleGroupInstanceModelImpl.CLASSNAMEID_COLUMN_BITMASK |
233 MDRRuleGroupInstanceModelImpl.CLASSPK_COLUMN_BITMASK |
234 MDRRuleGroupInstanceModelImpl.RULEGROUPID_COLUMN_BITMASK);
235 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_R = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
236 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
237 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_R",
238 new String[] {
239 Long.class.getName(), Long.class.getName(), Long.class.getName()
240 });
241 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
242 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
243 MDRRuleGroupInstanceImpl.class,
244 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
245 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
246 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED,
247 MDRRuleGroupInstanceImpl.class,
248 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
249 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
250 MDRRuleGroupInstanceModelImpl.FINDER_CACHE_ENABLED, Long.class,
251 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
252
253
258 public void cacheResult(MDRRuleGroupInstance mdrRuleGroupInstance) {
259 EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
260 MDRRuleGroupInstanceImpl.class,
261 mdrRuleGroupInstance.getPrimaryKey(), mdrRuleGroupInstance);
262
263 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
264 new Object[] {
265 mdrRuleGroupInstance.getUuid(),
266 Long.valueOf(mdrRuleGroupInstance.getGroupId())
267 }, mdrRuleGroupInstance);
268
269 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
270 new Object[] {
271 Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
272 Long.valueOf(mdrRuleGroupInstance.getClassPK()),
273 Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
274 }, mdrRuleGroupInstance);
275
276 mdrRuleGroupInstance.resetOriginalValues();
277 }
278
279
284 public void cacheResult(List<MDRRuleGroupInstance> mdrRuleGroupInstances) {
285 for (MDRRuleGroupInstance mdrRuleGroupInstance : mdrRuleGroupInstances) {
286 if (EntityCacheUtil.getResult(
287 MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
288 MDRRuleGroupInstanceImpl.class,
289 mdrRuleGroupInstance.getPrimaryKey()) == null) {
290 cacheResult(mdrRuleGroupInstance);
291 }
292 else {
293 mdrRuleGroupInstance.resetOriginalValues();
294 }
295 }
296 }
297
298
305 @Override
306 public void clearCache() {
307 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
308 CacheRegistryUtil.clear(MDRRuleGroupInstanceImpl.class.getName());
309 }
310
311 EntityCacheUtil.clearCache(MDRRuleGroupInstanceImpl.class.getName());
312
313 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
314 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
315 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
316 }
317
318
325 @Override
326 public void clearCache(MDRRuleGroupInstance mdrRuleGroupInstance) {
327 EntityCacheUtil.removeResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
328 MDRRuleGroupInstanceImpl.class, mdrRuleGroupInstance.getPrimaryKey());
329
330 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
331 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
332
333 clearUniqueFindersCache(mdrRuleGroupInstance);
334 }
335
336 @Override
337 public void clearCache(List<MDRRuleGroupInstance> mdrRuleGroupInstances) {
338 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
339 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
340
341 for (MDRRuleGroupInstance mdrRuleGroupInstance : mdrRuleGroupInstances) {
342 EntityCacheUtil.removeResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
343 MDRRuleGroupInstanceImpl.class,
344 mdrRuleGroupInstance.getPrimaryKey());
345
346 clearUniqueFindersCache(mdrRuleGroupInstance);
347 }
348 }
349
350 protected void clearUniqueFindersCache(
351 MDRRuleGroupInstance mdrRuleGroupInstance) {
352 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
353 new Object[] {
354 mdrRuleGroupInstance.getUuid(),
355 Long.valueOf(mdrRuleGroupInstance.getGroupId())
356 });
357
358 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R,
359 new Object[] {
360 Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
361 Long.valueOf(mdrRuleGroupInstance.getClassPK()),
362 Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
363 });
364 }
365
366
372 public MDRRuleGroupInstance create(long ruleGroupInstanceId) {
373 MDRRuleGroupInstance mdrRuleGroupInstance = new MDRRuleGroupInstanceImpl();
374
375 mdrRuleGroupInstance.setNew(true);
376 mdrRuleGroupInstance.setPrimaryKey(ruleGroupInstanceId);
377
378 String uuid = PortalUUIDUtil.generate();
379
380 mdrRuleGroupInstance.setUuid(uuid);
381
382 return mdrRuleGroupInstance;
383 }
384
385
393 public MDRRuleGroupInstance remove(long ruleGroupInstanceId)
394 throws NoSuchRuleGroupInstanceException, SystemException {
395 return remove(Long.valueOf(ruleGroupInstanceId));
396 }
397
398
406 @Override
407 public MDRRuleGroupInstance remove(Serializable primaryKey)
408 throws NoSuchRuleGroupInstanceException, SystemException {
409 Session session = null;
410
411 try {
412 session = openSession();
413
414 MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)session.get(MDRRuleGroupInstanceImpl.class,
415 primaryKey);
416
417 if (mdrRuleGroupInstance == null) {
418 if (_log.isWarnEnabled()) {
419 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
420 }
421
422 throw new NoSuchRuleGroupInstanceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
423 primaryKey);
424 }
425
426 return remove(mdrRuleGroupInstance);
427 }
428 catch (NoSuchRuleGroupInstanceException nsee) {
429 throw nsee;
430 }
431 catch (Exception e) {
432 throw processException(e);
433 }
434 finally {
435 closeSession(session);
436 }
437 }
438
439 @Override
440 protected MDRRuleGroupInstance removeImpl(
441 MDRRuleGroupInstance mdrRuleGroupInstance) throws SystemException {
442 mdrRuleGroupInstance = toUnwrappedModel(mdrRuleGroupInstance);
443
444 Session session = null;
445
446 try {
447 session = openSession();
448
449 if (mdrRuleGroupInstance.isCachedModel()) {
450 mdrRuleGroupInstance = (MDRRuleGroupInstance)session.get(MDRRuleGroupInstanceImpl.class,
451 mdrRuleGroupInstance.getPrimaryKeyObj());
452 }
453
454 session.delete(mdrRuleGroupInstance);
455 }
456 catch (Exception e) {
457 throw processException(e);
458 }
459 finally {
460 closeSession(session);
461 }
462
463 clearCache(mdrRuleGroupInstance);
464
465 return mdrRuleGroupInstance;
466 }
467
468 @Override
469 public MDRRuleGroupInstance updateImpl(
470 com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance mdrRuleGroupInstance)
471 throws SystemException {
472 mdrRuleGroupInstance = toUnwrappedModel(mdrRuleGroupInstance);
473
474 boolean isNew = mdrRuleGroupInstance.isNew();
475
476 MDRRuleGroupInstanceModelImpl mdrRuleGroupInstanceModelImpl = (MDRRuleGroupInstanceModelImpl)mdrRuleGroupInstance;
477
478 if (Validator.isNull(mdrRuleGroupInstance.getUuid())) {
479 String uuid = PortalUUIDUtil.generate();
480
481 mdrRuleGroupInstance.setUuid(uuid);
482 }
483
484 Session session = null;
485
486 try {
487 session = openSession();
488
489 if (mdrRuleGroupInstance.isNew()) {
490 session.save(mdrRuleGroupInstance);
491
492 mdrRuleGroupInstance.setNew(false);
493 }
494 else {
495 session.merge(mdrRuleGroupInstance);
496 }
497 }
498 catch (Exception e) {
499 throw processException(e);
500 }
501 finally {
502 closeSession(session);
503 }
504
505 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
506
507 if (isNew || !MDRRuleGroupInstanceModelImpl.COLUMN_BITMASK_ENABLED) {
508 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
509 }
510
511 else {
512 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
513 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
514 Object[] args = new Object[] {
515 mdrRuleGroupInstanceModelImpl.getOriginalUuid()
516 };
517
518 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
519 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
520 args);
521
522 args = new Object[] { mdrRuleGroupInstanceModelImpl.getUuid() };
523
524 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
525 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
526 args);
527 }
528
529 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
530 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
531 Object[] args = new Object[] {
532 mdrRuleGroupInstanceModelImpl.getOriginalUuid(),
533 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalCompanyId())
534 };
535
536 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
537 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
538 args);
539
540 args = new Object[] {
541 mdrRuleGroupInstanceModelImpl.getUuid(),
542 Long.valueOf(mdrRuleGroupInstanceModelImpl.getCompanyId())
543 };
544
545 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
546 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
547 args);
548 }
549
550 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
551 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
552 Object[] args = new Object[] {
553 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalGroupId())
554 };
555
556 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
557 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
558 args);
559
560 args = new Object[] {
561 Long.valueOf(mdrRuleGroupInstanceModelImpl.getGroupId())
562 };
563
564 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
565 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
566 args);
567 }
568
569 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
570 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID.getColumnBitmask()) != 0) {
571 Object[] args = new Object[] {
572 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalRuleGroupId())
573 };
574
575 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
576 args);
577 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID,
578 args);
579
580 args = new Object[] {
581 Long.valueOf(mdrRuleGroupInstanceModelImpl.getRuleGroupId())
582 };
583
584 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
585 args);
586 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID,
587 args);
588 }
589
590 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
591 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
592 Object[] args = new Object[] {
593 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
594 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK())
595 };
596
597 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
598 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
599 args);
600
601 args = new Object[] {
602 Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassNameId()),
603 Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassPK())
604 };
605
606 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
607 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
608 args);
609 }
610
611 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
612 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C.getColumnBitmask()) != 0) {
613 Object[] args = new Object[] {
614 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalGroupId()),
615 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
616 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK())
617 };
618
619 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
620 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
621 args);
622
623 args = new Object[] {
624 Long.valueOf(mdrRuleGroupInstanceModelImpl.getGroupId()),
625 Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassNameId()),
626 Long.valueOf(mdrRuleGroupInstanceModelImpl.getClassPK())
627 };
628
629 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C, args);
630 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C,
631 args);
632 }
633 }
634
635 EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
636 MDRRuleGroupInstanceImpl.class,
637 mdrRuleGroupInstance.getPrimaryKey(), mdrRuleGroupInstance);
638
639 if (isNew) {
640 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
641 new Object[] {
642 mdrRuleGroupInstance.getUuid(),
643 Long.valueOf(mdrRuleGroupInstance.getGroupId())
644 }, mdrRuleGroupInstance);
645
646 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
647 new Object[] {
648 Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
649 Long.valueOf(mdrRuleGroupInstance.getClassPK()),
650 Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
651 }, mdrRuleGroupInstance);
652 }
653 else {
654 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
655 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
656 Object[] args = new Object[] {
657 mdrRuleGroupInstanceModelImpl.getOriginalUuid(),
658 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalGroupId())
659 };
660
661 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
662
663 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
664
665 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
666 new Object[] {
667 mdrRuleGroupInstance.getUuid(),
668 Long.valueOf(mdrRuleGroupInstance.getGroupId())
669 }, mdrRuleGroupInstance);
670 }
671
672 if ((mdrRuleGroupInstanceModelImpl.getColumnBitmask() &
673 FINDER_PATH_FETCH_BY_C_C_R.getColumnBitmask()) != 0) {
674 Object[] args = new Object[] {
675 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassNameId()),
676 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalClassPK()),
677 Long.valueOf(mdrRuleGroupInstanceModelImpl.getOriginalRuleGroupId())
678 };
679
680 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_R, args);
681
682 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R, args);
683
684 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
685 new Object[] {
686 Long.valueOf(mdrRuleGroupInstance.getClassNameId()),
687 Long.valueOf(mdrRuleGroupInstance.getClassPK()),
688 Long.valueOf(mdrRuleGroupInstance.getRuleGroupId())
689 }, mdrRuleGroupInstance);
690 }
691 }
692
693 return mdrRuleGroupInstance;
694 }
695
696 protected MDRRuleGroupInstance toUnwrappedModel(
697 MDRRuleGroupInstance mdrRuleGroupInstance) {
698 if (mdrRuleGroupInstance instanceof MDRRuleGroupInstanceImpl) {
699 return mdrRuleGroupInstance;
700 }
701
702 MDRRuleGroupInstanceImpl mdrRuleGroupInstanceImpl = new MDRRuleGroupInstanceImpl();
703
704 mdrRuleGroupInstanceImpl.setNew(mdrRuleGroupInstance.isNew());
705 mdrRuleGroupInstanceImpl.setPrimaryKey(mdrRuleGroupInstance.getPrimaryKey());
706
707 mdrRuleGroupInstanceImpl.setUuid(mdrRuleGroupInstance.getUuid());
708 mdrRuleGroupInstanceImpl.setRuleGroupInstanceId(mdrRuleGroupInstance.getRuleGroupInstanceId());
709 mdrRuleGroupInstanceImpl.setGroupId(mdrRuleGroupInstance.getGroupId());
710 mdrRuleGroupInstanceImpl.setCompanyId(mdrRuleGroupInstance.getCompanyId());
711 mdrRuleGroupInstanceImpl.setUserId(mdrRuleGroupInstance.getUserId());
712 mdrRuleGroupInstanceImpl.setUserName(mdrRuleGroupInstance.getUserName());
713 mdrRuleGroupInstanceImpl.setCreateDate(mdrRuleGroupInstance.getCreateDate());
714 mdrRuleGroupInstanceImpl.setModifiedDate(mdrRuleGroupInstance.getModifiedDate());
715 mdrRuleGroupInstanceImpl.setClassNameId(mdrRuleGroupInstance.getClassNameId());
716 mdrRuleGroupInstanceImpl.setClassPK(mdrRuleGroupInstance.getClassPK());
717 mdrRuleGroupInstanceImpl.setRuleGroupId(mdrRuleGroupInstance.getRuleGroupId());
718 mdrRuleGroupInstanceImpl.setPriority(mdrRuleGroupInstance.getPriority());
719
720 return mdrRuleGroupInstanceImpl;
721 }
722
723
731 @Override
732 public MDRRuleGroupInstance findByPrimaryKey(Serializable primaryKey)
733 throws NoSuchModelException, SystemException {
734 return findByPrimaryKey(((Long)primaryKey).longValue());
735 }
736
737
745 public MDRRuleGroupInstance findByPrimaryKey(long ruleGroupInstanceId)
746 throws NoSuchRuleGroupInstanceException, SystemException {
747 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByPrimaryKey(ruleGroupInstanceId);
748
749 if (mdrRuleGroupInstance == null) {
750 if (_log.isWarnEnabled()) {
751 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
752 ruleGroupInstanceId);
753 }
754
755 throw new NoSuchRuleGroupInstanceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
756 ruleGroupInstanceId);
757 }
758
759 return mdrRuleGroupInstance;
760 }
761
762
769 @Override
770 public MDRRuleGroupInstance fetchByPrimaryKey(Serializable primaryKey)
771 throws SystemException {
772 return fetchByPrimaryKey(((Long)primaryKey).longValue());
773 }
774
775
782 public MDRRuleGroupInstance fetchByPrimaryKey(long ruleGroupInstanceId)
783 throws SystemException {
784 MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)EntityCacheUtil.getResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
785 MDRRuleGroupInstanceImpl.class, ruleGroupInstanceId);
786
787 if (mdrRuleGroupInstance == _nullMDRRuleGroupInstance) {
788 return null;
789 }
790
791 if (mdrRuleGroupInstance == null) {
792 Session session = null;
793
794 boolean hasException = false;
795
796 try {
797 session = openSession();
798
799 mdrRuleGroupInstance = (MDRRuleGroupInstance)session.get(MDRRuleGroupInstanceImpl.class,
800 Long.valueOf(ruleGroupInstanceId));
801 }
802 catch (Exception e) {
803 hasException = true;
804
805 throw processException(e);
806 }
807 finally {
808 if (mdrRuleGroupInstance != null) {
809 cacheResult(mdrRuleGroupInstance);
810 }
811 else if (!hasException) {
812 EntityCacheUtil.putResult(MDRRuleGroupInstanceModelImpl.ENTITY_CACHE_ENABLED,
813 MDRRuleGroupInstanceImpl.class, ruleGroupInstanceId,
814 _nullMDRRuleGroupInstance);
815 }
816
817 closeSession(session);
818 }
819 }
820
821 return mdrRuleGroupInstance;
822 }
823
824
831 public List<MDRRuleGroupInstance> findByUuid(String uuid)
832 throws SystemException {
833 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
834 }
835
836
849 public List<MDRRuleGroupInstance> findByUuid(String uuid, int start, int end)
850 throws SystemException {
851 return findByUuid(uuid, start, end, null);
852 }
853
854
868 public List<MDRRuleGroupInstance> findByUuid(String uuid, int start,
869 int end, OrderByComparator orderByComparator) throws SystemException {
870 FinderPath finderPath = null;
871 Object[] finderArgs = null;
872
873 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
874 (orderByComparator == null)) {
875 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
876 finderArgs = new Object[] { uuid };
877 }
878 else {
879 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
880 finderArgs = new Object[] { uuid, start, end, orderByComparator };
881 }
882
883 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
884 finderArgs, this);
885
886 if ((list != null) && !list.isEmpty()) {
887 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
888 if (!Validator.equals(uuid, mdrRuleGroupInstance.getUuid())) {
889 list = null;
890
891 break;
892 }
893 }
894 }
895
896 if (list == null) {
897 StringBundler query = null;
898
899 if (orderByComparator != null) {
900 query = new StringBundler(3 +
901 (orderByComparator.getOrderByFields().length * 3));
902 }
903 else {
904 query = new StringBundler(2);
905 }
906
907 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
908
909 if (uuid == null) {
910 query.append(_FINDER_COLUMN_UUID_UUID_1);
911 }
912 else {
913 if (uuid.equals(StringPool.BLANK)) {
914 query.append(_FINDER_COLUMN_UUID_UUID_3);
915 }
916 else {
917 query.append(_FINDER_COLUMN_UUID_UUID_2);
918 }
919 }
920
921 if (orderByComparator != null) {
922 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
923 orderByComparator);
924 }
925
926 String sql = query.toString();
927
928 Session session = null;
929
930 try {
931 session = openSession();
932
933 Query q = session.createQuery(sql);
934
935 QueryPos qPos = QueryPos.getInstance(q);
936
937 if (uuid != null) {
938 qPos.add(uuid);
939 }
940
941 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
942 getDialect(), start, end);
943 }
944 catch (Exception e) {
945 throw processException(e);
946 }
947 finally {
948 if (list == null) {
949 FinderCacheUtil.removeResult(finderPath, finderArgs);
950 }
951 else {
952 cacheResult(list);
953
954 FinderCacheUtil.putResult(finderPath, finderArgs, list);
955 }
956
957 closeSession(session);
958 }
959 }
960
961 return list;
962 }
963
964
973 public MDRRuleGroupInstance findByUuid_First(String uuid,
974 OrderByComparator orderByComparator)
975 throws NoSuchRuleGroupInstanceException, SystemException {
976 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUuid_First(uuid,
977 orderByComparator);
978
979 if (mdrRuleGroupInstance != null) {
980 return mdrRuleGroupInstance;
981 }
982
983 StringBundler msg = new StringBundler(4);
984
985 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
986
987 msg.append("uuid=");
988 msg.append(uuid);
989
990 msg.append(StringPool.CLOSE_CURLY_BRACE);
991
992 throw new NoSuchRuleGroupInstanceException(msg.toString());
993 }
994
995
1003 public MDRRuleGroupInstance fetchByUuid_First(String uuid,
1004 OrderByComparator orderByComparator) throws SystemException {
1005 List<MDRRuleGroupInstance> list = findByUuid(uuid, 0, 1,
1006 orderByComparator);
1007
1008 if (!list.isEmpty()) {
1009 return list.get(0);
1010 }
1011
1012 return null;
1013 }
1014
1015
1024 public MDRRuleGroupInstance findByUuid_Last(String uuid,
1025 OrderByComparator orderByComparator)
1026 throws NoSuchRuleGroupInstanceException, SystemException {
1027 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUuid_Last(uuid,
1028 orderByComparator);
1029
1030 if (mdrRuleGroupInstance != null) {
1031 return mdrRuleGroupInstance;
1032 }
1033
1034 StringBundler msg = new StringBundler(4);
1035
1036 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1037
1038 msg.append("uuid=");
1039 msg.append(uuid);
1040
1041 msg.append(StringPool.CLOSE_CURLY_BRACE);
1042
1043 throw new NoSuchRuleGroupInstanceException(msg.toString());
1044 }
1045
1046
1054 public MDRRuleGroupInstance fetchByUuid_Last(String uuid,
1055 OrderByComparator orderByComparator) throws SystemException {
1056 int count = countByUuid(uuid);
1057
1058 List<MDRRuleGroupInstance> list = findByUuid(uuid, count - 1, count,
1059 orderByComparator);
1060
1061 if (!list.isEmpty()) {
1062 return list.get(0);
1063 }
1064
1065 return null;
1066 }
1067
1068
1078 public MDRRuleGroupInstance[] findByUuid_PrevAndNext(
1079 long ruleGroupInstanceId, String uuid,
1080 OrderByComparator orderByComparator)
1081 throws NoSuchRuleGroupInstanceException, SystemException {
1082 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
1083
1084 Session session = null;
1085
1086 try {
1087 session = openSession();
1088
1089 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
1090
1091 array[0] = getByUuid_PrevAndNext(session, mdrRuleGroupInstance,
1092 uuid, orderByComparator, true);
1093
1094 array[1] = mdrRuleGroupInstance;
1095
1096 array[2] = getByUuid_PrevAndNext(session, mdrRuleGroupInstance,
1097 uuid, orderByComparator, false);
1098
1099 return array;
1100 }
1101 catch (Exception e) {
1102 throw processException(e);
1103 }
1104 finally {
1105 closeSession(session);
1106 }
1107 }
1108
1109 protected MDRRuleGroupInstance getByUuid_PrevAndNext(Session session,
1110 MDRRuleGroupInstance mdrRuleGroupInstance, String uuid,
1111 OrderByComparator orderByComparator, boolean previous) {
1112 StringBundler query = null;
1113
1114 if (orderByComparator != null) {
1115 query = new StringBundler(6 +
1116 (orderByComparator.getOrderByFields().length * 6));
1117 }
1118 else {
1119 query = new StringBundler(3);
1120 }
1121
1122 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1123
1124 if (uuid == null) {
1125 query.append(_FINDER_COLUMN_UUID_UUID_1);
1126 }
1127 else {
1128 if (uuid.equals(StringPool.BLANK)) {
1129 query.append(_FINDER_COLUMN_UUID_UUID_3);
1130 }
1131 else {
1132 query.append(_FINDER_COLUMN_UUID_UUID_2);
1133 }
1134 }
1135
1136 if (orderByComparator != null) {
1137 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1138
1139 if (orderByConditionFields.length > 0) {
1140 query.append(WHERE_AND);
1141 }
1142
1143 for (int i = 0; i < orderByConditionFields.length; i++) {
1144 query.append(_ORDER_BY_ENTITY_ALIAS);
1145 query.append(orderByConditionFields[i]);
1146
1147 if ((i + 1) < orderByConditionFields.length) {
1148 if (orderByComparator.isAscending() ^ previous) {
1149 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1150 }
1151 else {
1152 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1153 }
1154 }
1155 else {
1156 if (orderByComparator.isAscending() ^ previous) {
1157 query.append(WHERE_GREATER_THAN);
1158 }
1159 else {
1160 query.append(WHERE_LESSER_THAN);
1161 }
1162 }
1163 }
1164
1165 query.append(ORDER_BY_CLAUSE);
1166
1167 String[] orderByFields = orderByComparator.getOrderByFields();
1168
1169 for (int i = 0; i < orderByFields.length; i++) {
1170 query.append(_ORDER_BY_ENTITY_ALIAS);
1171 query.append(orderByFields[i]);
1172
1173 if ((i + 1) < orderByFields.length) {
1174 if (orderByComparator.isAscending() ^ previous) {
1175 query.append(ORDER_BY_ASC_HAS_NEXT);
1176 }
1177 else {
1178 query.append(ORDER_BY_DESC_HAS_NEXT);
1179 }
1180 }
1181 else {
1182 if (orderByComparator.isAscending() ^ previous) {
1183 query.append(ORDER_BY_ASC);
1184 }
1185 else {
1186 query.append(ORDER_BY_DESC);
1187 }
1188 }
1189 }
1190 }
1191
1192 String sql = query.toString();
1193
1194 Query q = session.createQuery(sql);
1195
1196 q.setFirstResult(0);
1197 q.setMaxResults(2);
1198
1199 QueryPos qPos = QueryPos.getInstance(q);
1200
1201 if (uuid != null) {
1202 qPos.add(uuid);
1203 }
1204
1205 if (orderByComparator != null) {
1206 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
1207
1208 for (Object value : values) {
1209 qPos.add(value);
1210 }
1211 }
1212
1213 List<MDRRuleGroupInstance> list = q.list();
1214
1215 if (list.size() == 2) {
1216 return list.get(1);
1217 }
1218 else {
1219 return null;
1220 }
1221 }
1222
1223
1232 public MDRRuleGroupInstance findByUUID_G(String uuid, long groupId)
1233 throws NoSuchRuleGroupInstanceException, SystemException {
1234 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUUID_G(uuid, groupId);
1235
1236 if (mdrRuleGroupInstance == null) {
1237 StringBundler msg = new StringBundler(6);
1238
1239 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1240
1241 msg.append("uuid=");
1242 msg.append(uuid);
1243
1244 msg.append(", groupId=");
1245 msg.append(groupId);
1246
1247 msg.append(StringPool.CLOSE_CURLY_BRACE);
1248
1249 if (_log.isWarnEnabled()) {
1250 _log.warn(msg.toString());
1251 }
1252
1253 throw new NoSuchRuleGroupInstanceException(msg.toString());
1254 }
1255
1256 return mdrRuleGroupInstance;
1257 }
1258
1259
1267 public MDRRuleGroupInstance fetchByUUID_G(String uuid, long groupId)
1268 throws SystemException {
1269 return fetchByUUID_G(uuid, groupId, true);
1270 }
1271
1272
1281 public MDRRuleGroupInstance fetchByUUID_G(String uuid, long groupId,
1282 boolean retrieveFromCache) throws SystemException {
1283 Object[] finderArgs = new Object[] { uuid, groupId };
1284
1285 Object result = null;
1286
1287 if (retrieveFromCache) {
1288 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1289 finderArgs, this);
1290 }
1291
1292 if (result instanceof MDRRuleGroupInstance) {
1293 MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)result;
1294
1295 if (!Validator.equals(uuid, mdrRuleGroupInstance.getUuid()) ||
1296 (groupId != mdrRuleGroupInstance.getGroupId())) {
1297 result = null;
1298 }
1299 }
1300
1301 if (result == null) {
1302 StringBundler query = new StringBundler(3);
1303
1304 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1305
1306 if (uuid == null) {
1307 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1308 }
1309 else {
1310 if (uuid.equals(StringPool.BLANK)) {
1311 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1312 }
1313 else {
1314 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1315 }
1316 }
1317
1318 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1319
1320 String sql = query.toString();
1321
1322 Session session = null;
1323
1324 try {
1325 session = openSession();
1326
1327 Query q = session.createQuery(sql);
1328
1329 QueryPos qPos = QueryPos.getInstance(q);
1330
1331 if (uuid != null) {
1332 qPos.add(uuid);
1333 }
1334
1335 qPos.add(groupId);
1336
1337 List<MDRRuleGroupInstance> list = q.list();
1338
1339 result = list;
1340
1341 MDRRuleGroupInstance mdrRuleGroupInstance = null;
1342
1343 if (list.isEmpty()) {
1344 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1345 finderArgs, list);
1346 }
1347 else {
1348 mdrRuleGroupInstance = list.get(0);
1349
1350 cacheResult(mdrRuleGroupInstance);
1351
1352 if ((mdrRuleGroupInstance.getUuid() == null) ||
1353 !mdrRuleGroupInstance.getUuid().equals(uuid) ||
1354 (mdrRuleGroupInstance.getGroupId() != groupId)) {
1355 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1356 finderArgs, mdrRuleGroupInstance);
1357 }
1358 }
1359
1360 return mdrRuleGroupInstance;
1361 }
1362 catch (Exception e) {
1363 throw processException(e);
1364 }
1365 finally {
1366 if (result == null) {
1367 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1368 finderArgs);
1369 }
1370
1371 closeSession(session);
1372 }
1373 }
1374 else {
1375 if (result instanceof List<?>) {
1376 return null;
1377 }
1378 else {
1379 return (MDRRuleGroupInstance)result;
1380 }
1381 }
1382 }
1383
1384
1392 public List<MDRRuleGroupInstance> findByUuid_C(String uuid, long companyId)
1393 throws SystemException {
1394 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1395 QueryUtil.ALL_POS, null);
1396 }
1397
1398
1412 public List<MDRRuleGroupInstance> findByUuid_C(String uuid, long companyId,
1413 int start, int end) throws SystemException {
1414 return findByUuid_C(uuid, companyId, start, end, null);
1415 }
1416
1417
1432 public List<MDRRuleGroupInstance> findByUuid_C(String uuid, long companyId,
1433 int start, int end, OrderByComparator orderByComparator)
1434 throws SystemException {
1435 FinderPath finderPath = null;
1436 Object[] finderArgs = null;
1437
1438 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1439 (orderByComparator == null)) {
1440 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1441 finderArgs = new Object[] { uuid, companyId };
1442 }
1443 else {
1444 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1445 finderArgs = new Object[] {
1446 uuid, companyId,
1447
1448 start, end, orderByComparator
1449 };
1450 }
1451
1452 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
1453 finderArgs, this);
1454
1455 if ((list != null) && !list.isEmpty()) {
1456 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
1457 if (!Validator.equals(uuid, mdrRuleGroupInstance.getUuid()) ||
1458 (companyId != mdrRuleGroupInstance.getCompanyId())) {
1459 list = null;
1460
1461 break;
1462 }
1463 }
1464 }
1465
1466 if (list == null) {
1467 StringBundler query = null;
1468
1469 if (orderByComparator != null) {
1470 query = new StringBundler(4 +
1471 (orderByComparator.getOrderByFields().length * 3));
1472 }
1473 else {
1474 query = new StringBundler(3);
1475 }
1476
1477 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1478
1479 if (uuid == null) {
1480 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1481 }
1482 else {
1483 if (uuid.equals(StringPool.BLANK)) {
1484 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1485 }
1486 else {
1487 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1488 }
1489 }
1490
1491 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1492
1493 if (orderByComparator != null) {
1494 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1495 orderByComparator);
1496 }
1497
1498 String sql = query.toString();
1499
1500 Session session = null;
1501
1502 try {
1503 session = openSession();
1504
1505 Query q = session.createQuery(sql);
1506
1507 QueryPos qPos = QueryPos.getInstance(q);
1508
1509 if (uuid != null) {
1510 qPos.add(uuid);
1511 }
1512
1513 qPos.add(companyId);
1514
1515 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
1516 getDialect(), start, end);
1517 }
1518 catch (Exception e) {
1519 throw processException(e);
1520 }
1521 finally {
1522 if (list == null) {
1523 FinderCacheUtil.removeResult(finderPath, finderArgs);
1524 }
1525 else {
1526 cacheResult(list);
1527
1528 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1529 }
1530
1531 closeSession(session);
1532 }
1533 }
1534
1535 return list;
1536 }
1537
1538
1548 public MDRRuleGroupInstance findByUuid_C_First(String uuid, long companyId,
1549 OrderByComparator orderByComparator)
1550 throws NoSuchRuleGroupInstanceException, SystemException {
1551 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUuid_C_First(uuid,
1552 companyId, orderByComparator);
1553
1554 if (mdrRuleGroupInstance != null) {
1555 return mdrRuleGroupInstance;
1556 }
1557
1558 StringBundler msg = new StringBundler(6);
1559
1560 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1561
1562 msg.append("uuid=");
1563 msg.append(uuid);
1564
1565 msg.append(", companyId=");
1566 msg.append(companyId);
1567
1568 msg.append(StringPool.CLOSE_CURLY_BRACE);
1569
1570 throw new NoSuchRuleGroupInstanceException(msg.toString());
1571 }
1572
1573
1582 public MDRRuleGroupInstance fetchByUuid_C_First(String uuid,
1583 long companyId, OrderByComparator orderByComparator)
1584 throws SystemException {
1585 List<MDRRuleGroupInstance> list = findByUuid_C(uuid, companyId, 0, 1,
1586 orderByComparator);
1587
1588 if (!list.isEmpty()) {
1589 return list.get(0);
1590 }
1591
1592 return null;
1593 }
1594
1595
1605 public MDRRuleGroupInstance findByUuid_C_Last(String uuid, long companyId,
1606 OrderByComparator orderByComparator)
1607 throws NoSuchRuleGroupInstanceException, SystemException {
1608 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByUuid_C_Last(uuid,
1609 companyId, orderByComparator);
1610
1611 if (mdrRuleGroupInstance != null) {
1612 return mdrRuleGroupInstance;
1613 }
1614
1615 StringBundler msg = new StringBundler(6);
1616
1617 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1618
1619 msg.append("uuid=");
1620 msg.append(uuid);
1621
1622 msg.append(", companyId=");
1623 msg.append(companyId);
1624
1625 msg.append(StringPool.CLOSE_CURLY_BRACE);
1626
1627 throw new NoSuchRuleGroupInstanceException(msg.toString());
1628 }
1629
1630
1639 public MDRRuleGroupInstance fetchByUuid_C_Last(String uuid, long companyId,
1640 OrderByComparator orderByComparator) throws SystemException {
1641 int count = countByUuid_C(uuid, companyId);
1642
1643 List<MDRRuleGroupInstance> list = findByUuid_C(uuid, companyId,
1644 count - 1, count, orderByComparator);
1645
1646 if (!list.isEmpty()) {
1647 return list.get(0);
1648 }
1649
1650 return null;
1651 }
1652
1653
1664 public MDRRuleGroupInstance[] findByUuid_C_PrevAndNext(
1665 long ruleGroupInstanceId, String uuid, long companyId,
1666 OrderByComparator orderByComparator)
1667 throws NoSuchRuleGroupInstanceException, SystemException {
1668 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
1669
1670 Session session = null;
1671
1672 try {
1673 session = openSession();
1674
1675 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
1676
1677 array[0] = getByUuid_C_PrevAndNext(session, mdrRuleGroupInstance,
1678 uuid, companyId, orderByComparator, true);
1679
1680 array[1] = mdrRuleGroupInstance;
1681
1682 array[2] = getByUuid_C_PrevAndNext(session, mdrRuleGroupInstance,
1683 uuid, companyId, orderByComparator, false);
1684
1685 return array;
1686 }
1687 catch (Exception e) {
1688 throw processException(e);
1689 }
1690 finally {
1691 closeSession(session);
1692 }
1693 }
1694
1695 protected MDRRuleGroupInstance getByUuid_C_PrevAndNext(Session session,
1696 MDRRuleGroupInstance mdrRuleGroupInstance, String uuid, long companyId,
1697 OrderByComparator orderByComparator, boolean previous) {
1698 StringBundler query = null;
1699
1700 if (orderByComparator != null) {
1701 query = new StringBundler(6 +
1702 (orderByComparator.getOrderByFields().length * 6));
1703 }
1704 else {
1705 query = new StringBundler(3);
1706 }
1707
1708 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1709
1710 if (uuid == null) {
1711 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1712 }
1713 else {
1714 if (uuid.equals(StringPool.BLANK)) {
1715 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1716 }
1717 else {
1718 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1719 }
1720 }
1721
1722 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1723
1724 if (orderByComparator != null) {
1725 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1726
1727 if (orderByConditionFields.length > 0) {
1728 query.append(WHERE_AND);
1729 }
1730
1731 for (int i = 0; i < orderByConditionFields.length; i++) {
1732 query.append(_ORDER_BY_ENTITY_ALIAS);
1733 query.append(orderByConditionFields[i]);
1734
1735 if ((i + 1) < orderByConditionFields.length) {
1736 if (orderByComparator.isAscending() ^ previous) {
1737 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1738 }
1739 else {
1740 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1741 }
1742 }
1743 else {
1744 if (orderByComparator.isAscending() ^ previous) {
1745 query.append(WHERE_GREATER_THAN);
1746 }
1747 else {
1748 query.append(WHERE_LESSER_THAN);
1749 }
1750 }
1751 }
1752
1753 query.append(ORDER_BY_CLAUSE);
1754
1755 String[] orderByFields = orderByComparator.getOrderByFields();
1756
1757 for (int i = 0; i < orderByFields.length; i++) {
1758 query.append(_ORDER_BY_ENTITY_ALIAS);
1759 query.append(orderByFields[i]);
1760
1761 if ((i + 1) < orderByFields.length) {
1762 if (orderByComparator.isAscending() ^ previous) {
1763 query.append(ORDER_BY_ASC_HAS_NEXT);
1764 }
1765 else {
1766 query.append(ORDER_BY_DESC_HAS_NEXT);
1767 }
1768 }
1769 else {
1770 if (orderByComparator.isAscending() ^ previous) {
1771 query.append(ORDER_BY_ASC);
1772 }
1773 else {
1774 query.append(ORDER_BY_DESC);
1775 }
1776 }
1777 }
1778 }
1779
1780 String sql = query.toString();
1781
1782 Query q = session.createQuery(sql);
1783
1784 q.setFirstResult(0);
1785 q.setMaxResults(2);
1786
1787 QueryPos qPos = QueryPos.getInstance(q);
1788
1789 if (uuid != null) {
1790 qPos.add(uuid);
1791 }
1792
1793 qPos.add(companyId);
1794
1795 if (orderByComparator != null) {
1796 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
1797
1798 for (Object value : values) {
1799 qPos.add(value);
1800 }
1801 }
1802
1803 List<MDRRuleGroupInstance> list = q.list();
1804
1805 if (list.size() == 2) {
1806 return list.get(1);
1807 }
1808 else {
1809 return null;
1810 }
1811 }
1812
1813
1820 public List<MDRRuleGroupInstance> findByGroupId(long groupId)
1821 throws SystemException {
1822 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1823 }
1824
1825
1838 public List<MDRRuleGroupInstance> findByGroupId(long groupId, int start,
1839 int end) throws SystemException {
1840 return findByGroupId(groupId, start, end, null);
1841 }
1842
1843
1857 public List<MDRRuleGroupInstance> findByGroupId(long groupId, int start,
1858 int end, OrderByComparator orderByComparator) throws SystemException {
1859 FinderPath finderPath = null;
1860 Object[] finderArgs = null;
1861
1862 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1863 (orderByComparator == null)) {
1864 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1865 finderArgs = new Object[] { groupId };
1866 }
1867 else {
1868 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1869 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1870 }
1871
1872 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
1873 finderArgs, this);
1874
1875 if ((list != null) && !list.isEmpty()) {
1876 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
1877 if ((groupId != mdrRuleGroupInstance.getGroupId())) {
1878 list = null;
1879
1880 break;
1881 }
1882 }
1883 }
1884
1885 if (list == null) {
1886 StringBundler query = null;
1887
1888 if (orderByComparator != null) {
1889 query = new StringBundler(3 +
1890 (orderByComparator.getOrderByFields().length * 3));
1891 }
1892 else {
1893 query = new StringBundler(2);
1894 }
1895
1896 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
1897
1898 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1899
1900 if (orderByComparator != null) {
1901 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1902 orderByComparator);
1903 }
1904
1905 String sql = query.toString();
1906
1907 Session session = null;
1908
1909 try {
1910 session = openSession();
1911
1912 Query q = session.createQuery(sql);
1913
1914 QueryPos qPos = QueryPos.getInstance(q);
1915
1916 qPos.add(groupId);
1917
1918 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
1919 getDialect(), start, end);
1920 }
1921 catch (Exception e) {
1922 throw processException(e);
1923 }
1924 finally {
1925 if (list == null) {
1926 FinderCacheUtil.removeResult(finderPath, finderArgs);
1927 }
1928 else {
1929 cacheResult(list);
1930
1931 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1932 }
1933
1934 closeSession(session);
1935 }
1936 }
1937
1938 return list;
1939 }
1940
1941
1950 public MDRRuleGroupInstance findByGroupId_First(long groupId,
1951 OrderByComparator orderByComparator)
1952 throws NoSuchRuleGroupInstanceException, SystemException {
1953 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByGroupId_First(groupId,
1954 orderByComparator);
1955
1956 if (mdrRuleGroupInstance != null) {
1957 return mdrRuleGroupInstance;
1958 }
1959
1960 StringBundler msg = new StringBundler(4);
1961
1962 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1963
1964 msg.append("groupId=");
1965 msg.append(groupId);
1966
1967 msg.append(StringPool.CLOSE_CURLY_BRACE);
1968
1969 throw new NoSuchRuleGroupInstanceException(msg.toString());
1970 }
1971
1972
1980 public MDRRuleGroupInstance fetchByGroupId_First(long groupId,
1981 OrderByComparator orderByComparator) throws SystemException {
1982 List<MDRRuleGroupInstance> list = findByGroupId(groupId, 0, 1,
1983 orderByComparator);
1984
1985 if (!list.isEmpty()) {
1986 return list.get(0);
1987 }
1988
1989 return null;
1990 }
1991
1992
2001 public MDRRuleGroupInstance findByGroupId_Last(long groupId,
2002 OrderByComparator orderByComparator)
2003 throws NoSuchRuleGroupInstanceException, SystemException {
2004 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByGroupId_Last(groupId,
2005 orderByComparator);
2006
2007 if (mdrRuleGroupInstance != null) {
2008 return mdrRuleGroupInstance;
2009 }
2010
2011 StringBundler msg = new StringBundler(4);
2012
2013 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2014
2015 msg.append("groupId=");
2016 msg.append(groupId);
2017
2018 msg.append(StringPool.CLOSE_CURLY_BRACE);
2019
2020 throw new NoSuchRuleGroupInstanceException(msg.toString());
2021 }
2022
2023
2031 public MDRRuleGroupInstance fetchByGroupId_Last(long groupId,
2032 OrderByComparator orderByComparator) throws SystemException {
2033 int count = countByGroupId(groupId);
2034
2035 List<MDRRuleGroupInstance> list = findByGroupId(groupId, count - 1,
2036 count, orderByComparator);
2037
2038 if (!list.isEmpty()) {
2039 return list.get(0);
2040 }
2041
2042 return null;
2043 }
2044
2045
2055 public MDRRuleGroupInstance[] findByGroupId_PrevAndNext(
2056 long ruleGroupInstanceId, long groupId,
2057 OrderByComparator orderByComparator)
2058 throws NoSuchRuleGroupInstanceException, SystemException {
2059 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
2060
2061 Session session = null;
2062
2063 try {
2064 session = openSession();
2065
2066 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
2067
2068 array[0] = getByGroupId_PrevAndNext(session, mdrRuleGroupInstance,
2069 groupId, orderByComparator, true);
2070
2071 array[1] = mdrRuleGroupInstance;
2072
2073 array[2] = getByGroupId_PrevAndNext(session, mdrRuleGroupInstance,
2074 groupId, orderByComparator, false);
2075
2076 return array;
2077 }
2078 catch (Exception e) {
2079 throw processException(e);
2080 }
2081 finally {
2082 closeSession(session);
2083 }
2084 }
2085
2086 protected MDRRuleGroupInstance getByGroupId_PrevAndNext(Session session,
2087 MDRRuleGroupInstance mdrRuleGroupInstance, long groupId,
2088 OrderByComparator orderByComparator, boolean previous) {
2089 StringBundler query = null;
2090
2091 if (orderByComparator != null) {
2092 query = new StringBundler(6 +
2093 (orderByComparator.getOrderByFields().length * 6));
2094 }
2095 else {
2096 query = new StringBundler(3);
2097 }
2098
2099 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2100
2101 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2102
2103 if (orderByComparator != null) {
2104 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2105
2106 if (orderByConditionFields.length > 0) {
2107 query.append(WHERE_AND);
2108 }
2109
2110 for (int i = 0; i < orderByConditionFields.length; i++) {
2111 query.append(_ORDER_BY_ENTITY_ALIAS);
2112 query.append(orderByConditionFields[i]);
2113
2114 if ((i + 1) < orderByConditionFields.length) {
2115 if (orderByComparator.isAscending() ^ previous) {
2116 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2117 }
2118 else {
2119 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2120 }
2121 }
2122 else {
2123 if (orderByComparator.isAscending() ^ previous) {
2124 query.append(WHERE_GREATER_THAN);
2125 }
2126 else {
2127 query.append(WHERE_LESSER_THAN);
2128 }
2129 }
2130 }
2131
2132 query.append(ORDER_BY_CLAUSE);
2133
2134 String[] orderByFields = orderByComparator.getOrderByFields();
2135
2136 for (int i = 0; i < orderByFields.length; i++) {
2137 query.append(_ORDER_BY_ENTITY_ALIAS);
2138 query.append(orderByFields[i]);
2139
2140 if ((i + 1) < orderByFields.length) {
2141 if (orderByComparator.isAscending() ^ previous) {
2142 query.append(ORDER_BY_ASC_HAS_NEXT);
2143 }
2144 else {
2145 query.append(ORDER_BY_DESC_HAS_NEXT);
2146 }
2147 }
2148 else {
2149 if (orderByComparator.isAscending() ^ previous) {
2150 query.append(ORDER_BY_ASC);
2151 }
2152 else {
2153 query.append(ORDER_BY_DESC);
2154 }
2155 }
2156 }
2157 }
2158
2159 String sql = query.toString();
2160
2161 Query q = session.createQuery(sql);
2162
2163 q.setFirstResult(0);
2164 q.setMaxResults(2);
2165
2166 QueryPos qPos = QueryPos.getInstance(q);
2167
2168 qPos.add(groupId);
2169
2170 if (orderByComparator != null) {
2171 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
2172
2173 for (Object value : values) {
2174 qPos.add(value);
2175 }
2176 }
2177
2178 List<MDRRuleGroupInstance> list = q.list();
2179
2180 if (list.size() == 2) {
2181 return list.get(1);
2182 }
2183 else {
2184 return null;
2185 }
2186 }
2187
2188
2195 public List<MDRRuleGroupInstance> filterFindByGroupId(long groupId)
2196 throws SystemException {
2197 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2198 QueryUtil.ALL_POS, null);
2199 }
2200
2201
2214 public List<MDRRuleGroupInstance> filterFindByGroupId(long groupId,
2215 int start, int end) throws SystemException {
2216 return filterFindByGroupId(groupId, start, end, null);
2217 }
2218
2219
2233 public List<MDRRuleGroupInstance> filterFindByGroupId(long groupId,
2234 int start, int end, OrderByComparator orderByComparator)
2235 throws SystemException {
2236 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2237 return findByGroupId(groupId, start, end, orderByComparator);
2238 }
2239
2240 StringBundler query = null;
2241
2242 if (orderByComparator != null) {
2243 query = new StringBundler(3 +
2244 (orderByComparator.getOrderByFields().length * 3));
2245 }
2246 else {
2247 query = new StringBundler(2);
2248 }
2249
2250 if (getDB().isSupportsInlineDistinct()) {
2251 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2252 }
2253 else {
2254 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
2255 }
2256
2257 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2258
2259 if (!getDB().isSupportsInlineDistinct()) {
2260 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
2261 }
2262
2263 if (orderByComparator != null) {
2264 if (getDB().isSupportsInlineDistinct()) {
2265 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2266 orderByComparator);
2267 }
2268 else {
2269 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2270 orderByComparator);
2271 }
2272 }
2273
2274 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2275 MDRRuleGroupInstance.class.getName(),
2276 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2277
2278 Session session = null;
2279
2280 try {
2281 session = openSession();
2282
2283 SQLQuery q = session.createSQLQuery(sql);
2284
2285 if (getDB().isSupportsInlineDistinct()) {
2286 q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
2287 }
2288 else {
2289 q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
2290 }
2291
2292 QueryPos qPos = QueryPos.getInstance(q);
2293
2294 qPos.add(groupId);
2295
2296 return (List<MDRRuleGroupInstance>)QueryUtil.list(q, getDialect(),
2297 start, end);
2298 }
2299 catch (Exception e) {
2300 throw processException(e);
2301 }
2302 finally {
2303 closeSession(session);
2304 }
2305 }
2306
2307
2317 public MDRRuleGroupInstance[] filterFindByGroupId_PrevAndNext(
2318 long ruleGroupInstanceId, long groupId,
2319 OrderByComparator orderByComparator)
2320 throws NoSuchRuleGroupInstanceException, SystemException {
2321 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2322 return findByGroupId_PrevAndNext(ruleGroupInstanceId, groupId,
2323 orderByComparator);
2324 }
2325
2326 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
2327
2328 Session session = null;
2329
2330 try {
2331 session = openSession();
2332
2333 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
2334
2335 array[0] = filterGetByGroupId_PrevAndNext(session,
2336 mdrRuleGroupInstance, groupId, orderByComparator, true);
2337
2338 array[1] = mdrRuleGroupInstance;
2339
2340 array[2] = filterGetByGroupId_PrevAndNext(session,
2341 mdrRuleGroupInstance, groupId, orderByComparator, false);
2342
2343 return array;
2344 }
2345 catch (Exception e) {
2346 throw processException(e);
2347 }
2348 finally {
2349 closeSession(session);
2350 }
2351 }
2352
2353 protected MDRRuleGroupInstance filterGetByGroupId_PrevAndNext(
2354 Session session, MDRRuleGroupInstance mdrRuleGroupInstance,
2355 long groupId, OrderByComparator orderByComparator, boolean previous) {
2356 StringBundler query = null;
2357
2358 if (orderByComparator != null) {
2359 query = new StringBundler(6 +
2360 (orderByComparator.getOrderByFields().length * 6));
2361 }
2362 else {
2363 query = new StringBundler(3);
2364 }
2365
2366 if (getDB().isSupportsInlineDistinct()) {
2367 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2368 }
2369 else {
2370 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
2371 }
2372
2373 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2374
2375 if (!getDB().isSupportsInlineDistinct()) {
2376 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
2377 }
2378
2379 if (orderByComparator != null) {
2380 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2381
2382 if (orderByConditionFields.length > 0) {
2383 query.append(WHERE_AND);
2384 }
2385
2386 for (int i = 0; i < orderByConditionFields.length; i++) {
2387 if (getDB().isSupportsInlineDistinct()) {
2388 query.append(_ORDER_BY_ENTITY_ALIAS);
2389 }
2390 else {
2391 query.append(_ORDER_BY_ENTITY_TABLE);
2392 }
2393
2394 query.append(orderByConditionFields[i]);
2395
2396 if ((i + 1) < orderByConditionFields.length) {
2397 if (orderByComparator.isAscending() ^ previous) {
2398 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2399 }
2400 else {
2401 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2402 }
2403 }
2404 else {
2405 if (orderByComparator.isAscending() ^ previous) {
2406 query.append(WHERE_GREATER_THAN);
2407 }
2408 else {
2409 query.append(WHERE_LESSER_THAN);
2410 }
2411 }
2412 }
2413
2414 query.append(ORDER_BY_CLAUSE);
2415
2416 String[] orderByFields = orderByComparator.getOrderByFields();
2417
2418 for (int i = 0; i < orderByFields.length; i++) {
2419 if (getDB().isSupportsInlineDistinct()) {
2420 query.append(_ORDER_BY_ENTITY_ALIAS);
2421 }
2422 else {
2423 query.append(_ORDER_BY_ENTITY_TABLE);
2424 }
2425
2426 query.append(orderByFields[i]);
2427
2428 if ((i + 1) < orderByFields.length) {
2429 if (orderByComparator.isAscending() ^ previous) {
2430 query.append(ORDER_BY_ASC_HAS_NEXT);
2431 }
2432 else {
2433 query.append(ORDER_BY_DESC_HAS_NEXT);
2434 }
2435 }
2436 else {
2437 if (orderByComparator.isAscending() ^ previous) {
2438 query.append(ORDER_BY_ASC);
2439 }
2440 else {
2441 query.append(ORDER_BY_DESC);
2442 }
2443 }
2444 }
2445 }
2446
2447 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2448 MDRRuleGroupInstance.class.getName(),
2449 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2450
2451 SQLQuery q = session.createSQLQuery(sql);
2452
2453 q.setFirstResult(0);
2454 q.setMaxResults(2);
2455
2456 if (getDB().isSupportsInlineDistinct()) {
2457 q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
2458 }
2459 else {
2460 q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
2461 }
2462
2463 QueryPos qPos = QueryPos.getInstance(q);
2464
2465 qPos.add(groupId);
2466
2467 if (orderByComparator != null) {
2468 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
2469
2470 for (Object value : values) {
2471 qPos.add(value);
2472 }
2473 }
2474
2475 List<MDRRuleGroupInstance> list = q.list();
2476
2477 if (list.size() == 2) {
2478 return list.get(1);
2479 }
2480 else {
2481 return null;
2482 }
2483 }
2484
2485
2492 public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId)
2493 throws SystemException {
2494 return findByRuleGroupId(ruleGroupId, QueryUtil.ALL_POS,
2495 QueryUtil.ALL_POS, null);
2496 }
2497
2498
2511 public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId,
2512 int start, int end) throws SystemException {
2513 return findByRuleGroupId(ruleGroupId, start, end, null);
2514 }
2515
2516
2530 public List<MDRRuleGroupInstance> findByRuleGroupId(long ruleGroupId,
2531 int start, int end, OrderByComparator orderByComparator)
2532 throws SystemException {
2533 FinderPath finderPath = null;
2534 Object[] finderArgs = null;
2535
2536 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2537 (orderByComparator == null)) {
2538 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPID;
2539 finderArgs = new Object[] { ruleGroupId };
2540 }
2541 else {
2542 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPID;
2543 finderArgs = new Object[] { ruleGroupId, start, end, orderByComparator };
2544 }
2545
2546 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
2547 finderArgs, this);
2548
2549 if ((list != null) && !list.isEmpty()) {
2550 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
2551 if ((ruleGroupId != mdrRuleGroupInstance.getRuleGroupId())) {
2552 list = null;
2553
2554 break;
2555 }
2556 }
2557 }
2558
2559 if (list == null) {
2560 StringBundler query = null;
2561
2562 if (orderByComparator != null) {
2563 query = new StringBundler(3 +
2564 (orderByComparator.getOrderByFields().length * 3));
2565 }
2566 else {
2567 query = new StringBundler(2);
2568 }
2569
2570 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2571
2572 query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
2573
2574 if (orderByComparator != null) {
2575 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2576 orderByComparator);
2577 }
2578
2579 String sql = query.toString();
2580
2581 Session session = null;
2582
2583 try {
2584 session = openSession();
2585
2586 Query q = session.createQuery(sql);
2587
2588 QueryPos qPos = QueryPos.getInstance(q);
2589
2590 qPos.add(ruleGroupId);
2591
2592 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
2593 getDialect(), start, end);
2594 }
2595 catch (Exception e) {
2596 throw processException(e);
2597 }
2598 finally {
2599 if (list == null) {
2600 FinderCacheUtil.removeResult(finderPath, finderArgs);
2601 }
2602 else {
2603 cacheResult(list);
2604
2605 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2606 }
2607
2608 closeSession(session);
2609 }
2610 }
2611
2612 return list;
2613 }
2614
2615
2624 public MDRRuleGroupInstance findByRuleGroupId_First(long ruleGroupId,
2625 OrderByComparator orderByComparator)
2626 throws NoSuchRuleGroupInstanceException, SystemException {
2627 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByRuleGroupId_First(ruleGroupId,
2628 orderByComparator);
2629
2630 if (mdrRuleGroupInstance != null) {
2631 return mdrRuleGroupInstance;
2632 }
2633
2634 StringBundler msg = new StringBundler(4);
2635
2636 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2637
2638 msg.append("ruleGroupId=");
2639 msg.append(ruleGroupId);
2640
2641 msg.append(StringPool.CLOSE_CURLY_BRACE);
2642
2643 throw new NoSuchRuleGroupInstanceException(msg.toString());
2644 }
2645
2646
2654 public MDRRuleGroupInstance fetchByRuleGroupId_First(long ruleGroupId,
2655 OrderByComparator orderByComparator) throws SystemException {
2656 List<MDRRuleGroupInstance> list = findByRuleGroupId(ruleGroupId, 0, 1,
2657 orderByComparator);
2658
2659 if (!list.isEmpty()) {
2660 return list.get(0);
2661 }
2662
2663 return null;
2664 }
2665
2666
2675 public MDRRuleGroupInstance findByRuleGroupId_Last(long ruleGroupId,
2676 OrderByComparator orderByComparator)
2677 throws NoSuchRuleGroupInstanceException, SystemException {
2678 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByRuleGroupId_Last(ruleGroupId,
2679 orderByComparator);
2680
2681 if (mdrRuleGroupInstance != null) {
2682 return mdrRuleGroupInstance;
2683 }
2684
2685 StringBundler msg = new StringBundler(4);
2686
2687 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2688
2689 msg.append("ruleGroupId=");
2690 msg.append(ruleGroupId);
2691
2692 msg.append(StringPool.CLOSE_CURLY_BRACE);
2693
2694 throw new NoSuchRuleGroupInstanceException(msg.toString());
2695 }
2696
2697
2705 public MDRRuleGroupInstance fetchByRuleGroupId_Last(long ruleGroupId,
2706 OrderByComparator orderByComparator) throws SystemException {
2707 int count = countByRuleGroupId(ruleGroupId);
2708
2709 List<MDRRuleGroupInstance> list = findByRuleGroupId(ruleGroupId,
2710 count - 1, count, orderByComparator);
2711
2712 if (!list.isEmpty()) {
2713 return list.get(0);
2714 }
2715
2716 return null;
2717 }
2718
2719
2729 public MDRRuleGroupInstance[] findByRuleGroupId_PrevAndNext(
2730 long ruleGroupInstanceId, long ruleGroupId,
2731 OrderByComparator orderByComparator)
2732 throws NoSuchRuleGroupInstanceException, SystemException {
2733 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
2734
2735 Session session = null;
2736
2737 try {
2738 session = openSession();
2739
2740 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
2741
2742 array[0] = getByRuleGroupId_PrevAndNext(session,
2743 mdrRuleGroupInstance, ruleGroupId, orderByComparator, true);
2744
2745 array[1] = mdrRuleGroupInstance;
2746
2747 array[2] = getByRuleGroupId_PrevAndNext(session,
2748 mdrRuleGroupInstance, ruleGroupId, orderByComparator, false);
2749
2750 return array;
2751 }
2752 catch (Exception e) {
2753 throw processException(e);
2754 }
2755 finally {
2756 closeSession(session);
2757 }
2758 }
2759
2760 protected MDRRuleGroupInstance getByRuleGroupId_PrevAndNext(
2761 Session session, MDRRuleGroupInstance mdrRuleGroupInstance,
2762 long ruleGroupId, OrderByComparator orderByComparator, boolean previous) {
2763 StringBundler query = null;
2764
2765 if (orderByComparator != null) {
2766 query = new StringBundler(6 +
2767 (orderByComparator.getOrderByFields().length * 6));
2768 }
2769 else {
2770 query = new StringBundler(3);
2771 }
2772
2773 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2774
2775 query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
2776
2777 if (orderByComparator != null) {
2778 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2779
2780 if (orderByConditionFields.length > 0) {
2781 query.append(WHERE_AND);
2782 }
2783
2784 for (int i = 0; i < orderByConditionFields.length; i++) {
2785 query.append(_ORDER_BY_ENTITY_ALIAS);
2786 query.append(orderByConditionFields[i]);
2787
2788 if ((i + 1) < orderByConditionFields.length) {
2789 if (orderByComparator.isAscending() ^ previous) {
2790 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2791 }
2792 else {
2793 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2794 }
2795 }
2796 else {
2797 if (orderByComparator.isAscending() ^ previous) {
2798 query.append(WHERE_GREATER_THAN);
2799 }
2800 else {
2801 query.append(WHERE_LESSER_THAN);
2802 }
2803 }
2804 }
2805
2806 query.append(ORDER_BY_CLAUSE);
2807
2808 String[] orderByFields = orderByComparator.getOrderByFields();
2809
2810 for (int i = 0; i < orderByFields.length; i++) {
2811 query.append(_ORDER_BY_ENTITY_ALIAS);
2812 query.append(orderByFields[i]);
2813
2814 if ((i + 1) < orderByFields.length) {
2815 if (orderByComparator.isAscending() ^ previous) {
2816 query.append(ORDER_BY_ASC_HAS_NEXT);
2817 }
2818 else {
2819 query.append(ORDER_BY_DESC_HAS_NEXT);
2820 }
2821 }
2822 else {
2823 if (orderByComparator.isAscending() ^ previous) {
2824 query.append(ORDER_BY_ASC);
2825 }
2826 else {
2827 query.append(ORDER_BY_DESC);
2828 }
2829 }
2830 }
2831 }
2832
2833 String sql = query.toString();
2834
2835 Query q = session.createQuery(sql);
2836
2837 q.setFirstResult(0);
2838 q.setMaxResults(2);
2839
2840 QueryPos qPos = QueryPos.getInstance(q);
2841
2842 qPos.add(ruleGroupId);
2843
2844 if (orderByComparator != null) {
2845 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
2846
2847 for (Object value : values) {
2848 qPos.add(value);
2849 }
2850 }
2851
2852 List<MDRRuleGroupInstance> list = q.list();
2853
2854 if (list.size() == 2) {
2855 return list.get(1);
2856 }
2857 else {
2858 return null;
2859 }
2860 }
2861
2862
2870 public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK)
2871 throws SystemException {
2872 return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2873 QueryUtil.ALL_POS, null);
2874 }
2875
2876
2890 public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK,
2891 int start, int end) throws SystemException {
2892 return findByC_C(classNameId, classPK, start, end, null);
2893 }
2894
2895
2910 public List<MDRRuleGroupInstance> findByC_C(long classNameId, long classPK,
2911 int start, int end, OrderByComparator orderByComparator)
2912 throws SystemException {
2913 FinderPath finderPath = null;
2914 Object[] finderArgs = null;
2915
2916 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2917 (orderByComparator == null)) {
2918 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2919 finderArgs = new Object[] { classNameId, classPK };
2920 }
2921 else {
2922 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2923 finderArgs = new Object[] {
2924 classNameId, classPK,
2925
2926 start, end, orderByComparator
2927 };
2928 }
2929
2930 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
2931 finderArgs, this);
2932
2933 if ((list != null) && !list.isEmpty()) {
2934 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
2935 if ((classNameId != mdrRuleGroupInstance.getClassNameId()) ||
2936 (classPK != mdrRuleGroupInstance.getClassPK())) {
2937 list = null;
2938
2939 break;
2940 }
2941 }
2942 }
2943
2944 if (list == null) {
2945 StringBundler query = null;
2946
2947 if (orderByComparator != null) {
2948 query = new StringBundler(4 +
2949 (orderByComparator.getOrderByFields().length * 3));
2950 }
2951 else {
2952 query = new StringBundler(3);
2953 }
2954
2955 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
2956
2957 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2958
2959 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2960
2961 if (orderByComparator != null) {
2962 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2963 orderByComparator);
2964 }
2965
2966 String sql = query.toString();
2967
2968 Session session = null;
2969
2970 try {
2971 session = openSession();
2972
2973 Query q = session.createQuery(sql);
2974
2975 QueryPos qPos = QueryPos.getInstance(q);
2976
2977 qPos.add(classNameId);
2978
2979 qPos.add(classPK);
2980
2981 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
2982 getDialect(), start, end);
2983 }
2984 catch (Exception e) {
2985 throw processException(e);
2986 }
2987 finally {
2988 if (list == null) {
2989 FinderCacheUtil.removeResult(finderPath, finderArgs);
2990 }
2991 else {
2992 cacheResult(list);
2993
2994 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2995 }
2996
2997 closeSession(session);
2998 }
2999 }
3000
3001 return list;
3002 }
3003
3004
3014 public MDRRuleGroupInstance findByC_C_First(long classNameId, long classPK,
3015 OrderByComparator orderByComparator)
3016 throws NoSuchRuleGroupInstanceException, SystemException {
3017 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByC_C_First(classNameId,
3018 classPK, orderByComparator);
3019
3020 if (mdrRuleGroupInstance != null) {
3021 return mdrRuleGroupInstance;
3022 }
3023
3024 StringBundler msg = new StringBundler(6);
3025
3026 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3027
3028 msg.append("classNameId=");
3029 msg.append(classNameId);
3030
3031 msg.append(", classPK=");
3032 msg.append(classPK);
3033
3034 msg.append(StringPool.CLOSE_CURLY_BRACE);
3035
3036 throw new NoSuchRuleGroupInstanceException(msg.toString());
3037 }
3038
3039
3048 public MDRRuleGroupInstance fetchByC_C_First(long classNameId,
3049 long classPK, OrderByComparator orderByComparator)
3050 throws SystemException {
3051 List<MDRRuleGroupInstance> list = findByC_C(classNameId, classPK, 0, 1,
3052 orderByComparator);
3053
3054 if (!list.isEmpty()) {
3055 return list.get(0);
3056 }
3057
3058 return null;
3059 }
3060
3061
3071 public MDRRuleGroupInstance findByC_C_Last(long classNameId, long classPK,
3072 OrderByComparator orderByComparator)
3073 throws NoSuchRuleGroupInstanceException, SystemException {
3074 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByC_C_Last(classNameId,
3075 classPK, orderByComparator);
3076
3077 if (mdrRuleGroupInstance != null) {
3078 return mdrRuleGroupInstance;
3079 }
3080
3081 StringBundler msg = new StringBundler(6);
3082
3083 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3084
3085 msg.append("classNameId=");
3086 msg.append(classNameId);
3087
3088 msg.append(", classPK=");
3089 msg.append(classPK);
3090
3091 msg.append(StringPool.CLOSE_CURLY_BRACE);
3092
3093 throw new NoSuchRuleGroupInstanceException(msg.toString());
3094 }
3095
3096
3105 public MDRRuleGroupInstance fetchByC_C_Last(long classNameId, long classPK,
3106 OrderByComparator orderByComparator) throws SystemException {
3107 int count = countByC_C(classNameId, classPK);
3108
3109 List<MDRRuleGroupInstance> list = findByC_C(classNameId, classPK,
3110 count - 1, count, orderByComparator);
3111
3112 if (!list.isEmpty()) {
3113 return list.get(0);
3114 }
3115
3116 return null;
3117 }
3118
3119
3130 public MDRRuleGroupInstance[] findByC_C_PrevAndNext(
3131 long ruleGroupInstanceId, long classNameId, long classPK,
3132 OrderByComparator orderByComparator)
3133 throws NoSuchRuleGroupInstanceException, SystemException {
3134 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
3135
3136 Session session = null;
3137
3138 try {
3139 session = openSession();
3140
3141 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
3142
3143 array[0] = getByC_C_PrevAndNext(session, mdrRuleGroupInstance,
3144 classNameId, classPK, orderByComparator, true);
3145
3146 array[1] = mdrRuleGroupInstance;
3147
3148 array[2] = getByC_C_PrevAndNext(session, mdrRuleGroupInstance,
3149 classNameId, classPK, orderByComparator, false);
3150
3151 return array;
3152 }
3153 catch (Exception e) {
3154 throw processException(e);
3155 }
3156 finally {
3157 closeSession(session);
3158 }
3159 }
3160
3161 protected MDRRuleGroupInstance getByC_C_PrevAndNext(Session session,
3162 MDRRuleGroupInstance mdrRuleGroupInstance, long classNameId,
3163 long classPK, OrderByComparator orderByComparator, boolean previous) {
3164 StringBundler query = null;
3165
3166 if (orderByComparator != null) {
3167 query = new StringBundler(6 +
3168 (orderByComparator.getOrderByFields().length * 6));
3169 }
3170 else {
3171 query = new StringBundler(3);
3172 }
3173
3174 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3175
3176 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3177
3178 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3179
3180 if (orderByComparator != null) {
3181 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3182
3183 if (orderByConditionFields.length > 0) {
3184 query.append(WHERE_AND);
3185 }
3186
3187 for (int i = 0; i < orderByConditionFields.length; i++) {
3188 query.append(_ORDER_BY_ENTITY_ALIAS);
3189 query.append(orderByConditionFields[i]);
3190
3191 if ((i + 1) < orderByConditionFields.length) {
3192 if (orderByComparator.isAscending() ^ previous) {
3193 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3194 }
3195 else {
3196 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3197 }
3198 }
3199 else {
3200 if (orderByComparator.isAscending() ^ previous) {
3201 query.append(WHERE_GREATER_THAN);
3202 }
3203 else {
3204 query.append(WHERE_LESSER_THAN);
3205 }
3206 }
3207 }
3208
3209 query.append(ORDER_BY_CLAUSE);
3210
3211 String[] orderByFields = orderByComparator.getOrderByFields();
3212
3213 for (int i = 0; i < orderByFields.length; i++) {
3214 query.append(_ORDER_BY_ENTITY_ALIAS);
3215 query.append(orderByFields[i]);
3216
3217 if ((i + 1) < orderByFields.length) {
3218 if (orderByComparator.isAscending() ^ previous) {
3219 query.append(ORDER_BY_ASC_HAS_NEXT);
3220 }
3221 else {
3222 query.append(ORDER_BY_DESC_HAS_NEXT);
3223 }
3224 }
3225 else {
3226 if (orderByComparator.isAscending() ^ previous) {
3227 query.append(ORDER_BY_ASC);
3228 }
3229 else {
3230 query.append(ORDER_BY_DESC);
3231 }
3232 }
3233 }
3234 }
3235
3236 String sql = query.toString();
3237
3238 Query q = session.createQuery(sql);
3239
3240 q.setFirstResult(0);
3241 q.setMaxResults(2);
3242
3243 QueryPos qPos = QueryPos.getInstance(q);
3244
3245 qPos.add(classNameId);
3246
3247 qPos.add(classPK);
3248
3249 if (orderByComparator != null) {
3250 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
3251
3252 for (Object value : values) {
3253 qPos.add(value);
3254 }
3255 }
3256
3257 List<MDRRuleGroupInstance> list = q.list();
3258
3259 if (list.size() == 2) {
3260 return list.get(1);
3261 }
3262 else {
3263 return null;
3264 }
3265 }
3266
3267
3276 public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
3277 long classNameId, long classPK) throws SystemException {
3278 return findByG_C_C(groupId, classNameId, classPK, QueryUtil.ALL_POS,
3279 QueryUtil.ALL_POS, null);
3280 }
3281
3282
3297 public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
3298 long classNameId, long classPK, int start, int end)
3299 throws SystemException {
3300 return findByG_C_C(groupId, classNameId, classPK, start, end, null);
3301 }
3302
3303
3319 public List<MDRRuleGroupInstance> findByG_C_C(long groupId,
3320 long classNameId, long classPK, int start, int end,
3321 OrderByComparator orderByComparator) throws SystemException {
3322 FinderPath finderPath = null;
3323 Object[] finderArgs = null;
3324
3325 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3326 (orderByComparator == null)) {
3327 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C;
3328 finderArgs = new Object[] { groupId, classNameId, classPK };
3329 }
3330 else {
3331 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C;
3332 finderArgs = new Object[] {
3333 groupId, classNameId, classPK,
3334
3335 start, end, orderByComparator
3336 };
3337 }
3338
3339 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
3340 finderArgs, this);
3341
3342 if ((list != null) && !list.isEmpty()) {
3343 for (MDRRuleGroupInstance mdrRuleGroupInstance : list) {
3344 if ((groupId != mdrRuleGroupInstance.getGroupId()) ||
3345 (classNameId != mdrRuleGroupInstance.getClassNameId()) ||
3346 (classPK != mdrRuleGroupInstance.getClassPK())) {
3347 list = null;
3348
3349 break;
3350 }
3351 }
3352 }
3353
3354 if (list == null) {
3355 StringBundler query = null;
3356
3357 if (orderByComparator != null) {
3358 query = new StringBundler(5 +
3359 (orderByComparator.getOrderByFields().length * 3));
3360 }
3361 else {
3362 query = new StringBundler(4);
3363 }
3364
3365 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3366
3367 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3368
3369 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3370
3371 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3372
3373 if (orderByComparator != null) {
3374 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3375 orderByComparator);
3376 }
3377
3378 String sql = query.toString();
3379
3380 Session session = null;
3381
3382 try {
3383 session = openSession();
3384
3385 Query q = session.createQuery(sql);
3386
3387 QueryPos qPos = QueryPos.getInstance(q);
3388
3389 qPos.add(groupId);
3390
3391 qPos.add(classNameId);
3392
3393 qPos.add(classPK);
3394
3395 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
3396 getDialect(), start, end);
3397 }
3398 catch (Exception e) {
3399 throw processException(e);
3400 }
3401 finally {
3402 if (list == null) {
3403 FinderCacheUtil.removeResult(finderPath, finderArgs);
3404 }
3405 else {
3406 cacheResult(list);
3407
3408 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3409 }
3410
3411 closeSession(session);
3412 }
3413 }
3414
3415 return list;
3416 }
3417
3418
3429 public MDRRuleGroupInstance findByG_C_C_First(long groupId,
3430 long classNameId, long classPK, OrderByComparator orderByComparator)
3431 throws NoSuchRuleGroupInstanceException, SystemException {
3432 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByG_C_C_First(groupId,
3433 classNameId, classPK, orderByComparator);
3434
3435 if (mdrRuleGroupInstance != null) {
3436 return mdrRuleGroupInstance;
3437 }
3438
3439 StringBundler msg = new StringBundler(8);
3440
3441 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3442
3443 msg.append("groupId=");
3444 msg.append(groupId);
3445
3446 msg.append(", classNameId=");
3447 msg.append(classNameId);
3448
3449 msg.append(", classPK=");
3450 msg.append(classPK);
3451
3452 msg.append(StringPool.CLOSE_CURLY_BRACE);
3453
3454 throw new NoSuchRuleGroupInstanceException(msg.toString());
3455 }
3456
3457
3467 public MDRRuleGroupInstance fetchByG_C_C_First(long groupId,
3468 long classNameId, long classPK, OrderByComparator orderByComparator)
3469 throws SystemException {
3470 List<MDRRuleGroupInstance> list = findByG_C_C(groupId, classNameId,
3471 classPK, 0, 1, orderByComparator);
3472
3473 if (!list.isEmpty()) {
3474 return list.get(0);
3475 }
3476
3477 return null;
3478 }
3479
3480
3491 public MDRRuleGroupInstance findByG_C_C_Last(long groupId,
3492 long classNameId, long classPK, OrderByComparator orderByComparator)
3493 throws NoSuchRuleGroupInstanceException, SystemException {
3494 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByG_C_C_Last(groupId,
3495 classNameId, classPK, orderByComparator);
3496
3497 if (mdrRuleGroupInstance != null) {
3498 return mdrRuleGroupInstance;
3499 }
3500
3501 StringBundler msg = new StringBundler(8);
3502
3503 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3504
3505 msg.append("groupId=");
3506 msg.append(groupId);
3507
3508 msg.append(", classNameId=");
3509 msg.append(classNameId);
3510
3511 msg.append(", classPK=");
3512 msg.append(classPK);
3513
3514 msg.append(StringPool.CLOSE_CURLY_BRACE);
3515
3516 throw new NoSuchRuleGroupInstanceException(msg.toString());
3517 }
3518
3519
3529 public MDRRuleGroupInstance fetchByG_C_C_Last(long groupId,
3530 long classNameId, long classPK, OrderByComparator orderByComparator)
3531 throws SystemException {
3532 int count = countByG_C_C(groupId, classNameId, classPK);
3533
3534 List<MDRRuleGroupInstance> list = findByG_C_C(groupId, classNameId,
3535 classPK, count - 1, count, orderByComparator);
3536
3537 if (!list.isEmpty()) {
3538 return list.get(0);
3539 }
3540
3541 return null;
3542 }
3543
3544
3556 public MDRRuleGroupInstance[] findByG_C_C_PrevAndNext(
3557 long ruleGroupInstanceId, long groupId, long classNameId, long classPK,
3558 OrderByComparator orderByComparator)
3559 throws NoSuchRuleGroupInstanceException, SystemException {
3560 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
3561
3562 Session session = null;
3563
3564 try {
3565 session = openSession();
3566
3567 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
3568
3569 array[0] = getByG_C_C_PrevAndNext(session, mdrRuleGroupInstance,
3570 groupId, classNameId, classPK, orderByComparator, true);
3571
3572 array[1] = mdrRuleGroupInstance;
3573
3574 array[2] = getByG_C_C_PrevAndNext(session, mdrRuleGroupInstance,
3575 groupId, classNameId, classPK, orderByComparator, false);
3576
3577 return array;
3578 }
3579 catch (Exception e) {
3580 throw processException(e);
3581 }
3582 finally {
3583 closeSession(session);
3584 }
3585 }
3586
3587 protected MDRRuleGroupInstance getByG_C_C_PrevAndNext(Session session,
3588 MDRRuleGroupInstance mdrRuleGroupInstance, long groupId,
3589 long classNameId, long classPK, OrderByComparator orderByComparator,
3590 boolean previous) {
3591 StringBundler query = null;
3592
3593 if (orderByComparator != null) {
3594 query = new StringBundler(6 +
3595 (orderByComparator.getOrderByFields().length * 6));
3596 }
3597 else {
3598 query = new StringBundler(3);
3599 }
3600
3601 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3602
3603 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3604
3605 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3606
3607 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3608
3609 if (orderByComparator != null) {
3610 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3611
3612 if (orderByConditionFields.length > 0) {
3613 query.append(WHERE_AND);
3614 }
3615
3616 for (int i = 0; i < orderByConditionFields.length; i++) {
3617 query.append(_ORDER_BY_ENTITY_ALIAS);
3618 query.append(orderByConditionFields[i]);
3619
3620 if ((i + 1) < orderByConditionFields.length) {
3621 if (orderByComparator.isAscending() ^ previous) {
3622 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3623 }
3624 else {
3625 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3626 }
3627 }
3628 else {
3629 if (orderByComparator.isAscending() ^ previous) {
3630 query.append(WHERE_GREATER_THAN);
3631 }
3632 else {
3633 query.append(WHERE_LESSER_THAN);
3634 }
3635 }
3636 }
3637
3638 query.append(ORDER_BY_CLAUSE);
3639
3640 String[] orderByFields = orderByComparator.getOrderByFields();
3641
3642 for (int i = 0; i < orderByFields.length; i++) {
3643 query.append(_ORDER_BY_ENTITY_ALIAS);
3644 query.append(orderByFields[i]);
3645
3646 if ((i + 1) < orderByFields.length) {
3647 if (orderByComparator.isAscending() ^ previous) {
3648 query.append(ORDER_BY_ASC_HAS_NEXT);
3649 }
3650 else {
3651 query.append(ORDER_BY_DESC_HAS_NEXT);
3652 }
3653 }
3654 else {
3655 if (orderByComparator.isAscending() ^ previous) {
3656 query.append(ORDER_BY_ASC);
3657 }
3658 else {
3659 query.append(ORDER_BY_DESC);
3660 }
3661 }
3662 }
3663 }
3664
3665 String sql = query.toString();
3666
3667 Query q = session.createQuery(sql);
3668
3669 q.setFirstResult(0);
3670 q.setMaxResults(2);
3671
3672 QueryPos qPos = QueryPos.getInstance(q);
3673
3674 qPos.add(groupId);
3675
3676 qPos.add(classNameId);
3677
3678 qPos.add(classPK);
3679
3680 if (orderByComparator != null) {
3681 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
3682
3683 for (Object value : values) {
3684 qPos.add(value);
3685 }
3686 }
3687
3688 List<MDRRuleGroupInstance> list = q.list();
3689
3690 if (list.size() == 2) {
3691 return list.get(1);
3692 }
3693 else {
3694 return null;
3695 }
3696 }
3697
3698
3707 public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
3708 long classNameId, long classPK) throws SystemException {
3709 return filterFindByG_C_C(groupId, classNameId, classPK,
3710 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3711 }
3712
3713
3728 public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
3729 long classNameId, long classPK, int start, int end)
3730 throws SystemException {
3731 return filterFindByG_C_C(groupId, classNameId, classPK, start, end, null);
3732 }
3733
3734
3750 public List<MDRRuleGroupInstance> filterFindByG_C_C(long groupId,
3751 long classNameId, long classPK, int start, int end,
3752 OrderByComparator orderByComparator) throws SystemException {
3753 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3754 return findByG_C_C(groupId, classNameId, classPK, start, end,
3755 orderByComparator);
3756 }
3757
3758 StringBundler query = null;
3759
3760 if (orderByComparator != null) {
3761 query = new StringBundler(5 +
3762 (orderByComparator.getOrderByFields().length * 3));
3763 }
3764 else {
3765 query = new StringBundler(4);
3766 }
3767
3768 if (getDB().isSupportsInlineDistinct()) {
3769 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3770 }
3771 else {
3772 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
3773 }
3774
3775 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3776
3777 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3778
3779 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3780
3781 if (!getDB().isSupportsInlineDistinct()) {
3782 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
3783 }
3784
3785 if (orderByComparator != null) {
3786 if (getDB().isSupportsInlineDistinct()) {
3787 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3788 orderByComparator);
3789 }
3790 else {
3791 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3792 orderByComparator);
3793 }
3794 }
3795
3796 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3797 MDRRuleGroupInstance.class.getName(),
3798 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3799
3800 Session session = null;
3801
3802 try {
3803 session = openSession();
3804
3805 SQLQuery q = session.createSQLQuery(sql);
3806
3807 if (getDB().isSupportsInlineDistinct()) {
3808 q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
3809 }
3810 else {
3811 q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
3812 }
3813
3814 QueryPos qPos = QueryPos.getInstance(q);
3815
3816 qPos.add(groupId);
3817
3818 qPos.add(classNameId);
3819
3820 qPos.add(classPK);
3821
3822 return (List<MDRRuleGroupInstance>)QueryUtil.list(q, getDialect(),
3823 start, end);
3824 }
3825 catch (Exception e) {
3826 throw processException(e);
3827 }
3828 finally {
3829 closeSession(session);
3830 }
3831 }
3832
3833
3845 public MDRRuleGroupInstance[] filterFindByG_C_C_PrevAndNext(
3846 long ruleGroupInstanceId, long groupId, long classNameId, long classPK,
3847 OrderByComparator orderByComparator)
3848 throws NoSuchRuleGroupInstanceException, SystemException {
3849 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3850 return findByG_C_C_PrevAndNext(ruleGroupInstanceId, groupId,
3851 classNameId, classPK, orderByComparator);
3852 }
3853
3854 MDRRuleGroupInstance mdrRuleGroupInstance = findByPrimaryKey(ruleGroupInstanceId);
3855
3856 Session session = null;
3857
3858 try {
3859 session = openSession();
3860
3861 MDRRuleGroupInstance[] array = new MDRRuleGroupInstanceImpl[3];
3862
3863 array[0] = filterGetByG_C_C_PrevAndNext(session,
3864 mdrRuleGroupInstance, groupId, classNameId, classPK,
3865 orderByComparator, true);
3866
3867 array[1] = mdrRuleGroupInstance;
3868
3869 array[2] = filterGetByG_C_C_PrevAndNext(session,
3870 mdrRuleGroupInstance, groupId, classNameId, classPK,
3871 orderByComparator, false);
3872
3873 return array;
3874 }
3875 catch (Exception e) {
3876 throw processException(e);
3877 }
3878 finally {
3879 closeSession(session);
3880 }
3881 }
3882
3883 protected MDRRuleGroupInstance filterGetByG_C_C_PrevAndNext(
3884 Session session, MDRRuleGroupInstance mdrRuleGroupInstance,
3885 long groupId, long classNameId, long classPK,
3886 OrderByComparator orderByComparator, boolean previous) {
3887 StringBundler query = null;
3888
3889 if (orderByComparator != null) {
3890 query = new StringBundler(6 +
3891 (orderByComparator.getOrderByFields().length * 6));
3892 }
3893 else {
3894 query = new StringBundler(3);
3895 }
3896
3897 if (getDB().isSupportsInlineDistinct()) {
3898 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
3899 }
3900 else {
3901 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1);
3902 }
3903
3904 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
3905
3906 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
3907
3908 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
3909
3910 if (!getDB().isSupportsInlineDistinct()) {
3911 query.append(_FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2);
3912 }
3913
3914 if (orderByComparator != null) {
3915 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3916
3917 if (orderByConditionFields.length > 0) {
3918 query.append(WHERE_AND);
3919 }
3920
3921 for (int i = 0; i < orderByConditionFields.length; i++) {
3922 if (getDB().isSupportsInlineDistinct()) {
3923 query.append(_ORDER_BY_ENTITY_ALIAS);
3924 }
3925 else {
3926 query.append(_ORDER_BY_ENTITY_TABLE);
3927 }
3928
3929 query.append(orderByConditionFields[i]);
3930
3931 if ((i + 1) < orderByConditionFields.length) {
3932 if (orderByComparator.isAscending() ^ previous) {
3933 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3934 }
3935 else {
3936 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3937 }
3938 }
3939 else {
3940 if (orderByComparator.isAscending() ^ previous) {
3941 query.append(WHERE_GREATER_THAN);
3942 }
3943 else {
3944 query.append(WHERE_LESSER_THAN);
3945 }
3946 }
3947 }
3948
3949 query.append(ORDER_BY_CLAUSE);
3950
3951 String[] orderByFields = orderByComparator.getOrderByFields();
3952
3953 for (int i = 0; i < orderByFields.length; i++) {
3954 if (getDB().isSupportsInlineDistinct()) {
3955 query.append(_ORDER_BY_ENTITY_ALIAS);
3956 }
3957 else {
3958 query.append(_ORDER_BY_ENTITY_TABLE);
3959 }
3960
3961 query.append(orderByFields[i]);
3962
3963 if ((i + 1) < orderByFields.length) {
3964 if (orderByComparator.isAscending() ^ previous) {
3965 query.append(ORDER_BY_ASC_HAS_NEXT);
3966 }
3967 else {
3968 query.append(ORDER_BY_DESC_HAS_NEXT);
3969 }
3970 }
3971 else {
3972 if (orderByComparator.isAscending() ^ previous) {
3973 query.append(ORDER_BY_ASC);
3974 }
3975 else {
3976 query.append(ORDER_BY_DESC);
3977 }
3978 }
3979 }
3980 }
3981
3982 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3983 MDRRuleGroupInstance.class.getName(),
3984 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3985
3986 SQLQuery q = session.createSQLQuery(sql);
3987
3988 q.setFirstResult(0);
3989 q.setMaxResults(2);
3990
3991 if (getDB().isSupportsInlineDistinct()) {
3992 q.addEntity(_FILTER_ENTITY_ALIAS, MDRRuleGroupInstanceImpl.class);
3993 }
3994 else {
3995 q.addEntity(_FILTER_ENTITY_TABLE, MDRRuleGroupInstanceImpl.class);
3996 }
3997
3998 QueryPos qPos = QueryPos.getInstance(q);
3999
4000 qPos.add(groupId);
4001
4002 qPos.add(classNameId);
4003
4004 qPos.add(classPK);
4005
4006 if (orderByComparator != null) {
4007 Object[] values = orderByComparator.getOrderByConditionValues(mdrRuleGroupInstance);
4008
4009 for (Object value : values) {
4010 qPos.add(value);
4011 }
4012 }
4013
4014 List<MDRRuleGroupInstance> list = q.list();
4015
4016 if (list.size() == 2) {
4017 return list.get(1);
4018 }
4019 else {
4020 return null;
4021 }
4022 }
4023
4024
4034 public MDRRuleGroupInstance findByC_C_R(long classNameId, long classPK,
4035 long ruleGroupId)
4036 throws NoSuchRuleGroupInstanceException, SystemException {
4037 MDRRuleGroupInstance mdrRuleGroupInstance = fetchByC_C_R(classNameId,
4038 classPK, ruleGroupId);
4039
4040 if (mdrRuleGroupInstance == null) {
4041 StringBundler msg = new StringBundler(8);
4042
4043 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4044
4045 msg.append("classNameId=");
4046 msg.append(classNameId);
4047
4048 msg.append(", classPK=");
4049 msg.append(classPK);
4050
4051 msg.append(", ruleGroupId=");
4052 msg.append(ruleGroupId);
4053
4054 msg.append(StringPool.CLOSE_CURLY_BRACE);
4055
4056 if (_log.isWarnEnabled()) {
4057 _log.warn(msg.toString());
4058 }
4059
4060 throw new NoSuchRuleGroupInstanceException(msg.toString());
4061 }
4062
4063 return mdrRuleGroupInstance;
4064 }
4065
4066
4075 public MDRRuleGroupInstance fetchByC_C_R(long classNameId, long classPK,
4076 long ruleGroupId) throws SystemException {
4077 return fetchByC_C_R(classNameId, classPK, ruleGroupId, true);
4078 }
4079
4080
4090 public MDRRuleGroupInstance fetchByC_C_R(long classNameId, long classPK,
4091 long ruleGroupId, boolean retrieveFromCache) throws SystemException {
4092 Object[] finderArgs = new Object[] { classNameId, classPK, ruleGroupId };
4093
4094 Object result = null;
4095
4096 if (retrieveFromCache) {
4097 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_R,
4098 finderArgs, this);
4099 }
4100
4101 if (result instanceof MDRRuleGroupInstance) {
4102 MDRRuleGroupInstance mdrRuleGroupInstance = (MDRRuleGroupInstance)result;
4103
4104 if ((classNameId != mdrRuleGroupInstance.getClassNameId()) ||
4105 (classPK != mdrRuleGroupInstance.getClassPK()) ||
4106 (ruleGroupId != mdrRuleGroupInstance.getRuleGroupId())) {
4107 result = null;
4108 }
4109 }
4110
4111 if (result == null) {
4112 StringBundler query = new StringBundler(4);
4113
4114 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE);
4115
4116 query.append(_FINDER_COLUMN_C_C_R_CLASSNAMEID_2);
4117
4118 query.append(_FINDER_COLUMN_C_C_R_CLASSPK_2);
4119
4120 query.append(_FINDER_COLUMN_C_C_R_RULEGROUPID_2);
4121
4122 String sql = query.toString();
4123
4124 Session session = null;
4125
4126 try {
4127 session = openSession();
4128
4129 Query q = session.createQuery(sql);
4130
4131 QueryPos qPos = QueryPos.getInstance(q);
4132
4133 qPos.add(classNameId);
4134
4135 qPos.add(classPK);
4136
4137 qPos.add(ruleGroupId);
4138
4139 List<MDRRuleGroupInstance> list = q.list();
4140
4141 result = list;
4142
4143 MDRRuleGroupInstance mdrRuleGroupInstance = null;
4144
4145 if (list.isEmpty()) {
4146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
4147 finderArgs, list);
4148 }
4149 else {
4150 mdrRuleGroupInstance = list.get(0);
4151
4152 cacheResult(mdrRuleGroupInstance);
4153
4154 if ((mdrRuleGroupInstance.getClassNameId() != classNameId) ||
4155 (mdrRuleGroupInstance.getClassPK() != classPK) ||
4156 (mdrRuleGroupInstance.getRuleGroupId() != ruleGroupId)) {
4157 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_R,
4158 finderArgs, mdrRuleGroupInstance);
4159 }
4160 }
4161
4162 return mdrRuleGroupInstance;
4163 }
4164 catch (Exception e) {
4165 throw processException(e);
4166 }
4167 finally {
4168 if (result == null) {
4169 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_R,
4170 finderArgs);
4171 }
4172
4173 closeSession(session);
4174 }
4175 }
4176 else {
4177 if (result instanceof List<?>) {
4178 return null;
4179 }
4180 else {
4181 return (MDRRuleGroupInstance)result;
4182 }
4183 }
4184 }
4185
4186
4192 public List<MDRRuleGroupInstance> findAll() throws SystemException {
4193 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4194 }
4195
4196
4208 public List<MDRRuleGroupInstance> findAll(int start, int end)
4209 throws SystemException {
4210 return findAll(start, end, null);
4211 }
4212
4213
4226 public List<MDRRuleGroupInstance> findAll(int start, int end,
4227 OrderByComparator orderByComparator) throws SystemException {
4228 FinderPath finderPath = null;
4229 Object[] finderArgs = new Object[] { start, end, orderByComparator };
4230
4231 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4232 (orderByComparator == null)) {
4233 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4234 finderArgs = FINDER_ARGS_EMPTY;
4235 }
4236 else {
4237 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4238 finderArgs = new Object[] { start, end, orderByComparator };
4239 }
4240
4241 List<MDRRuleGroupInstance> list = (List<MDRRuleGroupInstance>)FinderCacheUtil.getResult(finderPath,
4242 finderArgs, this);
4243
4244 if (list == null) {
4245 StringBundler query = null;
4246 String sql = null;
4247
4248 if (orderByComparator != null) {
4249 query = new StringBundler(2 +
4250 (orderByComparator.getOrderByFields().length * 3));
4251
4252 query.append(_SQL_SELECT_MDRRULEGROUPINSTANCE);
4253
4254 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4255 orderByComparator);
4256
4257 sql = query.toString();
4258 }
4259 else {
4260 sql = _SQL_SELECT_MDRRULEGROUPINSTANCE;
4261 }
4262
4263 Session session = null;
4264
4265 try {
4266 session = openSession();
4267
4268 Query q = session.createQuery(sql);
4269
4270 if (orderByComparator == null) {
4271 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
4272 getDialect(), start, end, false);
4273
4274 Collections.sort(list);
4275 }
4276 else {
4277 list = (List<MDRRuleGroupInstance>)QueryUtil.list(q,
4278 getDialect(), start, end);
4279 }
4280 }
4281 catch (Exception e) {
4282 throw processException(e);
4283 }
4284 finally {
4285 if (list == null) {
4286 FinderCacheUtil.removeResult(finderPath, finderArgs);
4287 }
4288 else {
4289 cacheResult(list);
4290
4291 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4292 }
4293
4294 closeSession(session);
4295 }
4296 }
4297
4298 return list;
4299 }
4300
4301
4307 public void removeByUuid(String uuid) throws SystemException {
4308 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByUuid(uuid)) {
4309 remove(mdrRuleGroupInstance);
4310 }
4311 }
4312
4313
4321 public MDRRuleGroupInstance removeByUUID_G(String uuid, long groupId)
4322 throws NoSuchRuleGroupInstanceException, SystemException {
4323 MDRRuleGroupInstance mdrRuleGroupInstance = findByUUID_G(uuid, groupId);
4324
4325 return remove(mdrRuleGroupInstance);
4326 }
4327
4328
4335 public void removeByUuid_C(String uuid, long companyId)
4336 throws SystemException {
4337 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByUuid_C(uuid,
4338 companyId)) {
4339 remove(mdrRuleGroupInstance);
4340 }
4341 }
4342
4343
4349 public void removeByGroupId(long groupId) throws SystemException {
4350 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByGroupId(groupId)) {
4351 remove(mdrRuleGroupInstance);
4352 }
4353 }
4354
4355
4361 public void removeByRuleGroupId(long ruleGroupId) throws SystemException {
4362 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByRuleGroupId(
4363 ruleGroupId)) {
4364 remove(mdrRuleGroupInstance);
4365 }
4366 }
4367
4368
4375 public void removeByC_C(long classNameId, long classPK)
4376 throws SystemException {
4377 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByC_C(
4378 classNameId, classPK)) {
4379 remove(mdrRuleGroupInstance);
4380 }
4381 }
4382
4383
4391 public void removeByG_C_C(long groupId, long classNameId, long classPK)
4392 throws SystemException {
4393 for (MDRRuleGroupInstance mdrRuleGroupInstance : findByG_C_C(groupId,
4394 classNameId, classPK)) {
4395 remove(mdrRuleGroupInstance);
4396 }
4397 }
4398
4399
4408 public MDRRuleGroupInstance removeByC_C_R(long classNameId, long classPK,
4409 long ruleGroupId)
4410 throws NoSuchRuleGroupInstanceException, SystemException {
4411 MDRRuleGroupInstance mdrRuleGroupInstance = findByC_C_R(classNameId,
4412 classPK, ruleGroupId);
4413
4414 return remove(mdrRuleGroupInstance);
4415 }
4416
4417
4422 public void removeAll() throws SystemException {
4423 for (MDRRuleGroupInstance mdrRuleGroupInstance : findAll()) {
4424 remove(mdrRuleGroupInstance);
4425 }
4426 }
4427
4428
4435 public int countByUuid(String uuid) throws SystemException {
4436 Object[] finderArgs = new Object[] { uuid };
4437
4438 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4439 finderArgs, this);
4440
4441 if (count == null) {
4442 StringBundler query = new StringBundler(2);
4443
4444 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4445
4446 if (uuid == null) {
4447 query.append(_FINDER_COLUMN_UUID_UUID_1);
4448 }
4449 else {
4450 if (uuid.equals(StringPool.BLANK)) {
4451 query.append(_FINDER_COLUMN_UUID_UUID_3);
4452 }
4453 else {
4454 query.append(_FINDER_COLUMN_UUID_UUID_2);
4455 }
4456 }
4457
4458 String sql = query.toString();
4459
4460 Session session = null;
4461
4462 try {
4463 session = openSession();
4464
4465 Query q = session.createQuery(sql);
4466
4467 QueryPos qPos = QueryPos.getInstance(q);
4468
4469 if (uuid != null) {
4470 qPos.add(uuid);
4471 }
4472
4473 count = (Long)q.uniqueResult();
4474 }
4475 catch (Exception e) {
4476 throw processException(e);
4477 }
4478 finally {
4479 if (count == null) {
4480 count = Long.valueOf(0);
4481 }
4482
4483 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4484 finderArgs, count);
4485
4486 closeSession(session);
4487 }
4488 }
4489
4490 return count.intValue();
4491 }
4492
4493
4501 public int countByUUID_G(String uuid, long groupId)
4502 throws SystemException {
4503 Object[] finderArgs = new Object[] { uuid, groupId };
4504
4505 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4506 finderArgs, this);
4507
4508 if (count == null) {
4509 StringBundler query = new StringBundler(3);
4510
4511 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4512
4513 if (uuid == null) {
4514 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4515 }
4516 else {
4517 if (uuid.equals(StringPool.BLANK)) {
4518 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4519 }
4520 else {
4521 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4522 }
4523 }
4524
4525 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4526
4527 String sql = query.toString();
4528
4529 Session session = null;
4530
4531 try {
4532 session = openSession();
4533
4534 Query q = session.createQuery(sql);
4535
4536 QueryPos qPos = QueryPos.getInstance(q);
4537
4538 if (uuid != null) {
4539 qPos.add(uuid);
4540 }
4541
4542 qPos.add(groupId);
4543
4544 count = (Long)q.uniqueResult();
4545 }
4546 catch (Exception e) {
4547 throw processException(e);
4548 }
4549 finally {
4550 if (count == null) {
4551 count = Long.valueOf(0);
4552 }
4553
4554 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4555 finderArgs, count);
4556
4557 closeSession(session);
4558 }
4559 }
4560
4561 return count.intValue();
4562 }
4563
4564
4572 public int countByUuid_C(String uuid, long companyId)
4573 throws SystemException {
4574 Object[] finderArgs = new Object[] { uuid, companyId };
4575
4576 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
4577 finderArgs, this);
4578
4579 if (count == null) {
4580 StringBundler query = new StringBundler(3);
4581
4582 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4583
4584 if (uuid == null) {
4585 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
4586 }
4587 else {
4588 if (uuid.equals(StringPool.BLANK)) {
4589 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
4590 }
4591 else {
4592 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
4593 }
4594 }
4595
4596 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
4597
4598 String sql = query.toString();
4599
4600 Session session = null;
4601
4602 try {
4603 session = openSession();
4604
4605 Query q = session.createQuery(sql);
4606
4607 QueryPos qPos = QueryPos.getInstance(q);
4608
4609 if (uuid != null) {
4610 qPos.add(uuid);
4611 }
4612
4613 qPos.add(companyId);
4614
4615 count = (Long)q.uniqueResult();
4616 }
4617 catch (Exception e) {
4618 throw processException(e);
4619 }
4620 finally {
4621 if (count == null) {
4622 count = Long.valueOf(0);
4623 }
4624
4625 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
4626 finderArgs, count);
4627
4628 closeSession(session);
4629 }
4630 }
4631
4632 return count.intValue();
4633 }
4634
4635
4642 public int countByGroupId(long groupId) throws SystemException {
4643 Object[] finderArgs = new Object[] { groupId };
4644
4645 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4646 finderArgs, this);
4647
4648 if (count == null) {
4649 StringBundler query = new StringBundler(2);
4650
4651 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4652
4653 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4654
4655 String sql = query.toString();
4656
4657 Session session = null;
4658
4659 try {
4660 session = openSession();
4661
4662 Query q = session.createQuery(sql);
4663
4664 QueryPos qPos = QueryPos.getInstance(q);
4665
4666 qPos.add(groupId);
4667
4668 count = (Long)q.uniqueResult();
4669 }
4670 catch (Exception e) {
4671 throw processException(e);
4672 }
4673 finally {
4674 if (count == null) {
4675 count = Long.valueOf(0);
4676 }
4677
4678 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4679 finderArgs, count);
4680
4681 closeSession(session);
4682 }
4683 }
4684
4685 return count.intValue();
4686 }
4687
4688
4695 public int filterCountByGroupId(long groupId) throws SystemException {
4696 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4697 return countByGroupId(groupId);
4698 }
4699
4700 StringBundler query = new StringBundler(2);
4701
4702 query.append(_FILTER_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4703
4704 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4705
4706 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4707 MDRRuleGroupInstance.class.getName(),
4708 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4709
4710 Session session = null;
4711
4712 try {
4713 session = openSession();
4714
4715 SQLQuery q = session.createSQLQuery(sql);
4716
4717 q.addScalar(COUNT_COLUMN_NAME,
4718 com.liferay.portal.kernel.dao.orm.Type.LONG);
4719
4720 QueryPos qPos = QueryPos.getInstance(q);
4721
4722 qPos.add(groupId);
4723
4724 Long count = (Long)q.uniqueResult();
4725
4726 return count.intValue();
4727 }
4728 catch (Exception e) {
4729 throw processException(e);
4730 }
4731 finally {
4732 closeSession(session);
4733 }
4734 }
4735
4736
4743 public int countByRuleGroupId(long ruleGroupId) throws SystemException {
4744 Object[] finderArgs = new Object[] { ruleGroupId };
4745
4746 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
4747 finderArgs, this);
4748
4749 if (count == null) {
4750 StringBundler query = new StringBundler(2);
4751
4752 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4753
4754 query.append(_FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2);
4755
4756 String sql = query.toString();
4757
4758 Session session = null;
4759
4760 try {
4761 session = openSession();
4762
4763 Query q = session.createQuery(sql);
4764
4765 QueryPos qPos = QueryPos.getInstance(q);
4766
4767 qPos.add(ruleGroupId);
4768
4769 count = (Long)q.uniqueResult();
4770 }
4771 catch (Exception e) {
4772 throw processException(e);
4773 }
4774 finally {
4775 if (count == null) {
4776 count = Long.valueOf(0);
4777 }
4778
4779 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RULEGROUPID,
4780 finderArgs, count);
4781
4782 closeSession(session);
4783 }
4784 }
4785
4786 return count.intValue();
4787 }
4788
4789
4797 public int countByC_C(long classNameId, long classPK)
4798 throws SystemException {
4799 Object[] finderArgs = new Object[] { classNameId, classPK };
4800
4801 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
4802 finderArgs, this);
4803
4804 if (count == null) {
4805 StringBundler query = new StringBundler(3);
4806
4807 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4808
4809 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
4810
4811 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
4812
4813 String sql = query.toString();
4814
4815 Session session = null;
4816
4817 try {
4818 session = openSession();
4819
4820 Query q = session.createQuery(sql);
4821
4822 QueryPos qPos = QueryPos.getInstance(q);
4823
4824 qPos.add(classNameId);
4825
4826 qPos.add(classPK);
4827
4828 count = (Long)q.uniqueResult();
4829 }
4830 catch (Exception e) {
4831 throw processException(e);
4832 }
4833 finally {
4834 if (count == null) {
4835 count = Long.valueOf(0);
4836 }
4837
4838 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
4839 count);
4840
4841 closeSession(session);
4842 }
4843 }
4844
4845 return count.intValue();
4846 }
4847
4848
4857 public int countByG_C_C(long groupId, long classNameId, long classPK)
4858 throws SystemException {
4859 Object[] finderArgs = new Object[] { groupId, classNameId, classPK };
4860
4861 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C,
4862 finderArgs, this);
4863
4864 if (count == null) {
4865 StringBundler query = new StringBundler(4);
4866
4867 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4868
4869 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
4870
4871 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
4872
4873 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
4874
4875 String sql = query.toString();
4876
4877 Session session = null;
4878
4879 try {
4880 session = openSession();
4881
4882 Query q = session.createQuery(sql);
4883
4884 QueryPos qPos = QueryPos.getInstance(q);
4885
4886 qPos.add(groupId);
4887
4888 qPos.add(classNameId);
4889
4890 qPos.add(classPK);
4891
4892 count = (Long)q.uniqueResult();
4893 }
4894 catch (Exception e) {
4895 throw processException(e);
4896 }
4897 finally {
4898 if (count == null) {
4899 count = Long.valueOf(0);
4900 }
4901
4902 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C,
4903 finderArgs, count);
4904
4905 closeSession(session);
4906 }
4907 }
4908
4909 return count.intValue();
4910 }
4911
4912
4921 public int filterCountByG_C_C(long groupId, long classNameId, long classPK)
4922 throws SystemException {
4923 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4924 return countByG_C_C(groupId, classNameId, classPK);
4925 }
4926
4927 StringBundler query = new StringBundler(4);
4928
4929 query.append(_FILTER_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4930
4931 query.append(_FINDER_COLUMN_G_C_C_GROUPID_2);
4932
4933 query.append(_FINDER_COLUMN_G_C_C_CLASSNAMEID_2);
4934
4935 query.append(_FINDER_COLUMN_G_C_C_CLASSPK_2);
4936
4937 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4938 MDRRuleGroupInstance.class.getName(),
4939 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4940
4941 Session session = null;
4942
4943 try {
4944 session = openSession();
4945
4946 SQLQuery q = session.createSQLQuery(sql);
4947
4948 q.addScalar(COUNT_COLUMN_NAME,
4949 com.liferay.portal.kernel.dao.orm.Type.LONG);
4950
4951 QueryPos qPos = QueryPos.getInstance(q);
4952
4953 qPos.add(groupId);
4954
4955 qPos.add(classNameId);
4956
4957 qPos.add(classPK);
4958
4959 Long count = (Long)q.uniqueResult();
4960
4961 return count.intValue();
4962 }
4963 catch (Exception e) {
4964 throw processException(e);
4965 }
4966 finally {
4967 closeSession(session);
4968 }
4969 }
4970
4971
4980 public int countByC_C_R(long classNameId, long classPK, long ruleGroupId)
4981 throws SystemException {
4982 Object[] finderArgs = new Object[] { classNameId, classPK, ruleGroupId };
4983
4984 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_R,
4985 finderArgs, this);
4986
4987 if (count == null) {
4988 StringBundler query = new StringBundler(4);
4989
4990 query.append(_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE);
4991
4992 query.append(_FINDER_COLUMN_C_C_R_CLASSNAMEID_2);
4993
4994 query.append(_FINDER_COLUMN_C_C_R_CLASSPK_2);
4995
4996 query.append(_FINDER_COLUMN_C_C_R_RULEGROUPID_2);
4997
4998 String sql = query.toString();
4999
5000 Session session = null;
5001
5002 try {
5003 session = openSession();
5004
5005 Query q = session.createQuery(sql);
5006
5007 QueryPos qPos = QueryPos.getInstance(q);
5008
5009 qPos.add(classNameId);
5010
5011 qPos.add(classPK);
5012
5013 qPos.add(ruleGroupId);
5014
5015 count = (Long)q.uniqueResult();
5016 }
5017 catch (Exception e) {
5018 throw processException(e);
5019 }
5020 finally {
5021 if (count == null) {
5022 count = Long.valueOf(0);
5023 }
5024
5025 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_R,
5026 finderArgs, count);
5027
5028 closeSession(session);
5029 }
5030 }
5031
5032 return count.intValue();
5033 }
5034
5035
5041 public int countAll() throws SystemException {
5042 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5043 FINDER_ARGS_EMPTY, this);
5044
5045 if (count == null) {
5046 Session session = null;
5047
5048 try {
5049 session = openSession();
5050
5051 Query q = session.createQuery(_SQL_COUNT_MDRRULEGROUPINSTANCE);
5052
5053 count = (Long)q.uniqueResult();
5054 }
5055 catch (Exception e) {
5056 throw processException(e);
5057 }
5058 finally {
5059 if (count == null) {
5060 count = Long.valueOf(0);
5061 }
5062
5063 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5064 FINDER_ARGS_EMPTY, count);
5065
5066 closeSession(session);
5067 }
5068 }
5069
5070 return count.intValue();
5071 }
5072
5073
5076 public void afterPropertiesSet() {
5077 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5078 com.liferay.portal.util.PropsUtil.get(
5079 "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance")));
5080
5081 if (listenerClassNames.length > 0) {
5082 try {
5083 List<ModelListener<MDRRuleGroupInstance>> listenersList = new ArrayList<ModelListener<MDRRuleGroupInstance>>();
5084
5085 for (String listenerClassName : listenerClassNames) {
5086 listenersList.add((ModelListener<MDRRuleGroupInstance>)InstanceFactory.newInstance(
5087 listenerClassName));
5088 }
5089
5090 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5091 }
5092 catch (Exception e) {
5093 _log.error(e);
5094 }
5095 }
5096 }
5097
5098 public void destroy() {
5099 EntityCacheUtil.removeCache(MDRRuleGroupInstanceImpl.class.getName());
5100 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5101 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5102 }
5103
5104 @BeanReference(type = MDRActionPersistence.class)
5105 protected MDRActionPersistence mdrActionPersistence;
5106 @BeanReference(type = MDRRulePersistence.class)
5107 protected MDRRulePersistence mdrRulePersistence;
5108 @BeanReference(type = MDRRuleGroupPersistence.class)
5109 protected MDRRuleGroupPersistence mdrRuleGroupPersistence;
5110 @BeanReference(type = MDRRuleGroupInstancePersistence.class)
5111 protected MDRRuleGroupInstancePersistence mdrRuleGroupInstancePersistence;
5112 @BeanReference(type = LayoutPersistence.class)
5113 protected LayoutPersistence layoutPersistence;
5114 @BeanReference(type = LayoutSetPersistence.class)
5115 protected LayoutSetPersistence layoutSetPersistence;
5116 @BeanReference(type = UserPersistence.class)
5117 protected UserPersistence userPersistence;
5118 private static final String _SQL_SELECT_MDRRULEGROUPINSTANCE = "SELECT mdrRuleGroupInstance FROM MDRRuleGroupInstance mdrRuleGroupInstance";
5119 private static final String _SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE = "SELECT mdrRuleGroupInstance FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
5120 private static final String _SQL_COUNT_MDRRULEGROUPINSTANCE = "SELECT COUNT(mdrRuleGroupInstance) FROM MDRRuleGroupInstance mdrRuleGroupInstance";
5121 private static final String _SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE = "SELECT COUNT(mdrRuleGroupInstance) FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
5122 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrRuleGroupInstance.uuid IS NULL";
5123 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrRuleGroupInstance.uuid = ?";
5124 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrRuleGroupInstance.uuid IS NULL OR mdrRuleGroupInstance.uuid = ?)";
5125 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrRuleGroupInstance.uuid IS NULL AND ";
5126 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrRuleGroupInstance.uuid = ? AND ";
5127 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrRuleGroupInstance.uuid IS NULL OR mdrRuleGroupInstance.uuid = ?) AND ";
5128 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrRuleGroupInstance.groupId = ?";
5129 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mdrRuleGroupInstance.uuid IS NULL AND ";
5130 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mdrRuleGroupInstance.uuid = ? AND ";
5131 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mdrRuleGroupInstance.uuid IS NULL OR mdrRuleGroupInstance.uuid = ?) AND ";
5132 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mdrRuleGroupInstance.companyId = ?";
5133 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "mdrRuleGroupInstance.groupId = ?";
5134 private static final String _FINDER_COLUMN_RULEGROUPID_RULEGROUPID_2 = "mdrRuleGroupInstance.ruleGroupId = ?";
5135 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
5136 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ?";
5137 private static final String _FINDER_COLUMN_G_C_C_GROUPID_2 = "mdrRuleGroupInstance.groupId = ? AND ";
5138 private static final String _FINDER_COLUMN_G_C_C_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
5139 private static final String _FINDER_COLUMN_G_C_C_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ?";
5140 private static final String _FINDER_COLUMN_C_C_R_CLASSNAMEID_2 = "mdrRuleGroupInstance.classNameId = ? AND ";
5141 private static final String _FINDER_COLUMN_C_C_R_CLASSPK_2 = "mdrRuleGroupInstance.classPK = ? AND ";
5142 private static final String _FINDER_COLUMN_C_C_R_RULEGROUPID_2 = "mdrRuleGroupInstance.ruleGroupId = ?";
5143 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "mdrRuleGroupInstance.ruleGroupInstanceId";
5144 private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_WHERE = "SELECT DISTINCT {mdrRuleGroupInstance.*} FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
5145 private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_1 =
5146 "SELECT {MDRRuleGroupInstance.*} FROM (SELECT DISTINCT mdrRuleGroupInstance.ruleGroupInstanceId FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
5147 private static final String _FILTER_SQL_SELECT_MDRRULEGROUPINSTANCE_NO_INLINE_DISTINCT_WHERE_2 =
5148 ") TEMP_TABLE INNER JOIN MDRRuleGroupInstance ON TEMP_TABLE.ruleGroupInstanceId = MDRRuleGroupInstance.ruleGroupInstanceId";
5149 private static final String _FILTER_SQL_COUNT_MDRRULEGROUPINSTANCE_WHERE = "SELECT COUNT(DISTINCT mdrRuleGroupInstance.ruleGroupInstanceId) AS COUNT_VALUE FROM MDRRuleGroupInstance mdrRuleGroupInstance WHERE ";
5150 private static final String _FILTER_ENTITY_ALIAS = "mdrRuleGroupInstance";
5151 private static final String _FILTER_ENTITY_TABLE = "MDRRuleGroupInstance";
5152 private static final String _ORDER_BY_ENTITY_ALIAS = "mdrRuleGroupInstance.";
5153 private static final String _ORDER_BY_ENTITY_TABLE = "MDRRuleGroupInstance.";
5154 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRRuleGroupInstance exists with the primary key ";
5155 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRRuleGroupInstance exists with the key {";
5156 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5157 private static Log _log = LogFactoryUtil.getLog(MDRRuleGroupInstancePersistenceImpl.class);
5158 private static MDRRuleGroupInstance _nullMDRRuleGroupInstance = new MDRRuleGroupInstanceImpl() {
5159 @Override
5160 public Object clone() {
5161 return this;
5162 }
5163
5164 @Override
5165 public CacheModel<MDRRuleGroupInstance> toCacheModel() {
5166 return _nullMDRRuleGroupInstanceCacheModel;
5167 }
5168 };
5169
5170 private static CacheModel<MDRRuleGroupInstance> _nullMDRRuleGroupInstanceCacheModel =
5171 new CacheModel<MDRRuleGroupInstance>() {
5172 public MDRRuleGroupInstance toEntityModel() {
5173 return _nullMDRRuleGroupInstance;
5174 }
5175 };
5176 }