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.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.service.persistence.BatchSessionUtil;
041 import com.liferay.portal.service.persistence.ResourcePersistence;
042 import com.liferay.portal.service.persistence.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.mobiledevicerules.NoSuchActionException;
046 import com.liferay.portlet.mobiledevicerules.model.MDRAction;
047 import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionImpl;
048 import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionModelImpl;
049
050 import java.io.Serializable;
051
052 import java.util.ArrayList;
053 import java.util.Collections;
054 import java.util.List;
055
056
068 public class MDRActionPersistenceImpl extends BasePersistenceImpl<MDRAction>
069 implements MDRActionPersistence {
070
075 public static final String FINDER_CLASS_NAME_ENTITY = MDRActionImpl.class.getName();
076 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List1";
078 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List2";
080 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
081 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
082 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
083 new String[] {
084 String.class.getName(),
085
086 "java.lang.Integer", "java.lang.Integer",
087 "com.liferay.portal.kernel.util.OrderByComparator"
088 });
089 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
090 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
092 new String[] { String.class.getName() },
093 MDRActionModelImpl.UUID_COLUMN_BITMASK);
094 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
095 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
097 new String[] { String.class.getName() });
098 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
099 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
100 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
101 new String[] { String.class.getName(), Long.class.getName() },
102 MDRActionModelImpl.UUID_COLUMN_BITMASK |
103 MDRActionModelImpl.GROUPID_COLUMN_BITMASK);
104 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
105 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
107 new String[] { String.class.getName(), Long.class.getName() });
108 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
109 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
110 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
111 FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
112 "findByRuleGroupInstanceId",
113 new String[] {
114 Long.class.getName(),
115
116 "java.lang.Integer", "java.lang.Integer",
117 "com.liferay.portal.kernel.util.OrderByComparator"
118 });
119 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
120 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
121 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
122 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
123 "findByRuleGroupInstanceId", new String[] { Long.class.getName() },
124 MDRActionModelImpl.RULEGROUPINSTANCEID_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
126 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
128 "countByRuleGroupInstanceId", new String[] { Long.class.getName() });
129 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
130 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
131 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
132 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
133 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
134 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
135 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
136 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
138
139
144 public void cacheResult(MDRAction mdrAction) {
145 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
146 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
147
148 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
149 new Object[] {
150 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
151 }, mdrAction);
152
153 mdrAction.resetOriginalValues();
154 }
155
156
161 public void cacheResult(List<MDRAction> mdrActions) {
162 for (MDRAction mdrAction : mdrActions) {
163 if (EntityCacheUtil.getResult(
164 MDRActionModelImpl.ENTITY_CACHE_ENABLED,
165 MDRActionImpl.class, mdrAction.getPrimaryKey()) == null) {
166 cacheResult(mdrAction);
167 }
168 else {
169 mdrAction.resetOriginalValues();
170 }
171 }
172 }
173
174
181 @Override
182 public void clearCache() {
183 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
184 CacheRegistryUtil.clear(MDRActionImpl.class.getName());
185 }
186
187 EntityCacheUtil.clearCache(MDRActionImpl.class.getName());
188
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
191 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
192 }
193
194
201 @Override
202 public void clearCache(MDRAction mdrAction) {
203 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
204 MDRActionImpl.class, mdrAction.getPrimaryKey());
205
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
207 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
208
209 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
210 new Object[] {
211 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
212 });
213 }
214
215
221 public MDRAction create(long actionId) {
222 MDRAction mdrAction = new MDRActionImpl();
223
224 mdrAction.setNew(true);
225 mdrAction.setPrimaryKey(actionId);
226
227 String uuid = PortalUUIDUtil.generate();
228
229 mdrAction.setUuid(uuid);
230
231 return mdrAction;
232 }
233
234
242 @Override
243 public MDRAction remove(Serializable primaryKey)
244 throws NoSuchModelException, SystemException {
245 return remove(((Long)primaryKey).longValue());
246 }
247
248
256 public MDRAction remove(long actionId)
257 throws NoSuchActionException, SystemException {
258 Session session = null;
259
260 try {
261 session = openSession();
262
263 MDRAction mdrAction = (MDRAction)session.get(MDRActionImpl.class,
264 Long.valueOf(actionId));
265
266 if (mdrAction == null) {
267 if (_log.isWarnEnabled()) {
268 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + actionId);
269 }
270
271 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
272 actionId);
273 }
274
275 return mdrActionPersistence.remove(mdrAction);
276 }
277 catch (NoSuchActionException nsee) {
278 throw nsee;
279 }
280 catch (Exception e) {
281 throw processException(e);
282 }
283 finally {
284 closeSession(session);
285 }
286 }
287
288
295 @Override
296 public MDRAction remove(MDRAction mdrAction) throws SystemException {
297 return super.remove(mdrAction);
298 }
299
300 @Override
301 protected MDRAction removeImpl(MDRAction mdrAction)
302 throws SystemException {
303 mdrAction = toUnwrappedModel(mdrAction);
304
305 Session session = null;
306
307 try {
308 session = openSession();
309
310 BatchSessionUtil.delete(session, mdrAction);
311 }
312 catch (Exception e) {
313 throw processException(e);
314 }
315 finally {
316 closeSession(session);
317 }
318
319 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
320 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
321
322 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
323
324 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
325 new Object[] {
326 mdrActionModelImpl.getUuid(),
327 Long.valueOf(mdrActionModelImpl.getGroupId())
328 });
329
330 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
331 MDRActionImpl.class, mdrAction.getPrimaryKey());
332
333 return mdrAction;
334 }
335
336 @Override
337 public MDRAction updateImpl(
338 com.liferay.portlet.mobiledevicerules.model.MDRAction mdrAction,
339 boolean merge) throws SystemException {
340 mdrAction = toUnwrappedModel(mdrAction);
341
342 boolean isNew = mdrAction.isNew();
343
344 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
345
346 if (Validator.isNull(mdrAction.getUuid())) {
347 String uuid = PortalUUIDUtil.generate();
348
349 mdrAction.setUuid(uuid);
350 }
351
352 Session session = null;
353
354 try {
355 session = openSession();
356
357 BatchSessionUtil.update(session, mdrAction, merge);
358
359 mdrAction.setNew(false);
360 }
361 catch (Exception e) {
362 throw processException(e);
363 }
364 finally {
365 closeSession(session);
366 }
367
368 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
369
370 if (isNew || !MDRActionModelImpl.COLUMN_BITMASK_ENABLED) {
371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
372 }
373
374 else {
375 if ((mdrActionModelImpl.getColumnBitmask() &
376 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
377 Object[] args = new Object[] {
378 mdrActionModelImpl.getOriginalUuid()
379 };
380
381 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
382 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
383 args);
384
385 args = new Object[] { mdrActionModelImpl.getUuid() };
386
387 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
388 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
389 args);
390 }
391
392 if ((mdrActionModelImpl.getColumnBitmask() &
393 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID.getColumnBitmask()) != 0) {
394 Object[] args = new Object[] {
395 Long.valueOf(mdrActionModelImpl.getOriginalRuleGroupInstanceId())
396 };
397
398 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
399 args);
400 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
401 args);
402
403 args = new Object[] {
404 Long.valueOf(mdrActionModelImpl.getRuleGroupInstanceId())
405 };
406
407 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
408 args);
409 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
410 args);
411 }
412 }
413
414 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
415 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
416
417 if (isNew) {
418 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
419 new Object[] {
420 mdrAction.getUuid(), Long.valueOf(mdrAction.getGroupId())
421 }, mdrAction);
422 }
423 else {
424 if ((mdrActionModelImpl.getColumnBitmask() &
425 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
426 Object[] args = new Object[] {
427 mdrActionModelImpl.getOriginalUuid(),
428 Long.valueOf(mdrActionModelImpl.getOriginalGroupId())
429 };
430
431 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
432 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
433
434 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
435 new Object[] {
436 mdrAction.getUuid(),
437 Long.valueOf(mdrAction.getGroupId())
438 }, mdrAction);
439 }
440 }
441
442 return mdrAction;
443 }
444
445 protected MDRAction toUnwrappedModel(MDRAction mdrAction) {
446 if (mdrAction instanceof MDRActionImpl) {
447 return mdrAction;
448 }
449
450 MDRActionImpl mdrActionImpl = new MDRActionImpl();
451
452 mdrActionImpl.setNew(mdrAction.isNew());
453 mdrActionImpl.setPrimaryKey(mdrAction.getPrimaryKey());
454
455 mdrActionImpl.setUuid(mdrAction.getUuid());
456 mdrActionImpl.setActionId(mdrAction.getActionId());
457 mdrActionImpl.setGroupId(mdrAction.getGroupId());
458 mdrActionImpl.setCompanyId(mdrAction.getCompanyId());
459 mdrActionImpl.setUserId(mdrAction.getUserId());
460 mdrActionImpl.setUserName(mdrAction.getUserName());
461 mdrActionImpl.setCreateDate(mdrAction.getCreateDate());
462 mdrActionImpl.setModifiedDate(mdrAction.getModifiedDate());
463 mdrActionImpl.setClassNameId(mdrAction.getClassNameId());
464 mdrActionImpl.setClassPK(mdrAction.getClassPK());
465 mdrActionImpl.setRuleGroupInstanceId(mdrAction.getRuleGroupInstanceId());
466 mdrActionImpl.setName(mdrAction.getName());
467 mdrActionImpl.setDescription(mdrAction.getDescription());
468 mdrActionImpl.setType(mdrAction.getType());
469 mdrActionImpl.setTypeSettings(mdrAction.getTypeSettings());
470
471 return mdrActionImpl;
472 }
473
474
482 @Override
483 public MDRAction findByPrimaryKey(Serializable primaryKey)
484 throws NoSuchModelException, SystemException {
485 return findByPrimaryKey(((Long)primaryKey).longValue());
486 }
487
488
496 public MDRAction findByPrimaryKey(long actionId)
497 throws NoSuchActionException, SystemException {
498 MDRAction mdrAction = fetchByPrimaryKey(actionId);
499
500 if (mdrAction == null) {
501 if (_log.isWarnEnabled()) {
502 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + actionId);
503 }
504
505 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
506 actionId);
507 }
508
509 return mdrAction;
510 }
511
512
519 @Override
520 public MDRAction fetchByPrimaryKey(Serializable primaryKey)
521 throws SystemException {
522 return fetchByPrimaryKey(((Long)primaryKey).longValue());
523 }
524
525
532 public MDRAction fetchByPrimaryKey(long actionId) throws SystemException {
533 MDRAction mdrAction = (MDRAction)EntityCacheUtil.getResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
534 MDRActionImpl.class, actionId);
535
536 if (mdrAction == _nullMDRAction) {
537 return null;
538 }
539
540 if (mdrAction == null) {
541 Session session = null;
542
543 boolean hasException = false;
544
545 try {
546 session = openSession();
547
548 mdrAction = (MDRAction)session.get(MDRActionImpl.class,
549 Long.valueOf(actionId));
550 }
551 catch (Exception e) {
552 hasException = true;
553
554 throw processException(e);
555 }
556 finally {
557 if (mdrAction != null) {
558 cacheResult(mdrAction);
559 }
560 else if (!hasException) {
561 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
562 MDRActionImpl.class, actionId, _nullMDRAction);
563 }
564
565 closeSession(session);
566 }
567 }
568
569 return mdrAction;
570 }
571
572
579 public List<MDRAction> findByUuid(String uuid) throws SystemException {
580 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
581 }
582
583
596 public List<MDRAction> findByUuid(String uuid, int start, int end)
597 throws SystemException {
598 return findByUuid(uuid, start, end, null);
599 }
600
601
615 public List<MDRAction> findByUuid(String uuid, int start, int end,
616 OrderByComparator orderByComparator) throws SystemException {
617 FinderPath finderPath = null;
618 Object[] finderArgs = null;
619
620 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
621 (orderByComparator == null)) {
622 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
623 finderArgs = new Object[] { uuid };
624 }
625 else {
626 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
627 finderArgs = new Object[] { uuid, start, end, orderByComparator };
628 }
629
630 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
631 finderArgs, this);
632
633 if (list == null) {
634 StringBundler query = null;
635
636 if (orderByComparator != null) {
637 query = new StringBundler(3 +
638 (orderByComparator.getOrderByFields().length * 3));
639 }
640 else {
641 query = new StringBundler(2);
642 }
643
644 query.append(_SQL_SELECT_MDRACTION_WHERE);
645
646 if (uuid == null) {
647 query.append(_FINDER_COLUMN_UUID_UUID_1);
648 }
649 else {
650 if (uuid.equals(StringPool.BLANK)) {
651 query.append(_FINDER_COLUMN_UUID_UUID_3);
652 }
653 else {
654 query.append(_FINDER_COLUMN_UUID_UUID_2);
655 }
656 }
657
658 if (orderByComparator != null) {
659 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
660 orderByComparator);
661 }
662
663 String sql = query.toString();
664
665 Session session = null;
666
667 try {
668 session = openSession();
669
670 Query q = session.createQuery(sql);
671
672 QueryPos qPos = QueryPos.getInstance(q);
673
674 if (uuid != null) {
675 qPos.add(uuid);
676 }
677
678 list = (List<MDRAction>)QueryUtil.list(q, getDialect(), start,
679 end);
680 }
681 catch (Exception e) {
682 throw processException(e);
683 }
684 finally {
685 if (list == null) {
686 FinderCacheUtil.removeResult(finderPath, finderArgs);
687 }
688 else {
689 cacheResult(list);
690
691 FinderCacheUtil.putResult(finderPath, finderArgs, list);
692 }
693
694 closeSession(session);
695 }
696 }
697
698 return list;
699 }
700
701
714 public MDRAction findByUuid_First(String uuid,
715 OrderByComparator orderByComparator)
716 throws NoSuchActionException, SystemException {
717 List<MDRAction> list = findByUuid(uuid, 0, 1, orderByComparator);
718
719 if (list.isEmpty()) {
720 StringBundler msg = new StringBundler(4);
721
722 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
723
724 msg.append("uuid=");
725 msg.append(uuid);
726
727 msg.append(StringPool.CLOSE_CURLY_BRACE);
728
729 throw new NoSuchActionException(msg.toString());
730 }
731 else {
732 return list.get(0);
733 }
734 }
735
736
749 public MDRAction findByUuid_Last(String uuid,
750 OrderByComparator orderByComparator)
751 throws NoSuchActionException, SystemException {
752 int count = countByUuid(uuid);
753
754 List<MDRAction> list = findByUuid(uuid, count - 1, count,
755 orderByComparator);
756
757 if (list.isEmpty()) {
758 StringBundler msg = new StringBundler(4);
759
760 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
761
762 msg.append("uuid=");
763 msg.append(uuid);
764
765 msg.append(StringPool.CLOSE_CURLY_BRACE);
766
767 throw new NoSuchActionException(msg.toString());
768 }
769 else {
770 return list.get(0);
771 }
772 }
773
774
788 public MDRAction[] findByUuid_PrevAndNext(long actionId, String uuid,
789 OrderByComparator orderByComparator)
790 throws NoSuchActionException, SystemException {
791 MDRAction mdrAction = findByPrimaryKey(actionId);
792
793 Session session = null;
794
795 try {
796 session = openSession();
797
798 MDRAction[] array = new MDRActionImpl[3];
799
800 array[0] = getByUuid_PrevAndNext(session, mdrAction, uuid,
801 orderByComparator, true);
802
803 array[1] = mdrAction;
804
805 array[2] = getByUuid_PrevAndNext(session, mdrAction, uuid,
806 orderByComparator, false);
807
808 return array;
809 }
810 catch (Exception e) {
811 throw processException(e);
812 }
813 finally {
814 closeSession(session);
815 }
816 }
817
818 protected MDRAction getByUuid_PrevAndNext(Session session,
819 MDRAction mdrAction, String uuid, OrderByComparator orderByComparator,
820 boolean previous) {
821 StringBundler query = null;
822
823 if (orderByComparator != null) {
824 query = new StringBundler(6 +
825 (orderByComparator.getOrderByFields().length * 6));
826 }
827 else {
828 query = new StringBundler(3);
829 }
830
831 query.append(_SQL_SELECT_MDRACTION_WHERE);
832
833 if (uuid == null) {
834 query.append(_FINDER_COLUMN_UUID_UUID_1);
835 }
836 else {
837 if (uuid.equals(StringPool.BLANK)) {
838 query.append(_FINDER_COLUMN_UUID_UUID_3);
839 }
840 else {
841 query.append(_FINDER_COLUMN_UUID_UUID_2);
842 }
843 }
844
845 if (orderByComparator != null) {
846 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
847
848 if (orderByConditionFields.length > 0) {
849 query.append(WHERE_AND);
850 }
851
852 for (int i = 0; i < orderByConditionFields.length; i++) {
853 query.append(_ORDER_BY_ENTITY_ALIAS);
854 query.append(orderByConditionFields[i]);
855
856 if ((i + 1) < orderByConditionFields.length) {
857 if (orderByComparator.isAscending() ^ previous) {
858 query.append(WHERE_GREATER_THAN_HAS_NEXT);
859 }
860 else {
861 query.append(WHERE_LESSER_THAN_HAS_NEXT);
862 }
863 }
864 else {
865 if (orderByComparator.isAscending() ^ previous) {
866 query.append(WHERE_GREATER_THAN);
867 }
868 else {
869 query.append(WHERE_LESSER_THAN);
870 }
871 }
872 }
873
874 query.append(ORDER_BY_CLAUSE);
875
876 String[] orderByFields = orderByComparator.getOrderByFields();
877
878 for (int i = 0; i < orderByFields.length; i++) {
879 query.append(_ORDER_BY_ENTITY_ALIAS);
880 query.append(orderByFields[i]);
881
882 if ((i + 1) < orderByFields.length) {
883 if (orderByComparator.isAscending() ^ previous) {
884 query.append(ORDER_BY_ASC_HAS_NEXT);
885 }
886 else {
887 query.append(ORDER_BY_DESC_HAS_NEXT);
888 }
889 }
890 else {
891 if (orderByComparator.isAscending() ^ previous) {
892 query.append(ORDER_BY_ASC);
893 }
894 else {
895 query.append(ORDER_BY_DESC);
896 }
897 }
898 }
899 }
900
901 String sql = query.toString();
902
903 Query q = session.createQuery(sql);
904
905 q.setFirstResult(0);
906 q.setMaxResults(2);
907
908 QueryPos qPos = QueryPos.getInstance(q);
909
910 if (uuid != null) {
911 qPos.add(uuid);
912 }
913
914 if (orderByComparator != null) {
915 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
916
917 for (Object value : values) {
918 qPos.add(value);
919 }
920 }
921
922 List<MDRAction> list = q.list();
923
924 if (list.size() == 2) {
925 return list.get(1);
926 }
927 else {
928 return null;
929 }
930 }
931
932
941 public MDRAction findByUUID_G(String uuid, long groupId)
942 throws NoSuchActionException, SystemException {
943 MDRAction mdrAction = fetchByUUID_G(uuid, groupId);
944
945 if (mdrAction == null) {
946 StringBundler msg = new StringBundler(6);
947
948 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
949
950 msg.append("uuid=");
951 msg.append(uuid);
952
953 msg.append(", groupId=");
954 msg.append(groupId);
955
956 msg.append(StringPool.CLOSE_CURLY_BRACE);
957
958 if (_log.isWarnEnabled()) {
959 _log.warn(msg.toString());
960 }
961
962 throw new NoSuchActionException(msg.toString());
963 }
964
965 return mdrAction;
966 }
967
968
976 public MDRAction fetchByUUID_G(String uuid, long groupId)
977 throws SystemException {
978 return fetchByUUID_G(uuid, groupId, true);
979 }
980
981
990 public MDRAction fetchByUUID_G(String uuid, long groupId,
991 boolean retrieveFromCache) throws SystemException {
992 Object[] finderArgs = new Object[] { uuid, groupId };
993
994 Object result = null;
995
996 if (retrieveFromCache) {
997 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
998 finderArgs, this);
999 }
1000
1001 if (result == null) {
1002 StringBundler query = new StringBundler(3);
1003
1004 query.append(_SQL_SELECT_MDRACTION_WHERE);
1005
1006 if (uuid == null) {
1007 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1008 }
1009 else {
1010 if (uuid.equals(StringPool.BLANK)) {
1011 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1012 }
1013 else {
1014 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1015 }
1016 }
1017
1018 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1019
1020 String sql = query.toString();
1021
1022 Session session = null;
1023
1024 try {
1025 session = openSession();
1026
1027 Query q = session.createQuery(sql);
1028
1029 QueryPos qPos = QueryPos.getInstance(q);
1030
1031 if (uuid != null) {
1032 qPos.add(uuid);
1033 }
1034
1035 qPos.add(groupId);
1036
1037 List<MDRAction> list = q.list();
1038
1039 result = list;
1040
1041 MDRAction mdrAction = null;
1042
1043 if (list.isEmpty()) {
1044 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1045 finderArgs, list);
1046 }
1047 else {
1048 mdrAction = list.get(0);
1049
1050 cacheResult(mdrAction);
1051
1052 if ((mdrAction.getUuid() == null) ||
1053 !mdrAction.getUuid().equals(uuid) ||
1054 (mdrAction.getGroupId() != groupId)) {
1055 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1056 finderArgs, mdrAction);
1057 }
1058 }
1059
1060 return mdrAction;
1061 }
1062 catch (Exception e) {
1063 throw processException(e);
1064 }
1065 finally {
1066 if (result == null) {
1067 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1068 finderArgs);
1069 }
1070
1071 closeSession(session);
1072 }
1073 }
1074 else {
1075 if (result instanceof List<?>) {
1076 return null;
1077 }
1078 else {
1079 return (MDRAction)result;
1080 }
1081 }
1082 }
1083
1084
1091 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId)
1092 throws SystemException {
1093 return findByRuleGroupInstanceId(ruleGroupInstanceId,
1094 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1095 }
1096
1097
1110 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1111 int start, int end) throws SystemException {
1112 return findByRuleGroupInstanceId(ruleGroupInstanceId, start, end, null);
1113 }
1114
1115
1129 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1130 int start, int end, OrderByComparator orderByComparator)
1131 throws SystemException {
1132 FinderPath finderPath = null;
1133 Object[] finderArgs = null;
1134
1135 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1136 (orderByComparator == null)) {
1137 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1138 finderArgs = new Object[] { ruleGroupInstanceId };
1139 }
1140 else {
1141 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1142 finderArgs = new Object[] {
1143 ruleGroupInstanceId,
1144
1145 start, end, orderByComparator
1146 };
1147 }
1148
1149 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1150 finderArgs, this);
1151
1152 if (list == null) {
1153 StringBundler query = null;
1154
1155 if (orderByComparator != null) {
1156 query = new StringBundler(3 +
1157 (orderByComparator.getOrderByFields().length * 3));
1158 }
1159 else {
1160 query = new StringBundler(2);
1161 }
1162
1163 query.append(_SQL_SELECT_MDRACTION_WHERE);
1164
1165 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1166
1167 if (orderByComparator != null) {
1168 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1169 orderByComparator);
1170 }
1171
1172 String sql = query.toString();
1173
1174 Session session = null;
1175
1176 try {
1177 session = openSession();
1178
1179 Query q = session.createQuery(sql);
1180
1181 QueryPos qPos = QueryPos.getInstance(q);
1182
1183 qPos.add(ruleGroupInstanceId);
1184
1185 list = (List<MDRAction>)QueryUtil.list(q, getDialect(), start,
1186 end);
1187 }
1188 catch (Exception e) {
1189 throw processException(e);
1190 }
1191 finally {
1192 if (list == null) {
1193 FinderCacheUtil.removeResult(finderPath, finderArgs);
1194 }
1195 else {
1196 cacheResult(list);
1197
1198 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1199 }
1200
1201 closeSession(session);
1202 }
1203 }
1204
1205 return list;
1206 }
1207
1208
1221 public MDRAction findByRuleGroupInstanceId_First(long ruleGroupInstanceId,
1222 OrderByComparator orderByComparator)
1223 throws NoSuchActionException, SystemException {
1224 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1225 0, 1, orderByComparator);
1226
1227 if (list.isEmpty()) {
1228 StringBundler msg = new StringBundler(4);
1229
1230 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1231
1232 msg.append("ruleGroupInstanceId=");
1233 msg.append(ruleGroupInstanceId);
1234
1235 msg.append(StringPool.CLOSE_CURLY_BRACE);
1236
1237 throw new NoSuchActionException(msg.toString());
1238 }
1239 else {
1240 return list.get(0);
1241 }
1242 }
1243
1244
1257 public MDRAction findByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1258 OrderByComparator orderByComparator)
1259 throws NoSuchActionException, SystemException {
1260 int count = countByRuleGroupInstanceId(ruleGroupInstanceId);
1261
1262 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1263 count - 1, count, orderByComparator);
1264
1265 if (list.isEmpty()) {
1266 StringBundler msg = new StringBundler(4);
1267
1268 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1269
1270 msg.append("ruleGroupInstanceId=");
1271 msg.append(ruleGroupInstanceId);
1272
1273 msg.append(StringPool.CLOSE_CURLY_BRACE);
1274
1275 throw new NoSuchActionException(msg.toString());
1276 }
1277 else {
1278 return list.get(0);
1279 }
1280 }
1281
1282
1296 public MDRAction[] findByRuleGroupInstanceId_PrevAndNext(long actionId,
1297 long ruleGroupInstanceId, OrderByComparator orderByComparator)
1298 throws NoSuchActionException, SystemException {
1299 MDRAction mdrAction = findByPrimaryKey(actionId);
1300
1301 Session session = null;
1302
1303 try {
1304 session = openSession();
1305
1306 MDRAction[] array = new MDRActionImpl[3];
1307
1308 array[0] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1309 ruleGroupInstanceId, orderByComparator, true);
1310
1311 array[1] = mdrAction;
1312
1313 array[2] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1314 ruleGroupInstanceId, orderByComparator, false);
1315
1316 return array;
1317 }
1318 catch (Exception e) {
1319 throw processException(e);
1320 }
1321 finally {
1322 closeSession(session);
1323 }
1324 }
1325
1326 protected MDRAction getByRuleGroupInstanceId_PrevAndNext(Session session,
1327 MDRAction mdrAction, long ruleGroupInstanceId,
1328 OrderByComparator orderByComparator, boolean previous) {
1329 StringBundler query = null;
1330
1331 if (orderByComparator != null) {
1332 query = new StringBundler(6 +
1333 (orderByComparator.getOrderByFields().length * 6));
1334 }
1335 else {
1336 query = new StringBundler(3);
1337 }
1338
1339 query.append(_SQL_SELECT_MDRACTION_WHERE);
1340
1341 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1342
1343 if (orderByComparator != null) {
1344 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1345
1346 if (orderByConditionFields.length > 0) {
1347 query.append(WHERE_AND);
1348 }
1349
1350 for (int i = 0; i < orderByConditionFields.length; i++) {
1351 query.append(_ORDER_BY_ENTITY_ALIAS);
1352 query.append(orderByConditionFields[i]);
1353
1354 if ((i + 1) < orderByConditionFields.length) {
1355 if (orderByComparator.isAscending() ^ previous) {
1356 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1357 }
1358 else {
1359 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1360 }
1361 }
1362 else {
1363 if (orderByComparator.isAscending() ^ previous) {
1364 query.append(WHERE_GREATER_THAN);
1365 }
1366 else {
1367 query.append(WHERE_LESSER_THAN);
1368 }
1369 }
1370 }
1371
1372 query.append(ORDER_BY_CLAUSE);
1373
1374 String[] orderByFields = orderByComparator.getOrderByFields();
1375
1376 for (int i = 0; i < orderByFields.length; i++) {
1377 query.append(_ORDER_BY_ENTITY_ALIAS);
1378 query.append(orderByFields[i]);
1379
1380 if ((i + 1) < orderByFields.length) {
1381 if (orderByComparator.isAscending() ^ previous) {
1382 query.append(ORDER_BY_ASC_HAS_NEXT);
1383 }
1384 else {
1385 query.append(ORDER_BY_DESC_HAS_NEXT);
1386 }
1387 }
1388 else {
1389 if (orderByComparator.isAscending() ^ previous) {
1390 query.append(ORDER_BY_ASC);
1391 }
1392 else {
1393 query.append(ORDER_BY_DESC);
1394 }
1395 }
1396 }
1397 }
1398
1399 String sql = query.toString();
1400
1401 Query q = session.createQuery(sql);
1402
1403 q.setFirstResult(0);
1404 q.setMaxResults(2);
1405
1406 QueryPos qPos = QueryPos.getInstance(q);
1407
1408 qPos.add(ruleGroupInstanceId);
1409
1410 if (orderByComparator != null) {
1411 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1412
1413 for (Object value : values) {
1414 qPos.add(value);
1415 }
1416 }
1417
1418 List<MDRAction> list = q.list();
1419
1420 if (list.size() == 2) {
1421 return list.get(1);
1422 }
1423 else {
1424 return null;
1425 }
1426 }
1427
1428
1434 public List<MDRAction> findAll() throws SystemException {
1435 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1436 }
1437
1438
1450 public List<MDRAction> findAll(int start, int end)
1451 throws SystemException {
1452 return findAll(start, end, null);
1453 }
1454
1455
1468 public List<MDRAction> findAll(int start, int end,
1469 OrderByComparator orderByComparator) throws SystemException {
1470 FinderPath finderPath = null;
1471 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1472
1473 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1474 (orderByComparator == null)) {
1475 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1476 finderArgs = FINDER_ARGS_EMPTY;
1477 }
1478 else {
1479 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1480 finderArgs = new Object[] { start, end, orderByComparator };
1481 }
1482
1483 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1484 finderArgs, this);
1485
1486 if (list == null) {
1487 StringBundler query = null;
1488 String sql = null;
1489
1490 if (orderByComparator != null) {
1491 query = new StringBundler(2 +
1492 (orderByComparator.getOrderByFields().length * 3));
1493
1494 query.append(_SQL_SELECT_MDRACTION);
1495
1496 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1497 orderByComparator);
1498
1499 sql = query.toString();
1500 }
1501 else {
1502 sql = _SQL_SELECT_MDRACTION;
1503 }
1504
1505 Session session = null;
1506
1507 try {
1508 session = openSession();
1509
1510 Query q = session.createQuery(sql);
1511
1512 if (orderByComparator == null) {
1513 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1514 start, end, false);
1515
1516 Collections.sort(list);
1517 }
1518 else {
1519 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1520 start, end);
1521 }
1522 }
1523 catch (Exception e) {
1524 throw processException(e);
1525 }
1526 finally {
1527 if (list == null) {
1528 FinderCacheUtil.removeResult(finderPath, finderArgs);
1529 }
1530 else {
1531 cacheResult(list);
1532
1533 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1534 }
1535
1536 closeSession(session);
1537 }
1538 }
1539
1540 return list;
1541 }
1542
1543
1549 public void removeByUuid(String uuid) throws SystemException {
1550 for (MDRAction mdrAction : findByUuid(uuid)) {
1551 mdrActionPersistence.remove(mdrAction);
1552 }
1553 }
1554
1555
1562 public void removeByUUID_G(String uuid, long groupId)
1563 throws NoSuchActionException, SystemException {
1564 MDRAction mdrAction = findByUUID_G(uuid, groupId);
1565
1566 mdrActionPersistence.remove(mdrAction);
1567 }
1568
1569
1575 public void removeByRuleGroupInstanceId(long ruleGroupInstanceId)
1576 throws SystemException {
1577 for (MDRAction mdrAction : findByRuleGroupInstanceId(
1578 ruleGroupInstanceId)) {
1579 mdrActionPersistence.remove(mdrAction);
1580 }
1581 }
1582
1583
1588 public void removeAll() throws SystemException {
1589 for (MDRAction mdrAction : findAll()) {
1590 mdrActionPersistence.remove(mdrAction);
1591 }
1592 }
1593
1594
1601 public int countByUuid(String uuid) throws SystemException {
1602 Object[] finderArgs = new Object[] { uuid };
1603
1604 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1605 finderArgs, this);
1606
1607 if (count == null) {
1608 StringBundler query = new StringBundler(2);
1609
1610 query.append(_SQL_COUNT_MDRACTION_WHERE);
1611
1612 if (uuid == null) {
1613 query.append(_FINDER_COLUMN_UUID_UUID_1);
1614 }
1615 else {
1616 if (uuid.equals(StringPool.BLANK)) {
1617 query.append(_FINDER_COLUMN_UUID_UUID_3);
1618 }
1619 else {
1620 query.append(_FINDER_COLUMN_UUID_UUID_2);
1621 }
1622 }
1623
1624 String sql = query.toString();
1625
1626 Session session = null;
1627
1628 try {
1629 session = openSession();
1630
1631 Query q = session.createQuery(sql);
1632
1633 QueryPos qPos = QueryPos.getInstance(q);
1634
1635 if (uuid != null) {
1636 qPos.add(uuid);
1637 }
1638
1639 count = (Long)q.uniqueResult();
1640 }
1641 catch (Exception e) {
1642 throw processException(e);
1643 }
1644 finally {
1645 if (count == null) {
1646 count = Long.valueOf(0);
1647 }
1648
1649 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1650 finderArgs, count);
1651
1652 closeSession(session);
1653 }
1654 }
1655
1656 return count.intValue();
1657 }
1658
1659
1667 public int countByUUID_G(String uuid, long groupId)
1668 throws SystemException {
1669 Object[] finderArgs = new Object[] { uuid, groupId };
1670
1671 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1672 finderArgs, this);
1673
1674 if (count == null) {
1675 StringBundler query = new StringBundler(3);
1676
1677 query.append(_SQL_COUNT_MDRACTION_WHERE);
1678
1679 if (uuid == null) {
1680 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1681 }
1682 else {
1683 if (uuid.equals(StringPool.BLANK)) {
1684 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1685 }
1686 else {
1687 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1688 }
1689 }
1690
1691 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1692
1693 String sql = query.toString();
1694
1695 Session session = null;
1696
1697 try {
1698 session = openSession();
1699
1700 Query q = session.createQuery(sql);
1701
1702 QueryPos qPos = QueryPos.getInstance(q);
1703
1704 if (uuid != null) {
1705 qPos.add(uuid);
1706 }
1707
1708 qPos.add(groupId);
1709
1710 count = (Long)q.uniqueResult();
1711 }
1712 catch (Exception e) {
1713 throw processException(e);
1714 }
1715 finally {
1716 if (count == null) {
1717 count = Long.valueOf(0);
1718 }
1719
1720 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1721 finderArgs, count);
1722
1723 closeSession(session);
1724 }
1725 }
1726
1727 return count.intValue();
1728 }
1729
1730
1737 public int countByRuleGroupInstanceId(long ruleGroupInstanceId)
1738 throws SystemException {
1739 Object[] finderArgs = new Object[] { ruleGroupInstanceId };
1740
1741 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
1742 finderArgs, this);
1743
1744 if (count == null) {
1745 StringBundler query = new StringBundler(2);
1746
1747 query.append(_SQL_COUNT_MDRACTION_WHERE);
1748
1749 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1750
1751 String sql = query.toString();
1752
1753 Session session = null;
1754
1755 try {
1756 session = openSession();
1757
1758 Query q = session.createQuery(sql);
1759
1760 QueryPos qPos = QueryPos.getInstance(q);
1761
1762 qPos.add(ruleGroupInstanceId);
1763
1764 count = (Long)q.uniqueResult();
1765 }
1766 catch (Exception e) {
1767 throw processException(e);
1768 }
1769 finally {
1770 if (count == null) {
1771 count = Long.valueOf(0);
1772 }
1773
1774 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
1775 finderArgs, count);
1776
1777 closeSession(session);
1778 }
1779 }
1780
1781 return count.intValue();
1782 }
1783
1784
1790 public int countAll() throws SystemException {
1791 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1792 FINDER_ARGS_EMPTY, this);
1793
1794 if (count == null) {
1795 Session session = null;
1796
1797 try {
1798 session = openSession();
1799
1800 Query q = session.createQuery(_SQL_COUNT_MDRACTION);
1801
1802 count = (Long)q.uniqueResult();
1803 }
1804 catch (Exception e) {
1805 throw processException(e);
1806 }
1807 finally {
1808 if (count == null) {
1809 count = Long.valueOf(0);
1810 }
1811
1812 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1813 FINDER_ARGS_EMPTY, count);
1814
1815 closeSession(session);
1816 }
1817 }
1818
1819 return count.intValue();
1820 }
1821
1822
1825 public void afterPropertiesSet() {
1826 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1827 com.liferay.portal.util.PropsUtil.get(
1828 "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRAction")));
1829
1830 if (listenerClassNames.length > 0) {
1831 try {
1832 List<ModelListener<MDRAction>> listenersList = new ArrayList<ModelListener<MDRAction>>();
1833
1834 for (String listenerClassName : listenerClassNames) {
1835 listenersList.add((ModelListener<MDRAction>)InstanceFactory.newInstance(
1836 listenerClassName));
1837 }
1838
1839 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1840 }
1841 catch (Exception e) {
1842 _log.error(e);
1843 }
1844 }
1845 }
1846
1847 public void destroy() {
1848 EntityCacheUtil.removeCache(MDRActionImpl.class.getName());
1849 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1850 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1851 }
1852
1853 @BeanReference(type = MDRActionPersistence.class)
1854 protected MDRActionPersistence mdrActionPersistence;
1855 @BeanReference(type = MDRRulePersistence.class)
1856 protected MDRRulePersistence mdrRulePersistence;
1857 @BeanReference(type = MDRRuleGroupPersistence.class)
1858 protected MDRRuleGroupPersistence mdrRuleGroupPersistence;
1859 @BeanReference(type = MDRRuleGroupInstancePersistence.class)
1860 protected MDRRuleGroupInstancePersistence mdrRuleGroupInstancePersistence;
1861 @BeanReference(type = ResourcePersistence.class)
1862 protected ResourcePersistence resourcePersistence;
1863 @BeanReference(type = UserPersistence.class)
1864 protected UserPersistence userPersistence;
1865 private static final String _SQL_SELECT_MDRACTION = "SELECT mdrAction FROM MDRAction mdrAction";
1866 private static final String _SQL_SELECT_MDRACTION_WHERE = "SELECT mdrAction FROM MDRAction mdrAction WHERE ";
1867 private static final String _SQL_COUNT_MDRACTION = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction";
1868 private static final String _SQL_COUNT_MDRACTION_WHERE = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction WHERE ";
1869 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrAction.uuid IS NULL";
1870 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrAction.uuid = ?";
1871 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?)";
1872 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrAction.uuid IS NULL AND ";
1873 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrAction.uuid = ? AND ";
1874 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = ?) AND ";
1875 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrAction.groupId = ?";
1876 private static final String _FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2 =
1877 "mdrAction.ruleGroupInstanceId = ?";
1878 private static final String _ORDER_BY_ENTITY_ALIAS = "mdrAction.";
1879 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRAction exists with the primary key ";
1880 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRAction exists with the key {";
1881 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1882 private static Log _log = LogFactoryUtil.getLog(MDRActionPersistenceImpl.class);
1883 private static MDRAction _nullMDRAction = new MDRActionImpl() {
1884 @Override
1885 public Object clone() {
1886 return this;
1887 }
1888
1889 @Override
1890 public CacheModel<MDRAction> toCacheModel() {
1891 return _nullMDRActionCacheModel;
1892 }
1893 };
1894
1895 private static CacheModel<MDRAction> _nullMDRActionCacheModel = new CacheModel<MDRAction>() {
1896 public MDRAction toEntityModel() {
1897 return _nullMDRAction;
1898 }
1899 };
1900 }