001
014
015 package com.liferay.portlet.mobiledevicerules.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.Session;
025 import com.liferay.portal.kernel.exception.SystemException;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.util.GetterUtil;
029 import com.liferay.portal.kernel.util.InstanceFactory;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.SetUtil;
032 import com.liferay.portal.kernel.util.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
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.impl.BasePersistenceImpl;
041
042 import com.liferay.portlet.mobiledevicerules.NoSuchActionException;
043 import com.liferay.portlet.mobiledevicerules.model.MDRAction;
044 import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionImpl;
045 import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionModelImpl;
046
047 import java.io.Serializable;
048
049 import java.util.ArrayList;
050 import java.util.Collections;
051 import java.util.List;
052 import java.util.Set;
053
054
066 public class MDRActionPersistenceImpl extends BasePersistenceImpl<MDRAction>
067 implements MDRActionPersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = MDRActionImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
079 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
080 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
082 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
085 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
088 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
090 new String[] {
091 String.class.getName(),
092
093 Integer.class.getName(), Integer.class.getName(),
094 OrderByComparator.class.getName()
095 });
096 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
097 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
098 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
099 new String[] { String.class.getName() },
100 MDRActionModelImpl.UUID_COLUMN_BITMASK);
101 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
102 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
103 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
104 new String[] { String.class.getName() });
105
106
113 @Override
114 public List<MDRAction> findByUuid(String uuid) throws SystemException {
115 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
116 }
117
118
131 @Override
132 public List<MDRAction> findByUuid(String uuid, int start, int end)
133 throws SystemException {
134 return findByUuid(uuid, start, end, null);
135 }
136
137
151 @Override
152 public List<MDRAction> findByUuid(String uuid, int start, int end,
153 OrderByComparator orderByComparator) throws SystemException {
154 boolean pagination = true;
155 FinderPath finderPath = null;
156 Object[] finderArgs = null;
157
158 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
159 (orderByComparator == null)) {
160 pagination = false;
161 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
162 finderArgs = new Object[] { uuid };
163 }
164 else {
165 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
166 finderArgs = new Object[] { uuid, start, end, orderByComparator };
167 }
168
169 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
170 finderArgs, this);
171
172 if ((list != null) && !list.isEmpty()) {
173 for (MDRAction mdrAction : list) {
174 if (!Validator.equals(uuid, mdrAction.getUuid())) {
175 list = null;
176
177 break;
178 }
179 }
180 }
181
182 if (list == null) {
183 StringBundler query = null;
184
185 if (orderByComparator != null) {
186 query = new StringBundler(3 +
187 (orderByComparator.getOrderByFields().length * 3));
188 }
189 else {
190 query = new StringBundler(3);
191 }
192
193 query.append(_SQL_SELECT_MDRACTION_WHERE);
194
195 boolean bindUuid = false;
196
197 if (uuid == null) {
198 query.append(_FINDER_COLUMN_UUID_UUID_1);
199 }
200 else if (uuid.equals(StringPool.BLANK)) {
201 query.append(_FINDER_COLUMN_UUID_UUID_3);
202 }
203 else {
204 bindUuid = true;
205
206 query.append(_FINDER_COLUMN_UUID_UUID_2);
207 }
208
209 if (orderByComparator != null) {
210 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
211 orderByComparator);
212 }
213 else
214 if (pagination) {
215 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
216 }
217
218 String sql = query.toString();
219
220 Session session = null;
221
222 try {
223 session = openSession();
224
225 Query q = session.createQuery(sql);
226
227 QueryPos qPos = QueryPos.getInstance(q);
228
229 if (bindUuid) {
230 qPos.add(uuid);
231 }
232
233 if (!pagination) {
234 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
235 start, end, false);
236
237 Collections.sort(list);
238
239 list = new UnmodifiableList<MDRAction>(list);
240 }
241 else {
242 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
243 start, end);
244 }
245
246 cacheResult(list);
247
248 FinderCacheUtil.putResult(finderPath, finderArgs, list);
249 }
250 catch (Exception e) {
251 FinderCacheUtil.removeResult(finderPath, finderArgs);
252
253 throw processException(e);
254 }
255 finally {
256 closeSession(session);
257 }
258 }
259
260 return list;
261 }
262
263
272 @Override
273 public MDRAction findByUuid_First(String uuid,
274 OrderByComparator orderByComparator)
275 throws NoSuchActionException, SystemException {
276 MDRAction mdrAction = fetchByUuid_First(uuid, orderByComparator);
277
278 if (mdrAction != null) {
279 return mdrAction;
280 }
281
282 StringBundler msg = new StringBundler(4);
283
284 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
285
286 msg.append("uuid=");
287 msg.append(uuid);
288
289 msg.append(StringPool.CLOSE_CURLY_BRACE);
290
291 throw new NoSuchActionException(msg.toString());
292 }
293
294
302 @Override
303 public MDRAction fetchByUuid_First(String uuid,
304 OrderByComparator orderByComparator) throws SystemException {
305 List<MDRAction> list = findByUuid(uuid, 0, 1, orderByComparator);
306
307 if (!list.isEmpty()) {
308 return list.get(0);
309 }
310
311 return null;
312 }
313
314
323 @Override
324 public MDRAction findByUuid_Last(String uuid,
325 OrderByComparator orderByComparator)
326 throws NoSuchActionException, SystemException {
327 MDRAction mdrAction = fetchByUuid_Last(uuid, orderByComparator);
328
329 if (mdrAction != null) {
330 return mdrAction;
331 }
332
333 StringBundler msg = new StringBundler(4);
334
335 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
336
337 msg.append("uuid=");
338 msg.append(uuid);
339
340 msg.append(StringPool.CLOSE_CURLY_BRACE);
341
342 throw new NoSuchActionException(msg.toString());
343 }
344
345
353 @Override
354 public MDRAction fetchByUuid_Last(String uuid,
355 OrderByComparator orderByComparator) throws SystemException {
356 int count = countByUuid(uuid);
357
358 if (count == 0) {
359 return null;
360 }
361
362 List<MDRAction> list = findByUuid(uuid, count - 1, count,
363 orderByComparator);
364
365 if (!list.isEmpty()) {
366 return list.get(0);
367 }
368
369 return null;
370 }
371
372
382 @Override
383 public MDRAction[] findByUuid_PrevAndNext(long actionId, String uuid,
384 OrderByComparator orderByComparator)
385 throws NoSuchActionException, SystemException {
386 MDRAction mdrAction = findByPrimaryKey(actionId);
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 MDRAction[] array = new MDRActionImpl[3];
394
395 array[0] = getByUuid_PrevAndNext(session, mdrAction, uuid,
396 orderByComparator, true);
397
398 array[1] = mdrAction;
399
400 array[2] = getByUuid_PrevAndNext(session, mdrAction, uuid,
401 orderByComparator, false);
402
403 return array;
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411 }
412
413 protected MDRAction getByUuid_PrevAndNext(Session session,
414 MDRAction mdrAction, String uuid, OrderByComparator orderByComparator,
415 boolean previous) {
416 StringBundler query = null;
417
418 if (orderByComparator != null) {
419 query = new StringBundler(6 +
420 (orderByComparator.getOrderByFields().length * 6));
421 }
422 else {
423 query = new StringBundler(3);
424 }
425
426 query.append(_SQL_SELECT_MDRACTION_WHERE);
427
428 boolean bindUuid = false;
429
430 if (uuid == null) {
431 query.append(_FINDER_COLUMN_UUID_UUID_1);
432 }
433 else if (uuid.equals(StringPool.BLANK)) {
434 query.append(_FINDER_COLUMN_UUID_UUID_3);
435 }
436 else {
437 bindUuid = true;
438
439 query.append(_FINDER_COLUMN_UUID_UUID_2);
440 }
441
442 if (orderByComparator != null) {
443 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
444
445 if (orderByConditionFields.length > 0) {
446 query.append(WHERE_AND);
447 }
448
449 for (int i = 0; i < orderByConditionFields.length; i++) {
450 query.append(_ORDER_BY_ENTITY_ALIAS);
451 query.append(orderByConditionFields[i]);
452
453 if ((i + 1) < orderByConditionFields.length) {
454 if (orderByComparator.isAscending() ^ previous) {
455 query.append(WHERE_GREATER_THAN_HAS_NEXT);
456 }
457 else {
458 query.append(WHERE_LESSER_THAN_HAS_NEXT);
459 }
460 }
461 else {
462 if (orderByComparator.isAscending() ^ previous) {
463 query.append(WHERE_GREATER_THAN);
464 }
465 else {
466 query.append(WHERE_LESSER_THAN);
467 }
468 }
469 }
470
471 query.append(ORDER_BY_CLAUSE);
472
473 String[] orderByFields = orderByComparator.getOrderByFields();
474
475 for (int i = 0; i < orderByFields.length; i++) {
476 query.append(_ORDER_BY_ENTITY_ALIAS);
477 query.append(orderByFields[i]);
478
479 if ((i + 1) < orderByFields.length) {
480 if (orderByComparator.isAscending() ^ previous) {
481 query.append(ORDER_BY_ASC_HAS_NEXT);
482 }
483 else {
484 query.append(ORDER_BY_DESC_HAS_NEXT);
485 }
486 }
487 else {
488 if (orderByComparator.isAscending() ^ previous) {
489 query.append(ORDER_BY_ASC);
490 }
491 else {
492 query.append(ORDER_BY_DESC);
493 }
494 }
495 }
496 }
497 else {
498 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
499 }
500
501 String sql = query.toString();
502
503 Query q = session.createQuery(sql);
504
505 q.setFirstResult(0);
506 q.setMaxResults(2);
507
508 QueryPos qPos = QueryPos.getInstance(q);
509
510 if (bindUuid) {
511 qPos.add(uuid);
512 }
513
514 if (orderByComparator != null) {
515 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
516
517 for (Object value : values) {
518 qPos.add(value);
519 }
520 }
521
522 List<MDRAction> list = q.list();
523
524 if (list.size() == 2) {
525 return list.get(1);
526 }
527 else {
528 return null;
529 }
530 }
531
532
538 @Override
539 public void removeByUuid(String uuid) throws SystemException {
540 for (MDRAction mdrAction : findByUuid(uuid, QueryUtil.ALL_POS,
541 QueryUtil.ALL_POS, null)) {
542 remove(mdrAction);
543 }
544 }
545
546
553 @Override
554 public int countByUuid(String uuid) throws SystemException {
555 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
556
557 Object[] finderArgs = new Object[] { uuid };
558
559 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
560 this);
561
562 if (count == null) {
563 StringBundler query = new StringBundler(2);
564
565 query.append(_SQL_COUNT_MDRACTION_WHERE);
566
567 boolean bindUuid = false;
568
569 if (uuid == null) {
570 query.append(_FINDER_COLUMN_UUID_UUID_1);
571 }
572 else if (uuid.equals(StringPool.BLANK)) {
573 query.append(_FINDER_COLUMN_UUID_UUID_3);
574 }
575 else {
576 bindUuid = true;
577
578 query.append(_FINDER_COLUMN_UUID_UUID_2);
579 }
580
581 String sql = query.toString();
582
583 Session session = null;
584
585 try {
586 session = openSession();
587
588 Query q = session.createQuery(sql);
589
590 QueryPos qPos = QueryPos.getInstance(q);
591
592 if (bindUuid) {
593 qPos.add(uuid);
594 }
595
596 count = (Long)q.uniqueResult();
597
598 FinderCacheUtil.putResult(finderPath, finderArgs, count);
599 }
600 catch (Exception e) {
601 FinderCacheUtil.removeResult(finderPath, finderArgs);
602
603 throw processException(e);
604 }
605 finally {
606 closeSession(session);
607 }
608 }
609
610 return count.intValue();
611 }
612
613 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrAction.uuid IS NULL";
614 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrAction.uuid = ?";
615 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = '')";
616 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
617 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
618 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
619 new String[] { String.class.getName(), Long.class.getName() },
620 MDRActionModelImpl.UUID_COLUMN_BITMASK |
621 MDRActionModelImpl.GROUPID_COLUMN_BITMASK);
622 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
623 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
624 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
625 new String[] { String.class.getName(), Long.class.getName() });
626
627
636 @Override
637 public MDRAction findByUUID_G(String uuid, long groupId)
638 throws NoSuchActionException, SystemException {
639 MDRAction mdrAction = fetchByUUID_G(uuid, groupId);
640
641 if (mdrAction == null) {
642 StringBundler msg = new StringBundler(6);
643
644 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
645
646 msg.append("uuid=");
647 msg.append(uuid);
648
649 msg.append(", groupId=");
650 msg.append(groupId);
651
652 msg.append(StringPool.CLOSE_CURLY_BRACE);
653
654 if (_log.isWarnEnabled()) {
655 _log.warn(msg.toString());
656 }
657
658 throw new NoSuchActionException(msg.toString());
659 }
660
661 return mdrAction;
662 }
663
664
672 @Override
673 public MDRAction fetchByUUID_G(String uuid, long groupId)
674 throws SystemException {
675 return fetchByUUID_G(uuid, groupId, true);
676 }
677
678
687 @Override
688 public MDRAction fetchByUUID_G(String uuid, long groupId,
689 boolean retrieveFromCache) throws SystemException {
690 Object[] finderArgs = new Object[] { uuid, groupId };
691
692 Object result = null;
693
694 if (retrieveFromCache) {
695 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
696 finderArgs, this);
697 }
698
699 if (result instanceof MDRAction) {
700 MDRAction mdrAction = (MDRAction)result;
701
702 if (!Validator.equals(uuid, mdrAction.getUuid()) ||
703 (groupId != mdrAction.getGroupId())) {
704 result = null;
705 }
706 }
707
708 if (result == null) {
709 StringBundler query = new StringBundler(4);
710
711 query.append(_SQL_SELECT_MDRACTION_WHERE);
712
713 boolean bindUuid = false;
714
715 if (uuid == null) {
716 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
717 }
718 else if (uuid.equals(StringPool.BLANK)) {
719 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
720 }
721 else {
722 bindUuid = true;
723
724 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
725 }
726
727 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
728
729 String sql = query.toString();
730
731 Session session = null;
732
733 try {
734 session = openSession();
735
736 Query q = session.createQuery(sql);
737
738 QueryPos qPos = QueryPos.getInstance(q);
739
740 if (bindUuid) {
741 qPos.add(uuid);
742 }
743
744 qPos.add(groupId);
745
746 List<MDRAction> list = q.list();
747
748 if (list.isEmpty()) {
749 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
750 finderArgs, list);
751 }
752 else {
753 MDRAction mdrAction = list.get(0);
754
755 result = mdrAction;
756
757 cacheResult(mdrAction);
758
759 if ((mdrAction.getUuid() == null) ||
760 !mdrAction.getUuid().equals(uuid) ||
761 (mdrAction.getGroupId() != groupId)) {
762 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
763 finderArgs, mdrAction);
764 }
765 }
766 }
767 catch (Exception e) {
768 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
769 finderArgs);
770
771 throw processException(e);
772 }
773 finally {
774 closeSession(session);
775 }
776 }
777
778 if (result instanceof List<?>) {
779 return null;
780 }
781 else {
782 return (MDRAction)result;
783 }
784 }
785
786
794 @Override
795 public MDRAction removeByUUID_G(String uuid, long groupId)
796 throws NoSuchActionException, SystemException {
797 MDRAction mdrAction = findByUUID_G(uuid, groupId);
798
799 return remove(mdrAction);
800 }
801
802
810 @Override
811 public int countByUUID_G(String uuid, long groupId)
812 throws SystemException {
813 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
814
815 Object[] finderArgs = new Object[] { uuid, groupId };
816
817 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
818 this);
819
820 if (count == null) {
821 StringBundler query = new StringBundler(3);
822
823 query.append(_SQL_COUNT_MDRACTION_WHERE);
824
825 boolean bindUuid = false;
826
827 if (uuid == null) {
828 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
829 }
830 else if (uuid.equals(StringPool.BLANK)) {
831 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
832 }
833 else {
834 bindUuid = true;
835
836 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
837 }
838
839 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
840
841 String sql = query.toString();
842
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 Query q = session.createQuery(sql);
849
850 QueryPos qPos = QueryPos.getInstance(q);
851
852 if (bindUuid) {
853 qPos.add(uuid);
854 }
855
856 qPos.add(groupId);
857
858 count = (Long)q.uniqueResult();
859
860 FinderCacheUtil.putResult(finderPath, finderArgs, count);
861 }
862 catch (Exception e) {
863 FinderCacheUtil.removeResult(finderPath, finderArgs);
864
865 throw processException(e);
866 }
867 finally {
868 closeSession(session);
869 }
870 }
871
872 return count.intValue();
873 }
874
875 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrAction.uuid IS NULL AND ";
876 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrAction.uuid = ? AND ";
877 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = '') AND ";
878 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrAction.groupId = ?";
879 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
880 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
881 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
882 new String[] {
883 String.class.getName(), Long.class.getName(),
884
885 Integer.class.getName(), Integer.class.getName(),
886 OrderByComparator.class.getName()
887 });
888 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
889 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
890 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
891 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
892 new String[] { String.class.getName(), Long.class.getName() },
893 MDRActionModelImpl.UUID_COLUMN_BITMASK |
894 MDRActionModelImpl.COMPANYID_COLUMN_BITMASK);
895 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
896 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
897 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
898 new String[] { String.class.getName(), Long.class.getName() });
899
900
908 @Override
909 public List<MDRAction> findByUuid_C(String uuid, long companyId)
910 throws SystemException {
911 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
912 QueryUtil.ALL_POS, null);
913 }
914
915
929 @Override
930 public List<MDRAction> findByUuid_C(String uuid, long companyId, int start,
931 int end) throws SystemException {
932 return findByUuid_C(uuid, companyId, start, end, null);
933 }
934
935
950 @Override
951 public List<MDRAction> findByUuid_C(String uuid, long companyId, int start,
952 int end, OrderByComparator orderByComparator) throws SystemException {
953 boolean pagination = true;
954 FinderPath finderPath = null;
955 Object[] finderArgs = null;
956
957 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
958 (orderByComparator == null)) {
959 pagination = false;
960 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
961 finderArgs = new Object[] { uuid, companyId };
962 }
963 else {
964 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
965 finderArgs = new Object[] {
966 uuid, companyId,
967
968 start, end, orderByComparator
969 };
970 }
971
972 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
973 finderArgs, this);
974
975 if ((list != null) && !list.isEmpty()) {
976 for (MDRAction mdrAction : list) {
977 if (!Validator.equals(uuid, mdrAction.getUuid()) ||
978 (companyId != mdrAction.getCompanyId())) {
979 list = null;
980
981 break;
982 }
983 }
984 }
985
986 if (list == null) {
987 StringBundler query = null;
988
989 if (orderByComparator != null) {
990 query = new StringBundler(4 +
991 (orderByComparator.getOrderByFields().length * 3));
992 }
993 else {
994 query = new StringBundler(4);
995 }
996
997 query.append(_SQL_SELECT_MDRACTION_WHERE);
998
999 boolean bindUuid = false;
1000
1001 if (uuid == null) {
1002 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1003 }
1004 else if (uuid.equals(StringPool.BLANK)) {
1005 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1006 }
1007 else {
1008 bindUuid = true;
1009
1010 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1011 }
1012
1013 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1014
1015 if (orderByComparator != null) {
1016 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1017 orderByComparator);
1018 }
1019 else
1020 if (pagination) {
1021 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1022 }
1023
1024 String sql = query.toString();
1025
1026 Session session = null;
1027
1028 try {
1029 session = openSession();
1030
1031 Query q = session.createQuery(sql);
1032
1033 QueryPos qPos = QueryPos.getInstance(q);
1034
1035 if (bindUuid) {
1036 qPos.add(uuid);
1037 }
1038
1039 qPos.add(companyId);
1040
1041 if (!pagination) {
1042 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1043 start, end, false);
1044
1045 Collections.sort(list);
1046
1047 list = new UnmodifiableList<MDRAction>(list);
1048 }
1049 else {
1050 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1051 start, end);
1052 }
1053
1054 cacheResult(list);
1055
1056 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1057 }
1058 catch (Exception e) {
1059 FinderCacheUtil.removeResult(finderPath, finderArgs);
1060
1061 throw processException(e);
1062 }
1063 finally {
1064 closeSession(session);
1065 }
1066 }
1067
1068 return list;
1069 }
1070
1071
1081 @Override
1082 public MDRAction findByUuid_C_First(String uuid, long companyId,
1083 OrderByComparator orderByComparator)
1084 throws NoSuchActionException, SystemException {
1085 MDRAction mdrAction = fetchByUuid_C_First(uuid, companyId,
1086 orderByComparator);
1087
1088 if (mdrAction != null) {
1089 return mdrAction;
1090 }
1091
1092 StringBundler msg = new StringBundler(6);
1093
1094 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1095
1096 msg.append("uuid=");
1097 msg.append(uuid);
1098
1099 msg.append(", companyId=");
1100 msg.append(companyId);
1101
1102 msg.append(StringPool.CLOSE_CURLY_BRACE);
1103
1104 throw new NoSuchActionException(msg.toString());
1105 }
1106
1107
1116 @Override
1117 public MDRAction fetchByUuid_C_First(String uuid, long companyId,
1118 OrderByComparator orderByComparator) throws SystemException {
1119 List<MDRAction> list = findByUuid_C(uuid, companyId, 0, 1,
1120 orderByComparator);
1121
1122 if (!list.isEmpty()) {
1123 return list.get(0);
1124 }
1125
1126 return null;
1127 }
1128
1129
1139 @Override
1140 public MDRAction findByUuid_C_Last(String uuid, long companyId,
1141 OrderByComparator orderByComparator)
1142 throws NoSuchActionException, SystemException {
1143 MDRAction mdrAction = fetchByUuid_C_Last(uuid, companyId,
1144 orderByComparator);
1145
1146 if (mdrAction != null) {
1147 return mdrAction;
1148 }
1149
1150 StringBundler msg = new StringBundler(6);
1151
1152 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1153
1154 msg.append("uuid=");
1155 msg.append(uuid);
1156
1157 msg.append(", companyId=");
1158 msg.append(companyId);
1159
1160 msg.append(StringPool.CLOSE_CURLY_BRACE);
1161
1162 throw new NoSuchActionException(msg.toString());
1163 }
1164
1165
1174 @Override
1175 public MDRAction fetchByUuid_C_Last(String uuid, long companyId,
1176 OrderByComparator orderByComparator) throws SystemException {
1177 int count = countByUuid_C(uuid, companyId);
1178
1179 if (count == 0) {
1180 return null;
1181 }
1182
1183 List<MDRAction> list = findByUuid_C(uuid, companyId, count - 1, count,
1184 orderByComparator);
1185
1186 if (!list.isEmpty()) {
1187 return list.get(0);
1188 }
1189
1190 return null;
1191 }
1192
1193
1204 @Override
1205 public MDRAction[] findByUuid_C_PrevAndNext(long actionId, String uuid,
1206 long companyId, OrderByComparator orderByComparator)
1207 throws NoSuchActionException, SystemException {
1208 MDRAction mdrAction = findByPrimaryKey(actionId);
1209
1210 Session session = null;
1211
1212 try {
1213 session = openSession();
1214
1215 MDRAction[] array = new MDRActionImpl[3];
1216
1217 array[0] = getByUuid_C_PrevAndNext(session, mdrAction, uuid,
1218 companyId, orderByComparator, true);
1219
1220 array[1] = mdrAction;
1221
1222 array[2] = getByUuid_C_PrevAndNext(session, mdrAction, uuid,
1223 companyId, orderByComparator, false);
1224
1225 return array;
1226 }
1227 catch (Exception e) {
1228 throw processException(e);
1229 }
1230 finally {
1231 closeSession(session);
1232 }
1233 }
1234
1235 protected MDRAction getByUuid_C_PrevAndNext(Session session,
1236 MDRAction mdrAction, String uuid, long companyId,
1237 OrderByComparator orderByComparator, boolean previous) {
1238 StringBundler query = null;
1239
1240 if (orderByComparator != null) {
1241 query = new StringBundler(6 +
1242 (orderByComparator.getOrderByFields().length * 6));
1243 }
1244 else {
1245 query = new StringBundler(3);
1246 }
1247
1248 query.append(_SQL_SELECT_MDRACTION_WHERE);
1249
1250 boolean bindUuid = false;
1251
1252 if (uuid == null) {
1253 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1254 }
1255 else if (uuid.equals(StringPool.BLANK)) {
1256 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1257 }
1258 else {
1259 bindUuid = true;
1260
1261 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1262 }
1263
1264 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1265
1266 if (orderByComparator != null) {
1267 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1268
1269 if (orderByConditionFields.length > 0) {
1270 query.append(WHERE_AND);
1271 }
1272
1273 for (int i = 0; i < orderByConditionFields.length; i++) {
1274 query.append(_ORDER_BY_ENTITY_ALIAS);
1275 query.append(orderByConditionFields[i]);
1276
1277 if ((i + 1) < orderByConditionFields.length) {
1278 if (orderByComparator.isAscending() ^ previous) {
1279 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1280 }
1281 else {
1282 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1283 }
1284 }
1285 else {
1286 if (orderByComparator.isAscending() ^ previous) {
1287 query.append(WHERE_GREATER_THAN);
1288 }
1289 else {
1290 query.append(WHERE_LESSER_THAN);
1291 }
1292 }
1293 }
1294
1295 query.append(ORDER_BY_CLAUSE);
1296
1297 String[] orderByFields = orderByComparator.getOrderByFields();
1298
1299 for (int i = 0; i < orderByFields.length; i++) {
1300 query.append(_ORDER_BY_ENTITY_ALIAS);
1301 query.append(orderByFields[i]);
1302
1303 if ((i + 1) < orderByFields.length) {
1304 if (orderByComparator.isAscending() ^ previous) {
1305 query.append(ORDER_BY_ASC_HAS_NEXT);
1306 }
1307 else {
1308 query.append(ORDER_BY_DESC_HAS_NEXT);
1309 }
1310 }
1311 else {
1312 if (orderByComparator.isAscending() ^ previous) {
1313 query.append(ORDER_BY_ASC);
1314 }
1315 else {
1316 query.append(ORDER_BY_DESC);
1317 }
1318 }
1319 }
1320 }
1321 else {
1322 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1323 }
1324
1325 String sql = query.toString();
1326
1327 Query q = session.createQuery(sql);
1328
1329 q.setFirstResult(0);
1330 q.setMaxResults(2);
1331
1332 QueryPos qPos = QueryPos.getInstance(q);
1333
1334 if (bindUuid) {
1335 qPos.add(uuid);
1336 }
1337
1338 qPos.add(companyId);
1339
1340 if (orderByComparator != null) {
1341 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1342
1343 for (Object value : values) {
1344 qPos.add(value);
1345 }
1346 }
1347
1348 List<MDRAction> list = q.list();
1349
1350 if (list.size() == 2) {
1351 return list.get(1);
1352 }
1353 else {
1354 return null;
1355 }
1356 }
1357
1358
1365 @Override
1366 public void removeByUuid_C(String uuid, long companyId)
1367 throws SystemException {
1368 for (MDRAction mdrAction : findByUuid_C(uuid, companyId,
1369 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1370 remove(mdrAction);
1371 }
1372 }
1373
1374
1382 @Override
1383 public int countByUuid_C(String uuid, long companyId)
1384 throws SystemException {
1385 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1386
1387 Object[] finderArgs = new Object[] { uuid, companyId };
1388
1389 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1390 this);
1391
1392 if (count == null) {
1393 StringBundler query = new StringBundler(3);
1394
1395 query.append(_SQL_COUNT_MDRACTION_WHERE);
1396
1397 boolean bindUuid = false;
1398
1399 if (uuid == null) {
1400 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1401 }
1402 else if (uuid.equals(StringPool.BLANK)) {
1403 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1404 }
1405 else {
1406 bindUuid = true;
1407
1408 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1409 }
1410
1411 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1412
1413 String sql = query.toString();
1414
1415 Session session = null;
1416
1417 try {
1418 session = openSession();
1419
1420 Query q = session.createQuery(sql);
1421
1422 QueryPos qPos = QueryPos.getInstance(q);
1423
1424 if (bindUuid) {
1425 qPos.add(uuid);
1426 }
1427
1428 qPos.add(companyId);
1429
1430 count = (Long)q.uniqueResult();
1431
1432 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1433 }
1434 catch (Exception e) {
1435 FinderCacheUtil.removeResult(finderPath, finderArgs);
1436
1437 throw processException(e);
1438 }
1439 finally {
1440 closeSession(session);
1441 }
1442 }
1443
1444 return count.intValue();
1445 }
1446
1447 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mdrAction.uuid IS NULL AND ";
1448 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mdrAction.uuid = ? AND ";
1449 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = '') AND ";
1450 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mdrAction.companyId = ?";
1451 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
1452 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1453 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
1454 FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1455 "findByRuleGroupInstanceId",
1456 new String[] {
1457 Long.class.getName(),
1458
1459 Integer.class.getName(), Integer.class.getName(),
1460 OrderByComparator.class.getName()
1461 });
1462 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
1463 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1464 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
1465 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1466 "findByRuleGroupInstanceId", new String[] { Long.class.getName() },
1467 MDRActionModelImpl.RULEGROUPINSTANCEID_COLUMN_BITMASK);
1468 public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1469 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1470 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1471 "countByRuleGroupInstanceId", new String[] { Long.class.getName() });
1472
1473
1480 @Override
1481 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId)
1482 throws SystemException {
1483 return findByRuleGroupInstanceId(ruleGroupInstanceId,
1484 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1485 }
1486
1487
1500 @Override
1501 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1502 int start, int end) throws SystemException {
1503 return findByRuleGroupInstanceId(ruleGroupInstanceId, start, end, null);
1504 }
1505
1506
1520 @Override
1521 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1522 int start, int end, OrderByComparator orderByComparator)
1523 throws SystemException {
1524 boolean pagination = true;
1525 FinderPath finderPath = null;
1526 Object[] finderArgs = null;
1527
1528 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1529 (orderByComparator == null)) {
1530 pagination = false;
1531 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1532 finderArgs = new Object[] { ruleGroupInstanceId };
1533 }
1534 else {
1535 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1536 finderArgs = new Object[] {
1537 ruleGroupInstanceId,
1538
1539 start, end, orderByComparator
1540 };
1541 }
1542
1543 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1544 finderArgs, this);
1545
1546 if ((list != null) && !list.isEmpty()) {
1547 for (MDRAction mdrAction : list) {
1548 if ((ruleGroupInstanceId != mdrAction.getRuleGroupInstanceId())) {
1549 list = null;
1550
1551 break;
1552 }
1553 }
1554 }
1555
1556 if (list == null) {
1557 StringBundler query = null;
1558
1559 if (orderByComparator != null) {
1560 query = new StringBundler(3 +
1561 (orderByComparator.getOrderByFields().length * 3));
1562 }
1563 else {
1564 query = new StringBundler(3);
1565 }
1566
1567 query.append(_SQL_SELECT_MDRACTION_WHERE);
1568
1569 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1570
1571 if (orderByComparator != null) {
1572 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1573 orderByComparator);
1574 }
1575 else
1576 if (pagination) {
1577 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1578 }
1579
1580 String sql = query.toString();
1581
1582 Session session = null;
1583
1584 try {
1585 session = openSession();
1586
1587 Query q = session.createQuery(sql);
1588
1589 QueryPos qPos = QueryPos.getInstance(q);
1590
1591 qPos.add(ruleGroupInstanceId);
1592
1593 if (!pagination) {
1594 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1595 start, end, false);
1596
1597 Collections.sort(list);
1598
1599 list = new UnmodifiableList<MDRAction>(list);
1600 }
1601 else {
1602 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1603 start, end);
1604 }
1605
1606 cacheResult(list);
1607
1608 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1609 }
1610 catch (Exception e) {
1611 FinderCacheUtil.removeResult(finderPath, finderArgs);
1612
1613 throw processException(e);
1614 }
1615 finally {
1616 closeSession(session);
1617 }
1618 }
1619
1620 return list;
1621 }
1622
1623
1632 @Override
1633 public MDRAction findByRuleGroupInstanceId_First(long ruleGroupInstanceId,
1634 OrderByComparator orderByComparator)
1635 throws NoSuchActionException, SystemException {
1636 MDRAction mdrAction = fetchByRuleGroupInstanceId_First(ruleGroupInstanceId,
1637 orderByComparator);
1638
1639 if (mdrAction != null) {
1640 return mdrAction;
1641 }
1642
1643 StringBundler msg = new StringBundler(4);
1644
1645 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1646
1647 msg.append("ruleGroupInstanceId=");
1648 msg.append(ruleGroupInstanceId);
1649
1650 msg.append(StringPool.CLOSE_CURLY_BRACE);
1651
1652 throw new NoSuchActionException(msg.toString());
1653 }
1654
1655
1663 @Override
1664 public MDRAction fetchByRuleGroupInstanceId_First(
1665 long ruleGroupInstanceId, OrderByComparator orderByComparator)
1666 throws SystemException {
1667 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1668 0, 1, orderByComparator);
1669
1670 if (!list.isEmpty()) {
1671 return list.get(0);
1672 }
1673
1674 return null;
1675 }
1676
1677
1686 @Override
1687 public MDRAction findByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1688 OrderByComparator orderByComparator)
1689 throws NoSuchActionException, SystemException {
1690 MDRAction mdrAction = fetchByRuleGroupInstanceId_Last(ruleGroupInstanceId,
1691 orderByComparator);
1692
1693 if (mdrAction != null) {
1694 return mdrAction;
1695 }
1696
1697 StringBundler msg = new StringBundler(4);
1698
1699 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1700
1701 msg.append("ruleGroupInstanceId=");
1702 msg.append(ruleGroupInstanceId);
1703
1704 msg.append(StringPool.CLOSE_CURLY_BRACE);
1705
1706 throw new NoSuchActionException(msg.toString());
1707 }
1708
1709
1717 @Override
1718 public MDRAction fetchByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1719 OrderByComparator orderByComparator) throws SystemException {
1720 int count = countByRuleGroupInstanceId(ruleGroupInstanceId);
1721
1722 if (count == 0) {
1723 return null;
1724 }
1725
1726 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1727 count - 1, count, orderByComparator);
1728
1729 if (!list.isEmpty()) {
1730 return list.get(0);
1731 }
1732
1733 return null;
1734 }
1735
1736
1746 @Override
1747 public MDRAction[] findByRuleGroupInstanceId_PrevAndNext(long actionId,
1748 long ruleGroupInstanceId, OrderByComparator orderByComparator)
1749 throws NoSuchActionException, SystemException {
1750 MDRAction mdrAction = findByPrimaryKey(actionId);
1751
1752 Session session = null;
1753
1754 try {
1755 session = openSession();
1756
1757 MDRAction[] array = new MDRActionImpl[3];
1758
1759 array[0] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1760 ruleGroupInstanceId, orderByComparator, true);
1761
1762 array[1] = mdrAction;
1763
1764 array[2] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1765 ruleGroupInstanceId, orderByComparator, false);
1766
1767 return array;
1768 }
1769 catch (Exception e) {
1770 throw processException(e);
1771 }
1772 finally {
1773 closeSession(session);
1774 }
1775 }
1776
1777 protected MDRAction getByRuleGroupInstanceId_PrevAndNext(Session session,
1778 MDRAction mdrAction, long ruleGroupInstanceId,
1779 OrderByComparator orderByComparator, boolean previous) {
1780 StringBundler query = null;
1781
1782 if (orderByComparator != null) {
1783 query = new StringBundler(6 +
1784 (orderByComparator.getOrderByFields().length * 6));
1785 }
1786 else {
1787 query = new StringBundler(3);
1788 }
1789
1790 query.append(_SQL_SELECT_MDRACTION_WHERE);
1791
1792 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1793
1794 if (orderByComparator != null) {
1795 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1796
1797 if (orderByConditionFields.length > 0) {
1798 query.append(WHERE_AND);
1799 }
1800
1801 for (int i = 0; i < orderByConditionFields.length; i++) {
1802 query.append(_ORDER_BY_ENTITY_ALIAS);
1803 query.append(orderByConditionFields[i]);
1804
1805 if ((i + 1) < orderByConditionFields.length) {
1806 if (orderByComparator.isAscending() ^ previous) {
1807 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1808 }
1809 else {
1810 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1811 }
1812 }
1813 else {
1814 if (orderByComparator.isAscending() ^ previous) {
1815 query.append(WHERE_GREATER_THAN);
1816 }
1817 else {
1818 query.append(WHERE_LESSER_THAN);
1819 }
1820 }
1821 }
1822
1823 query.append(ORDER_BY_CLAUSE);
1824
1825 String[] orderByFields = orderByComparator.getOrderByFields();
1826
1827 for (int i = 0; i < orderByFields.length; i++) {
1828 query.append(_ORDER_BY_ENTITY_ALIAS);
1829 query.append(orderByFields[i]);
1830
1831 if ((i + 1) < orderByFields.length) {
1832 if (orderByComparator.isAscending() ^ previous) {
1833 query.append(ORDER_BY_ASC_HAS_NEXT);
1834 }
1835 else {
1836 query.append(ORDER_BY_DESC_HAS_NEXT);
1837 }
1838 }
1839 else {
1840 if (orderByComparator.isAscending() ^ previous) {
1841 query.append(ORDER_BY_ASC);
1842 }
1843 else {
1844 query.append(ORDER_BY_DESC);
1845 }
1846 }
1847 }
1848 }
1849 else {
1850 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1851 }
1852
1853 String sql = query.toString();
1854
1855 Query q = session.createQuery(sql);
1856
1857 q.setFirstResult(0);
1858 q.setMaxResults(2);
1859
1860 QueryPos qPos = QueryPos.getInstance(q);
1861
1862 qPos.add(ruleGroupInstanceId);
1863
1864 if (orderByComparator != null) {
1865 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1866
1867 for (Object value : values) {
1868 qPos.add(value);
1869 }
1870 }
1871
1872 List<MDRAction> list = q.list();
1873
1874 if (list.size() == 2) {
1875 return list.get(1);
1876 }
1877 else {
1878 return null;
1879 }
1880 }
1881
1882
1888 @Override
1889 public void removeByRuleGroupInstanceId(long ruleGroupInstanceId)
1890 throws SystemException {
1891 for (MDRAction mdrAction : findByRuleGroupInstanceId(
1892 ruleGroupInstanceId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1893 remove(mdrAction);
1894 }
1895 }
1896
1897
1904 @Override
1905 public int countByRuleGroupInstanceId(long ruleGroupInstanceId)
1906 throws SystemException {
1907 FinderPath finderPath = FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID;
1908
1909 Object[] finderArgs = new Object[] { ruleGroupInstanceId };
1910
1911 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1912 this);
1913
1914 if (count == null) {
1915 StringBundler query = new StringBundler(2);
1916
1917 query.append(_SQL_COUNT_MDRACTION_WHERE);
1918
1919 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1920
1921 String sql = query.toString();
1922
1923 Session session = null;
1924
1925 try {
1926 session = openSession();
1927
1928 Query q = session.createQuery(sql);
1929
1930 QueryPos qPos = QueryPos.getInstance(q);
1931
1932 qPos.add(ruleGroupInstanceId);
1933
1934 count = (Long)q.uniqueResult();
1935
1936 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1937 }
1938 catch (Exception e) {
1939 FinderCacheUtil.removeResult(finderPath, finderArgs);
1940
1941 throw processException(e);
1942 }
1943 finally {
1944 closeSession(session);
1945 }
1946 }
1947
1948 return count.intValue();
1949 }
1950
1951 private static final String _FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2 =
1952 "mdrAction.ruleGroupInstanceId = ?";
1953
1954
1959 @Override
1960 public void cacheResult(MDRAction mdrAction) {
1961 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1962 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
1963
1964 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1965 new Object[] { mdrAction.getUuid(), mdrAction.getGroupId() },
1966 mdrAction);
1967
1968 mdrAction.resetOriginalValues();
1969 }
1970
1971
1976 @Override
1977 public void cacheResult(List<MDRAction> mdrActions) {
1978 for (MDRAction mdrAction : mdrActions) {
1979 if (EntityCacheUtil.getResult(
1980 MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1981 MDRActionImpl.class, mdrAction.getPrimaryKey()) == null) {
1982 cacheResult(mdrAction);
1983 }
1984 else {
1985 mdrAction.resetOriginalValues();
1986 }
1987 }
1988 }
1989
1990
1997 @Override
1998 public void clearCache() {
1999 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2000 CacheRegistryUtil.clear(MDRActionImpl.class.getName());
2001 }
2002
2003 EntityCacheUtil.clearCache(MDRActionImpl.class.getName());
2004
2005 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2006 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2007 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2008 }
2009
2010
2017 @Override
2018 public void clearCache(MDRAction mdrAction) {
2019 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2020 MDRActionImpl.class, mdrAction.getPrimaryKey());
2021
2022 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2023 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2024
2025 clearUniqueFindersCache(mdrAction);
2026 }
2027
2028 @Override
2029 public void clearCache(List<MDRAction> mdrActions) {
2030 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2031 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2032
2033 for (MDRAction mdrAction : mdrActions) {
2034 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2035 MDRActionImpl.class, mdrAction.getPrimaryKey());
2036
2037 clearUniqueFindersCache(mdrAction);
2038 }
2039 }
2040
2041 protected void cacheUniqueFindersCache(MDRAction mdrAction) {
2042 if (mdrAction.isNew()) {
2043 Object[] args = new Object[] {
2044 mdrAction.getUuid(), mdrAction.getGroupId()
2045 };
2046
2047 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2048 Long.valueOf(1));
2049 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2050 mdrAction);
2051 }
2052 else {
2053 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
2054
2055 if ((mdrActionModelImpl.getColumnBitmask() &
2056 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2057 Object[] args = new Object[] {
2058 mdrAction.getUuid(), mdrAction.getGroupId()
2059 };
2060
2061 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2062 Long.valueOf(1));
2063 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2064 mdrAction);
2065 }
2066 }
2067 }
2068
2069 protected void clearUniqueFindersCache(MDRAction mdrAction) {
2070 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
2071
2072 Object[] args = new Object[] { mdrAction.getUuid(), mdrAction.getGroupId() };
2073
2074 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2075 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2076
2077 if ((mdrActionModelImpl.getColumnBitmask() &
2078 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2079 args = new Object[] {
2080 mdrActionModelImpl.getOriginalUuid(),
2081 mdrActionModelImpl.getOriginalGroupId()
2082 };
2083
2084 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2085 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2086 }
2087 }
2088
2089
2095 @Override
2096 public MDRAction create(long actionId) {
2097 MDRAction mdrAction = new MDRActionImpl();
2098
2099 mdrAction.setNew(true);
2100 mdrAction.setPrimaryKey(actionId);
2101
2102 String uuid = PortalUUIDUtil.generate();
2103
2104 mdrAction.setUuid(uuid);
2105
2106 return mdrAction;
2107 }
2108
2109
2117 @Override
2118 public MDRAction remove(long actionId)
2119 throws NoSuchActionException, SystemException {
2120 return remove((Serializable)actionId);
2121 }
2122
2123
2131 @Override
2132 public MDRAction remove(Serializable primaryKey)
2133 throws NoSuchActionException, SystemException {
2134 Session session = null;
2135
2136 try {
2137 session = openSession();
2138
2139 MDRAction mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2140 primaryKey);
2141
2142 if (mdrAction == null) {
2143 if (_log.isWarnEnabled()) {
2144 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2145 }
2146
2147 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2148 primaryKey);
2149 }
2150
2151 return remove(mdrAction);
2152 }
2153 catch (NoSuchActionException nsee) {
2154 throw nsee;
2155 }
2156 catch (Exception e) {
2157 throw processException(e);
2158 }
2159 finally {
2160 closeSession(session);
2161 }
2162 }
2163
2164 @Override
2165 protected MDRAction removeImpl(MDRAction mdrAction)
2166 throws SystemException {
2167 mdrAction = toUnwrappedModel(mdrAction);
2168
2169 Session session = null;
2170
2171 try {
2172 session = openSession();
2173
2174 if (!session.contains(mdrAction)) {
2175 mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2176 mdrAction.getPrimaryKeyObj());
2177 }
2178
2179 if (mdrAction != null) {
2180 session.delete(mdrAction);
2181 }
2182 }
2183 catch (Exception e) {
2184 throw processException(e);
2185 }
2186 finally {
2187 closeSession(session);
2188 }
2189
2190 if (mdrAction != null) {
2191 clearCache(mdrAction);
2192 }
2193
2194 return mdrAction;
2195 }
2196
2197 @Override
2198 public MDRAction updateImpl(
2199 com.liferay.portlet.mobiledevicerules.model.MDRAction mdrAction)
2200 throws SystemException {
2201 mdrAction = toUnwrappedModel(mdrAction);
2202
2203 boolean isNew = mdrAction.isNew();
2204
2205 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
2206
2207 if (Validator.isNull(mdrAction.getUuid())) {
2208 String uuid = PortalUUIDUtil.generate();
2209
2210 mdrAction.setUuid(uuid);
2211 }
2212
2213 Session session = null;
2214
2215 try {
2216 session = openSession();
2217
2218 if (mdrAction.isNew()) {
2219 session.save(mdrAction);
2220
2221 mdrAction.setNew(false);
2222 }
2223 else {
2224 session.merge(mdrAction);
2225 }
2226 }
2227 catch (Exception e) {
2228 throw processException(e);
2229 }
2230 finally {
2231 closeSession(session);
2232 }
2233
2234 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2235
2236 if (isNew || !MDRActionModelImpl.COLUMN_BITMASK_ENABLED) {
2237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2238 }
2239
2240 else {
2241 if ((mdrActionModelImpl.getColumnBitmask() &
2242 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2243 Object[] args = new Object[] {
2244 mdrActionModelImpl.getOriginalUuid()
2245 };
2246
2247 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2248 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2249 args);
2250
2251 args = new Object[] { mdrActionModelImpl.getUuid() };
2252
2253 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2254 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2255 args);
2256 }
2257
2258 if ((mdrActionModelImpl.getColumnBitmask() &
2259 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2260 Object[] args = new Object[] {
2261 mdrActionModelImpl.getOriginalUuid(),
2262 mdrActionModelImpl.getOriginalCompanyId()
2263 };
2264
2265 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2266 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2267 args);
2268
2269 args = new Object[] {
2270 mdrActionModelImpl.getUuid(),
2271 mdrActionModelImpl.getCompanyId()
2272 };
2273
2274 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2275 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2276 args);
2277 }
2278
2279 if ((mdrActionModelImpl.getColumnBitmask() &
2280 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID.getColumnBitmask()) != 0) {
2281 Object[] args = new Object[] {
2282 mdrActionModelImpl.getOriginalRuleGroupInstanceId()
2283 };
2284
2285 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
2286 args);
2287 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
2288 args);
2289
2290 args = new Object[] { mdrActionModelImpl.getRuleGroupInstanceId() };
2291
2292 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
2293 args);
2294 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
2295 args);
2296 }
2297 }
2298
2299 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2300 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
2301
2302 clearUniqueFindersCache(mdrAction);
2303 cacheUniqueFindersCache(mdrAction);
2304
2305 return mdrAction;
2306 }
2307
2308 protected MDRAction toUnwrappedModel(MDRAction mdrAction) {
2309 if (mdrAction instanceof MDRActionImpl) {
2310 return mdrAction;
2311 }
2312
2313 MDRActionImpl mdrActionImpl = new MDRActionImpl();
2314
2315 mdrActionImpl.setNew(mdrAction.isNew());
2316 mdrActionImpl.setPrimaryKey(mdrAction.getPrimaryKey());
2317
2318 mdrActionImpl.setUuid(mdrAction.getUuid());
2319 mdrActionImpl.setActionId(mdrAction.getActionId());
2320 mdrActionImpl.setGroupId(mdrAction.getGroupId());
2321 mdrActionImpl.setCompanyId(mdrAction.getCompanyId());
2322 mdrActionImpl.setUserId(mdrAction.getUserId());
2323 mdrActionImpl.setUserName(mdrAction.getUserName());
2324 mdrActionImpl.setCreateDate(mdrAction.getCreateDate());
2325 mdrActionImpl.setModifiedDate(mdrAction.getModifiedDate());
2326 mdrActionImpl.setClassNameId(mdrAction.getClassNameId());
2327 mdrActionImpl.setClassPK(mdrAction.getClassPK());
2328 mdrActionImpl.setRuleGroupInstanceId(mdrAction.getRuleGroupInstanceId());
2329 mdrActionImpl.setName(mdrAction.getName());
2330 mdrActionImpl.setDescription(mdrAction.getDescription());
2331 mdrActionImpl.setType(mdrAction.getType());
2332 mdrActionImpl.setTypeSettings(mdrAction.getTypeSettings());
2333
2334 return mdrActionImpl;
2335 }
2336
2337
2345 @Override
2346 public MDRAction findByPrimaryKey(Serializable primaryKey)
2347 throws NoSuchActionException, SystemException {
2348 MDRAction mdrAction = fetchByPrimaryKey(primaryKey);
2349
2350 if (mdrAction == null) {
2351 if (_log.isWarnEnabled()) {
2352 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2353 }
2354
2355 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2356 primaryKey);
2357 }
2358
2359 return mdrAction;
2360 }
2361
2362
2370 @Override
2371 public MDRAction findByPrimaryKey(long actionId)
2372 throws NoSuchActionException, SystemException {
2373 return findByPrimaryKey((Serializable)actionId);
2374 }
2375
2376
2383 @Override
2384 public MDRAction fetchByPrimaryKey(Serializable primaryKey)
2385 throws SystemException {
2386 MDRAction mdrAction = (MDRAction)EntityCacheUtil.getResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2387 MDRActionImpl.class, primaryKey);
2388
2389 if (mdrAction == _nullMDRAction) {
2390 return null;
2391 }
2392
2393 if (mdrAction == null) {
2394 Session session = null;
2395
2396 try {
2397 session = openSession();
2398
2399 mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2400 primaryKey);
2401
2402 if (mdrAction != null) {
2403 cacheResult(mdrAction);
2404 }
2405 else {
2406 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2407 MDRActionImpl.class, primaryKey, _nullMDRAction);
2408 }
2409 }
2410 catch (Exception e) {
2411 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2412 MDRActionImpl.class, primaryKey);
2413
2414 throw processException(e);
2415 }
2416 finally {
2417 closeSession(session);
2418 }
2419 }
2420
2421 return mdrAction;
2422 }
2423
2424
2431 @Override
2432 public MDRAction fetchByPrimaryKey(long actionId) throws SystemException {
2433 return fetchByPrimaryKey((Serializable)actionId);
2434 }
2435
2436
2442 @Override
2443 public List<MDRAction> findAll() throws SystemException {
2444 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2445 }
2446
2447
2459 @Override
2460 public List<MDRAction> findAll(int start, int end)
2461 throws SystemException {
2462 return findAll(start, end, null);
2463 }
2464
2465
2478 @Override
2479 public List<MDRAction> findAll(int start, int end,
2480 OrderByComparator orderByComparator) throws SystemException {
2481 boolean pagination = true;
2482 FinderPath finderPath = null;
2483 Object[] finderArgs = null;
2484
2485 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2486 (orderByComparator == null)) {
2487 pagination = false;
2488 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2489 finderArgs = FINDER_ARGS_EMPTY;
2490 }
2491 else {
2492 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2493 finderArgs = new Object[] { start, end, orderByComparator };
2494 }
2495
2496 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
2497 finderArgs, this);
2498
2499 if (list == null) {
2500 StringBundler query = null;
2501 String sql = null;
2502
2503 if (orderByComparator != null) {
2504 query = new StringBundler(2 +
2505 (orderByComparator.getOrderByFields().length * 3));
2506
2507 query.append(_SQL_SELECT_MDRACTION);
2508
2509 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2510 orderByComparator);
2511
2512 sql = query.toString();
2513 }
2514 else {
2515 sql = _SQL_SELECT_MDRACTION;
2516
2517 if (pagination) {
2518 sql = sql.concat(MDRActionModelImpl.ORDER_BY_JPQL);
2519 }
2520 }
2521
2522 Session session = null;
2523
2524 try {
2525 session = openSession();
2526
2527 Query q = session.createQuery(sql);
2528
2529 if (!pagination) {
2530 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
2531 start, end, false);
2532
2533 Collections.sort(list);
2534
2535 list = new UnmodifiableList<MDRAction>(list);
2536 }
2537 else {
2538 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
2539 start, end);
2540 }
2541
2542 cacheResult(list);
2543
2544 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2545 }
2546 catch (Exception e) {
2547 FinderCacheUtil.removeResult(finderPath, finderArgs);
2548
2549 throw processException(e);
2550 }
2551 finally {
2552 closeSession(session);
2553 }
2554 }
2555
2556 return list;
2557 }
2558
2559
2564 @Override
2565 public void removeAll() throws SystemException {
2566 for (MDRAction mdrAction : findAll()) {
2567 remove(mdrAction);
2568 }
2569 }
2570
2571
2577 @Override
2578 public int countAll() throws SystemException {
2579 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2580 FINDER_ARGS_EMPTY, this);
2581
2582 if (count == null) {
2583 Session session = null;
2584
2585 try {
2586 session = openSession();
2587
2588 Query q = session.createQuery(_SQL_COUNT_MDRACTION);
2589
2590 count = (Long)q.uniqueResult();
2591
2592 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2593 FINDER_ARGS_EMPTY, count);
2594 }
2595 catch (Exception e) {
2596 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2597 FINDER_ARGS_EMPTY);
2598
2599 throw processException(e);
2600 }
2601 finally {
2602 closeSession(session);
2603 }
2604 }
2605
2606 return count.intValue();
2607 }
2608
2609 @Override
2610 protected Set<String> getBadColumnNames() {
2611 return _badColumnNames;
2612 }
2613
2614
2617 public void afterPropertiesSet() {
2618 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2619 com.liferay.portal.util.PropsUtil.get(
2620 "value.object.listener.com.liferay.portlet.mobiledevicerules.model.MDRAction")));
2621
2622 if (listenerClassNames.length > 0) {
2623 try {
2624 List<ModelListener<MDRAction>> listenersList = new ArrayList<ModelListener<MDRAction>>();
2625
2626 for (String listenerClassName : listenerClassNames) {
2627 listenersList.add((ModelListener<MDRAction>)InstanceFactory.newInstance(
2628 getClassLoader(), listenerClassName));
2629 }
2630
2631 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2632 }
2633 catch (Exception e) {
2634 _log.error(e);
2635 }
2636 }
2637 }
2638
2639 public void destroy() {
2640 EntityCacheUtil.removeCache(MDRActionImpl.class.getName());
2641 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2642 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2643 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2644 }
2645
2646 private static final String _SQL_SELECT_MDRACTION = "SELECT mdrAction FROM MDRAction mdrAction";
2647 private static final String _SQL_SELECT_MDRACTION_WHERE = "SELECT mdrAction FROM MDRAction mdrAction WHERE ";
2648 private static final String _SQL_COUNT_MDRACTION = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction";
2649 private static final String _SQL_COUNT_MDRACTION_WHERE = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction WHERE ";
2650 private static final String _ORDER_BY_ENTITY_ALIAS = "mdrAction.";
2651 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRAction exists with the primary key ";
2652 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRAction exists with the key {";
2653 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2654 private static Log _log = LogFactoryUtil.getLog(MDRActionPersistenceImpl.class);
2655 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2656 "uuid", "type"
2657 });
2658 private static MDRAction _nullMDRAction = new MDRActionImpl() {
2659 @Override
2660 public Object clone() {
2661 return this;
2662 }
2663
2664 @Override
2665 public CacheModel<MDRAction> toCacheModel() {
2666 return _nullMDRActionCacheModel;
2667 }
2668 };
2669
2670 private static CacheModel<MDRAction> _nullMDRActionCacheModel = new CacheModel<MDRAction>() {
2671 @Override
2672 public MDRAction toEntityModel() {
2673 return _nullMDRAction;
2674 }
2675 };
2676 }