001
014
015 package com.liferay.portlet.mobiledevicerules.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.util.OrderByComparator;
029 import com.liferay.portal.kernel.util.SetUtil;
030 import com.liferay.portal.kernel.util.StringBundler;
031 import com.liferay.portal.kernel.util.StringPool;
032 import com.liferay.portal.kernel.util.Validator;
033 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
034 import com.liferay.portal.model.CacheModel;
035 import com.liferay.portal.service.ServiceContext;
036 import com.liferay.portal.service.ServiceContextThreadLocal;
037 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
038
039 import com.liferay.portlet.mobiledevicerules.NoSuchActionException;
040 import com.liferay.portlet.mobiledevicerules.model.MDRAction;
041 import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionImpl;
042 import com.liferay.portlet.mobiledevicerules.model.impl.MDRActionModelImpl;
043 import com.liferay.portlet.mobiledevicerules.service.persistence.MDRActionPersistence;
044
045 import java.io.Serializable;
046
047 import java.util.Collections;
048 import java.util.Date;
049 import java.util.HashMap;
050 import java.util.HashSet;
051 import java.util.Iterator;
052 import java.util.List;
053 import java.util.Map;
054 import java.util.Set;
055
056
068 @ProviderType
069 public class MDRActionPersistenceImpl extends BasePersistenceImpl<MDRAction>
070 implements MDRActionPersistence {
071
076 public static final String FINDER_CLASS_NAME_ENTITY = MDRActionImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List1";
079 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List2";
081 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
082 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
083 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
085 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
088 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
091 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
092 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
100 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
102 new String[] { String.class.getName() },
103 MDRActionModelImpl.UUID_COLUMN_BITMASK);
104 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
105 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107 new String[] { String.class.getName() });
108
109
115 @Override
116 public List<MDRAction> findByUuid(String uuid) {
117 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
118 }
119
120
132 @Override
133 public List<MDRAction> findByUuid(String uuid, int start, int end) {
134 return findByUuid(uuid, start, end, null);
135 }
136
137
150 @Override
151 public List<MDRAction> findByUuid(String uuid, int start, int end,
152 OrderByComparator<MDRAction> orderByComparator) {
153 boolean pagination = true;
154 FinderPath finderPath = null;
155 Object[] finderArgs = null;
156
157 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
158 (orderByComparator == null)) {
159 pagination = false;
160 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
161 finderArgs = new Object[] { uuid };
162 }
163 else {
164 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
165 finderArgs = new Object[] { uuid, start, end, orderByComparator };
166 }
167
168 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
169 finderArgs, this);
170
171 if ((list != null) && !list.isEmpty()) {
172 for (MDRAction mdrAction : list) {
173 if (!Validator.equals(uuid, mdrAction.getUuid())) {
174 list = null;
175
176 break;
177 }
178 }
179 }
180
181 if (list == null) {
182 StringBundler query = null;
183
184 if (orderByComparator != null) {
185 query = new StringBundler(3 +
186 (orderByComparator.getOrderByFields().length * 3));
187 }
188 else {
189 query = new StringBundler(3);
190 }
191
192 query.append(_SQL_SELECT_MDRACTION_WHERE);
193
194 boolean bindUuid = false;
195
196 if (uuid == null) {
197 query.append(_FINDER_COLUMN_UUID_UUID_1);
198 }
199 else if (uuid.equals(StringPool.BLANK)) {
200 query.append(_FINDER_COLUMN_UUID_UUID_3);
201 }
202 else {
203 bindUuid = true;
204
205 query.append(_FINDER_COLUMN_UUID_UUID_2);
206 }
207
208 if (orderByComparator != null) {
209 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
210 orderByComparator);
211 }
212 else
213 if (pagination) {
214 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
215 }
216
217 String sql = query.toString();
218
219 Session session = null;
220
221 try {
222 session = openSession();
223
224 Query q = session.createQuery(sql);
225
226 QueryPos qPos = QueryPos.getInstance(q);
227
228 if (bindUuid) {
229 qPos.add(uuid);
230 }
231
232 if (!pagination) {
233 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
234 start, end, false);
235
236 Collections.sort(list);
237
238 list = Collections.unmodifiableList(list);
239 }
240 else {
241 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
242 start, end);
243 }
244
245 cacheResult(list);
246
247 FinderCacheUtil.putResult(finderPath, finderArgs, list);
248 }
249 catch (Exception e) {
250 FinderCacheUtil.removeResult(finderPath, finderArgs);
251
252 throw processException(e);
253 }
254 finally {
255 closeSession(session);
256 }
257 }
258
259 return list;
260 }
261
262
270 @Override
271 public MDRAction findByUuid_First(String uuid,
272 OrderByComparator<MDRAction> orderByComparator)
273 throws NoSuchActionException {
274 MDRAction mdrAction = fetchByUuid_First(uuid, orderByComparator);
275
276 if (mdrAction != null) {
277 return mdrAction;
278 }
279
280 StringBundler msg = new StringBundler(4);
281
282 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
283
284 msg.append("uuid=");
285 msg.append(uuid);
286
287 msg.append(StringPool.CLOSE_CURLY_BRACE);
288
289 throw new NoSuchActionException(msg.toString());
290 }
291
292
299 @Override
300 public MDRAction fetchByUuid_First(String uuid,
301 OrderByComparator<MDRAction> orderByComparator) {
302 List<MDRAction> list = findByUuid(uuid, 0, 1, orderByComparator);
303
304 if (!list.isEmpty()) {
305 return list.get(0);
306 }
307
308 return null;
309 }
310
311
319 @Override
320 public MDRAction findByUuid_Last(String uuid,
321 OrderByComparator<MDRAction> orderByComparator)
322 throws NoSuchActionException {
323 MDRAction mdrAction = fetchByUuid_Last(uuid, orderByComparator);
324
325 if (mdrAction != null) {
326 return mdrAction;
327 }
328
329 StringBundler msg = new StringBundler(4);
330
331 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
332
333 msg.append("uuid=");
334 msg.append(uuid);
335
336 msg.append(StringPool.CLOSE_CURLY_BRACE);
337
338 throw new NoSuchActionException(msg.toString());
339 }
340
341
348 @Override
349 public MDRAction fetchByUuid_Last(String uuid,
350 OrderByComparator<MDRAction> orderByComparator) {
351 int count = countByUuid(uuid);
352
353 if (count == 0) {
354 return null;
355 }
356
357 List<MDRAction> list = findByUuid(uuid, count - 1, count,
358 orderByComparator);
359
360 if (!list.isEmpty()) {
361 return list.get(0);
362 }
363
364 return null;
365 }
366
367
376 @Override
377 public MDRAction[] findByUuid_PrevAndNext(long actionId, String uuid,
378 OrderByComparator<MDRAction> orderByComparator)
379 throws NoSuchActionException {
380 MDRAction mdrAction = findByPrimaryKey(actionId);
381
382 Session session = null;
383
384 try {
385 session = openSession();
386
387 MDRAction[] array = new MDRActionImpl[3];
388
389 array[0] = getByUuid_PrevAndNext(session, mdrAction, uuid,
390 orderByComparator, true);
391
392 array[1] = mdrAction;
393
394 array[2] = getByUuid_PrevAndNext(session, mdrAction, uuid,
395 orderByComparator, false);
396
397 return array;
398 }
399 catch (Exception e) {
400 throw processException(e);
401 }
402 finally {
403 closeSession(session);
404 }
405 }
406
407 protected MDRAction getByUuid_PrevAndNext(Session session,
408 MDRAction mdrAction, String uuid,
409 OrderByComparator<MDRAction> orderByComparator, boolean previous) {
410 StringBundler query = null;
411
412 if (orderByComparator != null) {
413 query = new StringBundler(6 +
414 (orderByComparator.getOrderByFields().length * 6));
415 }
416 else {
417 query = new StringBundler(3);
418 }
419
420 query.append(_SQL_SELECT_MDRACTION_WHERE);
421
422 boolean bindUuid = false;
423
424 if (uuid == null) {
425 query.append(_FINDER_COLUMN_UUID_UUID_1);
426 }
427 else if (uuid.equals(StringPool.BLANK)) {
428 query.append(_FINDER_COLUMN_UUID_UUID_3);
429 }
430 else {
431 bindUuid = true;
432
433 query.append(_FINDER_COLUMN_UUID_UUID_2);
434 }
435
436 if (orderByComparator != null) {
437 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
438
439 if (orderByConditionFields.length > 0) {
440 query.append(WHERE_AND);
441 }
442
443 for (int i = 0; i < orderByConditionFields.length; i++) {
444 query.append(_ORDER_BY_ENTITY_ALIAS);
445 query.append(orderByConditionFields[i]);
446
447 if ((i + 1) < orderByConditionFields.length) {
448 if (orderByComparator.isAscending() ^ previous) {
449 query.append(WHERE_GREATER_THAN_HAS_NEXT);
450 }
451 else {
452 query.append(WHERE_LESSER_THAN_HAS_NEXT);
453 }
454 }
455 else {
456 if (orderByComparator.isAscending() ^ previous) {
457 query.append(WHERE_GREATER_THAN);
458 }
459 else {
460 query.append(WHERE_LESSER_THAN);
461 }
462 }
463 }
464
465 query.append(ORDER_BY_CLAUSE);
466
467 String[] orderByFields = orderByComparator.getOrderByFields();
468
469 for (int i = 0; i < orderByFields.length; i++) {
470 query.append(_ORDER_BY_ENTITY_ALIAS);
471 query.append(orderByFields[i]);
472
473 if ((i + 1) < orderByFields.length) {
474 if (orderByComparator.isAscending() ^ previous) {
475 query.append(ORDER_BY_ASC_HAS_NEXT);
476 }
477 else {
478 query.append(ORDER_BY_DESC_HAS_NEXT);
479 }
480 }
481 else {
482 if (orderByComparator.isAscending() ^ previous) {
483 query.append(ORDER_BY_ASC);
484 }
485 else {
486 query.append(ORDER_BY_DESC);
487 }
488 }
489 }
490 }
491 else {
492 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
493 }
494
495 String sql = query.toString();
496
497 Query q = session.createQuery(sql);
498
499 q.setFirstResult(0);
500 q.setMaxResults(2);
501
502 QueryPos qPos = QueryPos.getInstance(q);
503
504 if (bindUuid) {
505 qPos.add(uuid);
506 }
507
508 if (orderByComparator != null) {
509 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
510
511 for (Object value : values) {
512 qPos.add(value);
513 }
514 }
515
516 List<MDRAction> list = q.list();
517
518 if (list.size() == 2) {
519 return list.get(1);
520 }
521 else {
522 return null;
523 }
524 }
525
526
531 @Override
532 public void removeByUuid(String uuid) {
533 for (MDRAction mdrAction : findByUuid(uuid, QueryUtil.ALL_POS,
534 QueryUtil.ALL_POS, null)) {
535 remove(mdrAction);
536 }
537 }
538
539
545 @Override
546 public int countByUuid(String uuid) {
547 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
548
549 Object[] finderArgs = new Object[] { uuid };
550
551 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
552 this);
553
554 if (count == null) {
555 StringBundler query = new StringBundler(2);
556
557 query.append(_SQL_COUNT_MDRACTION_WHERE);
558
559 boolean bindUuid = false;
560
561 if (uuid == null) {
562 query.append(_FINDER_COLUMN_UUID_UUID_1);
563 }
564 else if (uuid.equals(StringPool.BLANK)) {
565 query.append(_FINDER_COLUMN_UUID_UUID_3);
566 }
567 else {
568 bindUuid = true;
569
570 query.append(_FINDER_COLUMN_UUID_UUID_2);
571 }
572
573 String sql = query.toString();
574
575 Session session = null;
576
577 try {
578 session = openSession();
579
580 Query q = session.createQuery(sql);
581
582 QueryPos qPos = QueryPos.getInstance(q);
583
584 if (bindUuid) {
585 qPos.add(uuid);
586 }
587
588 count = (Long)q.uniqueResult();
589
590 FinderCacheUtil.putResult(finderPath, finderArgs, count);
591 }
592 catch (Exception e) {
593 FinderCacheUtil.removeResult(finderPath, finderArgs);
594
595 throw processException(e);
596 }
597 finally {
598 closeSession(session);
599 }
600 }
601
602 return count.intValue();
603 }
604
605 private static final String _FINDER_COLUMN_UUID_UUID_1 = "mdrAction.uuid IS NULL";
606 private static final String _FINDER_COLUMN_UUID_UUID_2 = "mdrAction.uuid = ?";
607 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = '')";
608 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
609 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
610 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
611 new String[] { String.class.getName(), Long.class.getName() },
612 MDRActionModelImpl.UUID_COLUMN_BITMASK |
613 MDRActionModelImpl.GROUPID_COLUMN_BITMASK);
614 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
615 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
616 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
617 new String[] { String.class.getName(), Long.class.getName() });
618
619
627 @Override
628 public MDRAction findByUUID_G(String uuid, long groupId)
629 throws NoSuchActionException {
630 MDRAction mdrAction = fetchByUUID_G(uuid, groupId);
631
632 if (mdrAction == null) {
633 StringBundler msg = new StringBundler(6);
634
635 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
636
637 msg.append("uuid=");
638 msg.append(uuid);
639
640 msg.append(", groupId=");
641 msg.append(groupId);
642
643 msg.append(StringPool.CLOSE_CURLY_BRACE);
644
645 if (_log.isWarnEnabled()) {
646 _log.warn(msg.toString());
647 }
648
649 throw new NoSuchActionException(msg.toString());
650 }
651
652 return mdrAction;
653 }
654
655
662 @Override
663 public MDRAction fetchByUUID_G(String uuid, long groupId) {
664 return fetchByUUID_G(uuid, groupId, true);
665 }
666
667
675 @Override
676 public MDRAction fetchByUUID_G(String uuid, long groupId,
677 boolean retrieveFromCache) {
678 Object[] finderArgs = new Object[] { uuid, groupId };
679
680 Object result = null;
681
682 if (retrieveFromCache) {
683 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
684 finderArgs, this);
685 }
686
687 if (result instanceof MDRAction) {
688 MDRAction mdrAction = (MDRAction)result;
689
690 if (!Validator.equals(uuid, mdrAction.getUuid()) ||
691 (groupId != mdrAction.getGroupId())) {
692 result = null;
693 }
694 }
695
696 if (result == null) {
697 StringBundler query = new StringBundler(4);
698
699 query.append(_SQL_SELECT_MDRACTION_WHERE);
700
701 boolean bindUuid = false;
702
703 if (uuid == null) {
704 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
705 }
706 else if (uuid.equals(StringPool.BLANK)) {
707 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
708 }
709 else {
710 bindUuid = true;
711
712 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
713 }
714
715 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
716
717 String sql = query.toString();
718
719 Session session = null;
720
721 try {
722 session = openSession();
723
724 Query q = session.createQuery(sql);
725
726 QueryPos qPos = QueryPos.getInstance(q);
727
728 if (bindUuid) {
729 qPos.add(uuid);
730 }
731
732 qPos.add(groupId);
733
734 List<MDRAction> list = q.list();
735
736 if (list.isEmpty()) {
737 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
738 finderArgs, list);
739 }
740 else {
741 MDRAction mdrAction = list.get(0);
742
743 result = mdrAction;
744
745 cacheResult(mdrAction);
746
747 if ((mdrAction.getUuid() == null) ||
748 !mdrAction.getUuid().equals(uuid) ||
749 (mdrAction.getGroupId() != groupId)) {
750 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
751 finderArgs, mdrAction);
752 }
753 }
754 }
755 catch (Exception e) {
756 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
757 finderArgs);
758
759 throw processException(e);
760 }
761 finally {
762 closeSession(session);
763 }
764 }
765
766 if (result instanceof List<?>) {
767 return null;
768 }
769 else {
770 return (MDRAction)result;
771 }
772 }
773
774
781 @Override
782 public MDRAction removeByUUID_G(String uuid, long groupId)
783 throws NoSuchActionException {
784 MDRAction mdrAction = findByUUID_G(uuid, groupId);
785
786 return remove(mdrAction);
787 }
788
789
796 @Override
797 public int countByUUID_G(String uuid, long groupId) {
798 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
799
800 Object[] finderArgs = new Object[] { uuid, groupId };
801
802 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
803 this);
804
805 if (count == null) {
806 StringBundler query = new StringBundler(3);
807
808 query.append(_SQL_COUNT_MDRACTION_WHERE);
809
810 boolean bindUuid = false;
811
812 if (uuid == null) {
813 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
814 }
815 else if (uuid.equals(StringPool.BLANK)) {
816 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
817 }
818 else {
819 bindUuid = true;
820
821 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
822 }
823
824 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
825
826 String sql = query.toString();
827
828 Session session = null;
829
830 try {
831 session = openSession();
832
833 Query q = session.createQuery(sql);
834
835 QueryPos qPos = QueryPos.getInstance(q);
836
837 if (bindUuid) {
838 qPos.add(uuid);
839 }
840
841 qPos.add(groupId);
842
843 count = (Long)q.uniqueResult();
844
845 FinderCacheUtil.putResult(finderPath, finderArgs, count);
846 }
847 catch (Exception e) {
848 FinderCacheUtil.removeResult(finderPath, finderArgs);
849
850 throw processException(e);
851 }
852 finally {
853 closeSession(session);
854 }
855 }
856
857 return count.intValue();
858 }
859
860 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "mdrAction.uuid IS NULL AND ";
861 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "mdrAction.uuid = ? AND ";
862 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = '') AND ";
863 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "mdrAction.groupId = ?";
864 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
865 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
866 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
867 new String[] {
868 String.class.getName(), Long.class.getName(),
869
870 Integer.class.getName(), Integer.class.getName(),
871 OrderByComparator.class.getName()
872 });
873 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
874 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
875 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
876 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
877 new String[] { String.class.getName(), Long.class.getName() },
878 MDRActionModelImpl.UUID_COLUMN_BITMASK |
879 MDRActionModelImpl.COMPANYID_COLUMN_BITMASK);
880 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
881 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
882 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
883 new String[] { String.class.getName(), Long.class.getName() });
884
885
892 @Override
893 public List<MDRAction> findByUuid_C(String uuid, long companyId) {
894 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
895 QueryUtil.ALL_POS, null);
896 }
897
898
911 @Override
912 public List<MDRAction> findByUuid_C(String uuid, long companyId, int start,
913 int end) {
914 return findByUuid_C(uuid, companyId, start, end, null);
915 }
916
917
931 @Override
932 public List<MDRAction> findByUuid_C(String uuid, long companyId, int start,
933 int end, OrderByComparator<MDRAction> orderByComparator) {
934 boolean pagination = true;
935 FinderPath finderPath = null;
936 Object[] finderArgs = null;
937
938 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
939 (orderByComparator == null)) {
940 pagination = false;
941 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
942 finderArgs = new Object[] { uuid, companyId };
943 }
944 else {
945 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
946 finderArgs = new Object[] {
947 uuid, companyId,
948
949 start, end, orderByComparator
950 };
951 }
952
953 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
954 finderArgs, this);
955
956 if ((list != null) && !list.isEmpty()) {
957 for (MDRAction mdrAction : list) {
958 if (!Validator.equals(uuid, mdrAction.getUuid()) ||
959 (companyId != mdrAction.getCompanyId())) {
960 list = null;
961
962 break;
963 }
964 }
965 }
966
967 if (list == null) {
968 StringBundler query = null;
969
970 if (orderByComparator != null) {
971 query = new StringBundler(4 +
972 (orderByComparator.getOrderByFields().length * 3));
973 }
974 else {
975 query = new StringBundler(4);
976 }
977
978 query.append(_SQL_SELECT_MDRACTION_WHERE);
979
980 boolean bindUuid = false;
981
982 if (uuid == null) {
983 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
984 }
985 else if (uuid.equals(StringPool.BLANK)) {
986 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
987 }
988 else {
989 bindUuid = true;
990
991 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
992 }
993
994 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
995
996 if (orderByComparator != null) {
997 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
998 orderByComparator);
999 }
1000 else
1001 if (pagination) {
1002 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1003 }
1004
1005 String sql = query.toString();
1006
1007 Session session = null;
1008
1009 try {
1010 session = openSession();
1011
1012 Query q = session.createQuery(sql);
1013
1014 QueryPos qPos = QueryPos.getInstance(q);
1015
1016 if (bindUuid) {
1017 qPos.add(uuid);
1018 }
1019
1020 qPos.add(companyId);
1021
1022 if (!pagination) {
1023 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1024 start, end, false);
1025
1026 Collections.sort(list);
1027
1028 list = Collections.unmodifiableList(list);
1029 }
1030 else {
1031 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1032 start, end);
1033 }
1034
1035 cacheResult(list);
1036
1037 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1038 }
1039 catch (Exception e) {
1040 FinderCacheUtil.removeResult(finderPath, finderArgs);
1041
1042 throw processException(e);
1043 }
1044 finally {
1045 closeSession(session);
1046 }
1047 }
1048
1049 return list;
1050 }
1051
1052
1061 @Override
1062 public MDRAction findByUuid_C_First(String uuid, long companyId,
1063 OrderByComparator<MDRAction> orderByComparator)
1064 throws NoSuchActionException {
1065 MDRAction mdrAction = fetchByUuid_C_First(uuid, companyId,
1066 orderByComparator);
1067
1068 if (mdrAction != null) {
1069 return mdrAction;
1070 }
1071
1072 StringBundler msg = new StringBundler(6);
1073
1074 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1075
1076 msg.append("uuid=");
1077 msg.append(uuid);
1078
1079 msg.append(", companyId=");
1080 msg.append(companyId);
1081
1082 msg.append(StringPool.CLOSE_CURLY_BRACE);
1083
1084 throw new NoSuchActionException(msg.toString());
1085 }
1086
1087
1095 @Override
1096 public MDRAction fetchByUuid_C_First(String uuid, long companyId,
1097 OrderByComparator<MDRAction> orderByComparator) {
1098 List<MDRAction> list = findByUuid_C(uuid, companyId, 0, 1,
1099 orderByComparator);
1100
1101 if (!list.isEmpty()) {
1102 return list.get(0);
1103 }
1104
1105 return null;
1106 }
1107
1108
1117 @Override
1118 public MDRAction findByUuid_C_Last(String uuid, long companyId,
1119 OrderByComparator<MDRAction> orderByComparator)
1120 throws NoSuchActionException {
1121 MDRAction mdrAction = fetchByUuid_C_Last(uuid, companyId,
1122 orderByComparator);
1123
1124 if (mdrAction != null) {
1125 return mdrAction;
1126 }
1127
1128 StringBundler msg = new StringBundler(6);
1129
1130 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1131
1132 msg.append("uuid=");
1133 msg.append(uuid);
1134
1135 msg.append(", companyId=");
1136 msg.append(companyId);
1137
1138 msg.append(StringPool.CLOSE_CURLY_BRACE);
1139
1140 throw new NoSuchActionException(msg.toString());
1141 }
1142
1143
1151 @Override
1152 public MDRAction fetchByUuid_C_Last(String uuid, long companyId,
1153 OrderByComparator<MDRAction> orderByComparator) {
1154 int count = countByUuid_C(uuid, companyId);
1155
1156 if (count == 0) {
1157 return null;
1158 }
1159
1160 List<MDRAction> list = findByUuid_C(uuid, companyId, count - 1, count,
1161 orderByComparator);
1162
1163 if (!list.isEmpty()) {
1164 return list.get(0);
1165 }
1166
1167 return null;
1168 }
1169
1170
1180 @Override
1181 public MDRAction[] findByUuid_C_PrevAndNext(long actionId, String uuid,
1182 long companyId, OrderByComparator<MDRAction> orderByComparator)
1183 throws NoSuchActionException {
1184 MDRAction mdrAction = findByPrimaryKey(actionId);
1185
1186 Session session = null;
1187
1188 try {
1189 session = openSession();
1190
1191 MDRAction[] array = new MDRActionImpl[3];
1192
1193 array[0] = getByUuid_C_PrevAndNext(session, mdrAction, uuid,
1194 companyId, orderByComparator, true);
1195
1196 array[1] = mdrAction;
1197
1198 array[2] = getByUuid_C_PrevAndNext(session, mdrAction, uuid,
1199 companyId, orderByComparator, false);
1200
1201 return array;
1202 }
1203 catch (Exception e) {
1204 throw processException(e);
1205 }
1206 finally {
1207 closeSession(session);
1208 }
1209 }
1210
1211 protected MDRAction getByUuid_C_PrevAndNext(Session session,
1212 MDRAction mdrAction, String uuid, long companyId,
1213 OrderByComparator<MDRAction> orderByComparator, boolean previous) {
1214 StringBundler query = null;
1215
1216 if (orderByComparator != null) {
1217 query = new StringBundler(6 +
1218 (orderByComparator.getOrderByFields().length * 6));
1219 }
1220 else {
1221 query = new StringBundler(3);
1222 }
1223
1224 query.append(_SQL_SELECT_MDRACTION_WHERE);
1225
1226 boolean bindUuid = false;
1227
1228 if (uuid == null) {
1229 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1230 }
1231 else if (uuid.equals(StringPool.BLANK)) {
1232 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1233 }
1234 else {
1235 bindUuid = true;
1236
1237 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1238 }
1239
1240 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1241
1242 if (orderByComparator != null) {
1243 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1244
1245 if (orderByConditionFields.length > 0) {
1246 query.append(WHERE_AND);
1247 }
1248
1249 for (int i = 0; i < orderByConditionFields.length; i++) {
1250 query.append(_ORDER_BY_ENTITY_ALIAS);
1251 query.append(orderByConditionFields[i]);
1252
1253 if ((i + 1) < orderByConditionFields.length) {
1254 if (orderByComparator.isAscending() ^ previous) {
1255 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1256 }
1257 else {
1258 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1259 }
1260 }
1261 else {
1262 if (orderByComparator.isAscending() ^ previous) {
1263 query.append(WHERE_GREATER_THAN);
1264 }
1265 else {
1266 query.append(WHERE_LESSER_THAN);
1267 }
1268 }
1269 }
1270
1271 query.append(ORDER_BY_CLAUSE);
1272
1273 String[] orderByFields = orderByComparator.getOrderByFields();
1274
1275 for (int i = 0; i < orderByFields.length; i++) {
1276 query.append(_ORDER_BY_ENTITY_ALIAS);
1277 query.append(orderByFields[i]);
1278
1279 if ((i + 1) < orderByFields.length) {
1280 if (orderByComparator.isAscending() ^ previous) {
1281 query.append(ORDER_BY_ASC_HAS_NEXT);
1282 }
1283 else {
1284 query.append(ORDER_BY_DESC_HAS_NEXT);
1285 }
1286 }
1287 else {
1288 if (orderByComparator.isAscending() ^ previous) {
1289 query.append(ORDER_BY_ASC);
1290 }
1291 else {
1292 query.append(ORDER_BY_DESC);
1293 }
1294 }
1295 }
1296 }
1297 else {
1298 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1299 }
1300
1301 String sql = query.toString();
1302
1303 Query q = session.createQuery(sql);
1304
1305 q.setFirstResult(0);
1306 q.setMaxResults(2);
1307
1308 QueryPos qPos = QueryPos.getInstance(q);
1309
1310 if (bindUuid) {
1311 qPos.add(uuid);
1312 }
1313
1314 qPos.add(companyId);
1315
1316 if (orderByComparator != null) {
1317 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1318
1319 for (Object value : values) {
1320 qPos.add(value);
1321 }
1322 }
1323
1324 List<MDRAction> list = q.list();
1325
1326 if (list.size() == 2) {
1327 return list.get(1);
1328 }
1329 else {
1330 return null;
1331 }
1332 }
1333
1334
1340 @Override
1341 public void removeByUuid_C(String uuid, long companyId) {
1342 for (MDRAction mdrAction : findByUuid_C(uuid, companyId,
1343 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1344 remove(mdrAction);
1345 }
1346 }
1347
1348
1355 @Override
1356 public int countByUuid_C(String uuid, long companyId) {
1357 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1358
1359 Object[] finderArgs = new Object[] { uuid, companyId };
1360
1361 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1362 this);
1363
1364 if (count == null) {
1365 StringBundler query = new StringBundler(3);
1366
1367 query.append(_SQL_COUNT_MDRACTION_WHERE);
1368
1369 boolean bindUuid = false;
1370
1371 if (uuid == null) {
1372 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1373 }
1374 else if (uuid.equals(StringPool.BLANK)) {
1375 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1376 }
1377 else {
1378 bindUuid = true;
1379
1380 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1381 }
1382
1383 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1384
1385 String sql = query.toString();
1386
1387 Session session = null;
1388
1389 try {
1390 session = openSession();
1391
1392 Query q = session.createQuery(sql);
1393
1394 QueryPos qPos = QueryPos.getInstance(q);
1395
1396 if (bindUuid) {
1397 qPos.add(uuid);
1398 }
1399
1400 qPos.add(companyId);
1401
1402 count = (Long)q.uniqueResult();
1403
1404 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1405 }
1406 catch (Exception e) {
1407 FinderCacheUtil.removeResult(finderPath, finderArgs);
1408
1409 throw processException(e);
1410 }
1411 finally {
1412 closeSession(session);
1413 }
1414 }
1415
1416 return count.intValue();
1417 }
1418
1419 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "mdrAction.uuid IS NULL AND ";
1420 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "mdrAction.uuid = ? AND ";
1421 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(mdrAction.uuid IS NULL OR mdrAction.uuid = '') AND ";
1422 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "mdrAction.companyId = ?";
1423 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
1424 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1425 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
1426 FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1427 "findByRuleGroupInstanceId",
1428 new String[] {
1429 Long.class.getName(),
1430
1431 Integer.class.getName(), Integer.class.getName(),
1432 OrderByComparator.class.getName()
1433 });
1434 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID =
1435 new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1436 MDRActionModelImpl.FINDER_CACHE_ENABLED, MDRActionImpl.class,
1437 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1438 "findByRuleGroupInstanceId", new String[] { Long.class.getName() },
1439 MDRActionModelImpl.RULEGROUPINSTANCEID_COLUMN_BITMASK);
1440 public static final FinderPath FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID = new FinderPath(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1441 MDRActionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1442 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1443 "countByRuleGroupInstanceId", new String[] { Long.class.getName() });
1444
1445
1451 @Override
1452 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId) {
1453 return findByRuleGroupInstanceId(ruleGroupInstanceId,
1454 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1455 }
1456
1457
1469 @Override
1470 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1471 int start, int end) {
1472 return findByRuleGroupInstanceId(ruleGroupInstanceId, start, end, null);
1473 }
1474
1475
1488 @Override
1489 public List<MDRAction> findByRuleGroupInstanceId(long ruleGroupInstanceId,
1490 int start, int end, OrderByComparator<MDRAction> orderByComparator) {
1491 boolean pagination = true;
1492 FinderPath finderPath = null;
1493 Object[] finderArgs = null;
1494
1495 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1496 (orderByComparator == null)) {
1497 pagination = false;
1498 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1499 finderArgs = new Object[] { ruleGroupInstanceId };
1500 }
1501 else {
1502 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RULEGROUPINSTANCEID;
1503 finderArgs = new Object[] {
1504 ruleGroupInstanceId,
1505
1506 start, end, orderByComparator
1507 };
1508 }
1509
1510 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
1511 finderArgs, this);
1512
1513 if ((list != null) && !list.isEmpty()) {
1514 for (MDRAction mdrAction : list) {
1515 if ((ruleGroupInstanceId != mdrAction.getRuleGroupInstanceId())) {
1516 list = null;
1517
1518 break;
1519 }
1520 }
1521 }
1522
1523 if (list == null) {
1524 StringBundler query = null;
1525
1526 if (orderByComparator != null) {
1527 query = new StringBundler(3 +
1528 (orderByComparator.getOrderByFields().length * 3));
1529 }
1530 else {
1531 query = new StringBundler(3);
1532 }
1533
1534 query.append(_SQL_SELECT_MDRACTION_WHERE);
1535
1536 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1537
1538 if (orderByComparator != null) {
1539 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1540 orderByComparator);
1541 }
1542 else
1543 if (pagination) {
1544 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1545 }
1546
1547 String sql = query.toString();
1548
1549 Session session = null;
1550
1551 try {
1552 session = openSession();
1553
1554 Query q = session.createQuery(sql);
1555
1556 QueryPos qPos = QueryPos.getInstance(q);
1557
1558 qPos.add(ruleGroupInstanceId);
1559
1560 if (!pagination) {
1561 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1562 start, end, false);
1563
1564 Collections.sort(list);
1565
1566 list = Collections.unmodifiableList(list);
1567 }
1568 else {
1569 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
1570 start, end);
1571 }
1572
1573 cacheResult(list);
1574
1575 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1576 }
1577 catch (Exception e) {
1578 FinderCacheUtil.removeResult(finderPath, finderArgs);
1579
1580 throw processException(e);
1581 }
1582 finally {
1583 closeSession(session);
1584 }
1585 }
1586
1587 return list;
1588 }
1589
1590
1598 @Override
1599 public MDRAction findByRuleGroupInstanceId_First(long ruleGroupInstanceId,
1600 OrderByComparator<MDRAction> orderByComparator)
1601 throws NoSuchActionException {
1602 MDRAction mdrAction = fetchByRuleGroupInstanceId_First(ruleGroupInstanceId,
1603 orderByComparator);
1604
1605 if (mdrAction != null) {
1606 return mdrAction;
1607 }
1608
1609 StringBundler msg = new StringBundler(4);
1610
1611 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1612
1613 msg.append("ruleGroupInstanceId=");
1614 msg.append(ruleGroupInstanceId);
1615
1616 msg.append(StringPool.CLOSE_CURLY_BRACE);
1617
1618 throw new NoSuchActionException(msg.toString());
1619 }
1620
1621
1628 @Override
1629 public MDRAction fetchByRuleGroupInstanceId_First(
1630 long ruleGroupInstanceId, OrderByComparator<MDRAction> orderByComparator) {
1631 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1632 0, 1, orderByComparator);
1633
1634 if (!list.isEmpty()) {
1635 return list.get(0);
1636 }
1637
1638 return null;
1639 }
1640
1641
1649 @Override
1650 public MDRAction findByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1651 OrderByComparator<MDRAction> orderByComparator)
1652 throws NoSuchActionException {
1653 MDRAction mdrAction = fetchByRuleGroupInstanceId_Last(ruleGroupInstanceId,
1654 orderByComparator);
1655
1656 if (mdrAction != null) {
1657 return mdrAction;
1658 }
1659
1660 StringBundler msg = new StringBundler(4);
1661
1662 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1663
1664 msg.append("ruleGroupInstanceId=");
1665 msg.append(ruleGroupInstanceId);
1666
1667 msg.append(StringPool.CLOSE_CURLY_BRACE);
1668
1669 throw new NoSuchActionException(msg.toString());
1670 }
1671
1672
1679 @Override
1680 public MDRAction fetchByRuleGroupInstanceId_Last(long ruleGroupInstanceId,
1681 OrderByComparator<MDRAction> orderByComparator) {
1682 int count = countByRuleGroupInstanceId(ruleGroupInstanceId);
1683
1684 if (count == 0) {
1685 return null;
1686 }
1687
1688 List<MDRAction> list = findByRuleGroupInstanceId(ruleGroupInstanceId,
1689 count - 1, count, orderByComparator);
1690
1691 if (!list.isEmpty()) {
1692 return list.get(0);
1693 }
1694
1695 return null;
1696 }
1697
1698
1707 @Override
1708 public MDRAction[] findByRuleGroupInstanceId_PrevAndNext(long actionId,
1709 long ruleGroupInstanceId, OrderByComparator<MDRAction> orderByComparator)
1710 throws NoSuchActionException {
1711 MDRAction mdrAction = findByPrimaryKey(actionId);
1712
1713 Session session = null;
1714
1715 try {
1716 session = openSession();
1717
1718 MDRAction[] array = new MDRActionImpl[3];
1719
1720 array[0] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1721 ruleGroupInstanceId, orderByComparator, true);
1722
1723 array[1] = mdrAction;
1724
1725 array[2] = getByRuleGroupInstanceId_PrevAndNext(session, mdrAction,
1726 ruleGroupInstanceId, orderByComparator, false);
1727
1728 return array;
1729 }
1730 catch (Exception e) {
1731 throw processException(e);
1732 }
1733 finally {
1734 closeSession(session);
1735 }
1736 }
1737
1738 protected MDRAction getByRuleGroupInstanceId_PrevAndNext(Session session,
1739 MDRAction mdrAction, long ruleGroupInstanceId,
1740 OrderByComparator<MDRAction> orderByComparator, boolean previous) {
1741 StringBundler query = null;
1742
1743 if (orderByComparator != null) {
1744 query = new StringBundler(6 +
1745 (orderByComparator.getOrderByFields().length * 6));
1746 }
1747 else {
1748 query = new StringBundler(3);
1749 }
1750
1751 query.append(_SQL_SELECT_MDRACTION_WHERE);
1752
1753 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1754
1755 if (orderByComparator != null) {
1756 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1757
1758 if (orderByConditionFields.length > 0) {
1759 query.append(WHERE_AND);
1760 }
1761
1762 for (int i = 0; i < orderByConditionFields.length; i++) {
1763 query.append(_ORDER_BY_ENTITY_ALIAS);
1764 query.append(orderByConditionFields[i]);
1765
1766 if ((i + 1) < orderByConditionFields.length) {
1767 if (orderByComparator.isAscending() ^ previous) {
1768 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1769 }
1770 else {
1771 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1772 }
1773 }
1774 else {
1775 if (orderByComparator.isAscending() ^ previous) {
1776 query.append(WHERE_GREATER_THAN);
1777 }
1778 else {
1779 query.append(WHERE_LESSER_THAN);
1780 }
1781 }
1782 }
1783
1784 query.append(ORDER_BY_CLAUSE);
1785
1786 String[] orderByFields = orderByComparator.getOrderByFields();
1787
1788 for (int i = 0; i < orderByFields.length; i++) {
1789 query.append(_ORDER_BY_ENTITY_ALIAS);
1790 query.append(orderByFields[i]);
1791
1792 if ((i + 1) < orderByFields.length) {
1793 if (orderByComparator.isAscending() ^ previous) {
1794 query.append(ORDER_BY_ASC_HAS_NEXT);
1795 }
1796 else {
1797 query.append(ORDER_BY_DESC_HAS_NEXT);
1798 }
1799 }
1800 else {
1801 if (orderByComparator.isAscending() ^ previous) {
1802 query.append(ORDER_BY_ASC);
1803 }
1804 else {
1805 query.append(ORDER_BY_DESC);
1806 }
1807 }
1808 }
1809 }
1810 else {
1811 query.append(MDRActionModelImpl.ORDER_BY_JPQL);
1812 }
1813
1814 String sql = query.toString();
1815
1816 Query q = session.createQuery(sql);
1817
1818 q.setFirstResult(0);
1819 q.setMaxResults(2);
1820
1821 QueryPos qPos = QueryPos.getInstance(q);
1822
1823 qPos.add(ruleGroupInstanceId);
1824
1825 if (orderByComparator != null) {
1826 Object[] values = orderByComparator.getOrderByConditionValues(mdrAction);
1827
1828 for (Object value : values) {
1829 qPos.add(value);
1830 }
1831 }
1832
1833 List<MDRAction> list = q.list();
1834
1835 if (list.size() == 2) {
1836 return list.get(1);
1837 }
1838 else {
1839 return null;
1840 }
1841 }
1842
1843
1848 @Override
1849 public void removeByRuleGroupInstanceId(long ruleGroupInstanceId) {
1850 for (MDRAction mdrAction : findByRuleGroupInstanceId(
1851 ruleGroupInstanceId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1852 remove(mdrAction);
1853 }
1854 }
1855
1856
1862 @Override
1863 public int countByRuleGroupInstanceId(long ruleGroupInstanceId) {
1864 FinderPath finderPath = FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID;
1865
1866 Object[] finderArgs = new Object[] { ruleGroupInstanceId };
1867
1868 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1869 this);
1870
1871 if (count == null) {
1872 StringBundler query = new StringBundler(2);
1873
1874 query.append(_SQL_COUNT_MDRACTION_WHERE);
1875
1876 query.append(_FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2);
1877
1878 String sql = query.toString();
1879
1880 Session session = null;
1881
1882 try {
1883 session = openSession();
1884
1885 Query q = session.createQuery(sql);
1886
1887 QueryPos qPos = QueryPos.getInstance(q);
1888
1889 qPos.add(ruleGroupInstanceId);
1890
1891 count = (Long)q.uniqueResult();
1892
1893 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1894 }
1895 catch (Exception e) {
1896 FinderCacheUtil.removeResult(finderPath, finderArgs);
1897
1898 throw processException(e);
1899 }
1900 finally {
1901 closeSession(session);
1902 }
1903 }
1904
1905 return count.intValue();
1906 }
1907
1908 private static final String _FINDER_COLUMN_RULEGROUPINSTANCEID_RULEGROUPINSTANCEID_2 =
1909 "mdrAction.ruleGroupInstanceId = ?";
1910
1911 public MDRActionPersistenceImpl() {
1912 setModelClass(MDRAction.class);
1913 }
1914
1915
1920 @Override
1921 public void cacheResult(MDRAction mdrAction) {
1922 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1923 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction);
1924
1925 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1926 new Object[] { mdrAction.getUuid(), mdrAction.getGroupId() },
1927 mdrAction);
1928
1929 mdrAction.resetOriginalValues();
1930 }
1931
1932
1937 @Override
1938 public void cacheResult(List<MDRAction> mdrActions) {
1939 for (MDRAction mdrAction : mdrActions) {
1940 if (EntityCacheUtil.getResult(
1941 MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1942 MDRActionImpl.class, mdrAction.getPrimaryKey()) == null) {
1943 cacheResult(mdrAction);
1944 }
1945 else {
1946 mdrAction.resetOriginalValues();
1947 }
1948 }
1949 }
1950
1951
1958 @Override
1959 public void clearCache() {
1960 EntityCacheUtil.clearCache(MDRActionImpl.class);
1961
1962 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
1963 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1964 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1965 }
1966
1967
1974 @Override
1975 public void clearCache(MDRAction mdrAction) {
1976 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1977 MDRActionImpl.class, mdrAction.getPrimaryKey());
1978
1979 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1980 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1981
1982 clearUniqueFindersCache(mdrAction);
1983 }
1984
1985 @Override
1986 public void clearCache(List<MDRAction> mdrActions) {
1987 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1988 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1989
1990 for (MDRAction mdrAction : mdrActions) {
1991 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
1992 MDRActionImpl.class, mdrAction.getPrimaryKey());
1993
1994 clearUniqueFindersCache(mdrAction);
1995 }
1996 }
1997
1998 protected void cacheUniqueFindersCache(MDRAction mdrAction) {
1999 if (mdrAction.isNew()) {
2000 Object[] args = new Object[] {
2001 mdrAction.getUuid(), mdrAction.getGroupId()
2002 };
2003
2004 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2005 Long.valueOf(1));
2006 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2007 mdrAction);
2008 }
2009 else {
2010 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
2011
2012 if ((mdrActionModelImpl.getColumnBitmask() &
2013 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2014 Object[] args = new Object[] {
2015 mdrAction.getUuid(), mdrAction.getGroupId()
2016 };
2017
2018 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2019 Long.valueOf(1));
2020 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2021 mdrAction);
2022 }
2023 }
2024 }
2025
2026 protected void clearUniqueFindersCache(MDRAction mdrAction) {
2027 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
2028
2029 Object[] args = new Object[] { mdrAction.getUuid(), mdrAction.getGroupId() };
2030
2031 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2032 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2033
2034 if ((mdrActionModelImpl.getColumnBitmask() &
2035 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2036 args = new Object[] {
2037 mdrActionModelImpl.getOriginalUuid(),
2038 mdrActionModelImpl.getOriginalGroupId()
2039 };
2040
2041 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2042 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2043 }
2044 }
2045
2046
2052 @Override
2053 public MDRAction create(long actionId) {
2054 MDRAction mdrAction = new MDRActionImpl();
2055
2056 mdrAction.setNew(true);
2057 mdrAction.setPrimaryKey(actionId);
2058
2059 String uuid = PortalUUIDUtil.generate();
2060
2061 mdrAction.setUuid(uuid);
2062
2063 return mdrAction;
2064 }
2065
2066
2073 @Override
2074 public MDRAction remove(long actionId) throws NoSuchActionException {
2075 return remove((Serializable)actionId);
2076 }
2077
2078
2085 @Override
2086 public MDRAction remove(Serializable primaryKey)
2087 throws NoSuchActionException {
2088 Session session = null;
2089
2090 try {
2091 session = openSession();
2092
2093 MDRAction mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2094 primaryKey);
2095
2096 if (mdrAction == null) {
2097 if (_log.isWarnEnabled()) {
2098 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2099 }
2100
2101 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2102 primaryKey);
2103 }
2104
2105 return remove(mdrAction);
2106 }
2107 catch (NoSuchActionException nsee) {
2108 throw nsee;
2109 }
2110 catch (Exception e) {
2111 throw processException(e);
2112 }
2113 finally {
2114 closeSession(session);
2115 }
2116 }
2117
2118 @Override
2119 protected MDRAction removeImpl(MDRAction mdrAction) {
2120 mdrAction = toUnwrappedModel(mdrAction);
2121
2122 Session session = null;
2123
2124 try {
2125 session = openSession();
2126
2127 if (!session.contains(mdrAction)) {
2128 mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2129 mdrAction.getPrimaryKeyObj());
2130 }
2131
2132 if (mdrAction != null) {
2133 session.delete(mdrAction);
2134 }
2135 }
2136 catch (Exception e) {
2137 throw processException(e);
2138 }
2139 finally {
2140 closeSession(session);
2141 }
2142
2143 if (mdrAction != null) {
2144 clearCache(mdrAction);
2145 }
2146
2147 return mdrAction;
2148 }
2149
2150 @Override
2151 public MDRAction updateImpl(MDRAction mdrAction) {
2152 mdrAction = toUnwrappedModel(mdrAction);
2153
2154 boolean isNew = mdrAction.isNew();
2155
2156 MDRActionModelImpl mdrActionModelImpl = (MDRActionModelImpl)mdrAction;
2157
2158 if (Validator.isNull(mdrAction.getUuid())) {
2159 String uuid = PortalUUIDUtil.generate();
2160
2161 mdrAction.setUuid(uuid);
2162 }
2163
2164 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
2165
2166 Date now = new Date();
2167
2168 if (isNew && (mdrAction.getCreateDate() == null)) {
2169 if (serviceContext == null) {
2170 mdrAction.setCreateDate(now);
2171 }
2172 else {
2173 mdrAction.setCreateDate(serviceContext.getCreateDate(now));
2174 }
2175 }
2176
2177 if (!mdrActionModelImpl.hasSetModifiedDate()) {
2178 if (serviceContext == null) {
2179 mdrAction.setModifiedDate(now);
2180 }
2181 else {
2182 mdrAction.setModifiedDate(serviceContext.getModifiedDate(now));
2183 }
2184 }
2185
2186 Session session = null;
2187
2188 try {
2189 session = openSession();
2190
2191 if (mdrAction.isNew()) {
2192 session.save(mdrAction);
2193
2194 mdrAction.setNew(false);
2195 }
2196 else {
2197 session.merge(mdrAction);
2198 }
2199 }
2200 catch (Exception e) {
2201 throw processException(e);
2202 }
2203 finally {
2204 closeSession(session);
2205 }
2206
2207 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2208
2209 if (isNew || !MDRActionModelImpl.COLUMN_BITMASK_ENABLED) {
2210 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2211 }
2212
2213 else {
2214 if ((mdrActionModelImpl.getColumnBitmask() &
2215 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2216 Object[] args = new Object[] {
2217 mdrActionModelImpl.getOriginalUuid()
2218 };
2219
2220 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2221 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2222 args);
2223
2224 args = new Object[] { mdrActionModelImpl.getUuid() };
2225
2226 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2227 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2228 args);
2229 }
2230
2231 if ((mdrActionModelImpl.getColumnBitmask() &
2232 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2233 Object[] args = new Object[] {
2234 mdrActionModelImpl.getOriginalUuid(),
2235 mdrActionModelImpl.getOriginalCompanyId()
2236 };
2237
2238 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2239 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2240 args);
2241
2242 args = new Object[] {
2243 mdrActionModelImpl.getUuid(),
2244 mdrActionModelImpl.getCompanyId()
2245 };
2246
2247 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2248 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2249 args);
2250 }
2251
2252 if ((mdrActionModelImpl.getColumnBitmask() &
2253 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID.getColumnBitmask()) != 0) {
2254 Object[] args = new Object[] {
2255 mdrActionModelImpl.getOriginalRuleGroupInstanceId()
2256 };
2257
2258 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
2259 args);
2260 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
2261 args);
2262
2263 args = new Object[] { mdrActionModelImpl.getRuleGroupInstanceId() };
2264
2265 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RULEGROUPINSTANCEID,
2266 args);
2267 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RULEGROUPINSTANCEID,
2268 args);
2269 }
2270 }
2271
2272 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2273 MDRActionImpl.class, mdrAction.getPrimaryKey(), mdrAction, false);
2274
2275 clearUniqueFindersCache(mdrAction);
2276 cacheUniqueFindersCache(mdrAction);
2277
2278 mdrAction.resetOriginalValues();
2279
2280 return mdrAction;
2281 }
2282
2283 protected MDRAction toUnwrappedModel(MDRAction mdrAction) {
2284 if (mdrAction instanceof MDRActionImpl) {
2285 return mdrAction;
2286 }
2287
2288 MDRActionImpl mdrActionImpl = new MDRActionImpl();
2289
2290 mdrActionImpl.setNew(mdrAction.isNew());
2291 mdrActionImpl.setPrimaryKey(mdrAction.getPrimaryKey());
2292
2293 mdrActionImpl.setUuid(mdrAction.getUuid());
2294 mdrActionImpl.setActionId(mdrAction.getActionId());
2295 mdrActionImpl.setGroupId(mdrAction.getGroupId());
2296 mdrActionImpl.setCompanyId(mdrAction.getCompanyId());
2297 mdrActionImpl.setUserId(mdrAction.getUserId());
2298 mdrActionImpl.setUserName(mdrAction.getUserName());
2299 mdrActionImpl.setCreateDate(mdrAction.getCreateDate());
2300 mdrActionImpl.setModifiedDate(mdrAction.getModifiedDate());
2301 mdrActionImpl.setClassNameId(mdrAction.getClassNameId());
2302 mdrActionImpl.setClassPK(mdrAction.getClassPK());
2303 mdrActionImpl.setRuleGroupInstanceId(mdrAction.getRuleGroupInstanceId());
2304 mdrActionImpl.setName(mdrAction.getName());
2305 mdrActionImpl.setDescription(mdrAction.getDescription());
2306 mdrActionImpl.setType(mdrAction.getType());
2307 mdrActionImpl.setTypeSettings(mdrAction.getTypeSettings());
2308
2309 return mdrActionImpl;
2310 }
2311
2312
2319 @Override
2320 public MDRAction findByPrimaryKey(Serializable primaryKey)
2321 throws NoSuchActionException {
2322 MDRAction mdrAction = fetchByPrimaryKey(primaryKey);
2323
2324 if (mdrAction == null) {
2325 if (_log.isWarnEnabled()) {
2326 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2327 }
2328
2329 throw new NoSuchActionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2330 primaryKey);
2331 }
2332
2333 return mdrAction;
2334 }
2335
2336
2343 @Override
2344 public MDRAction findByPrimaryKey(long actionId)
2345 throws NoSuchActionException {
2346 return findByPrimaryKey((Serializable)actionId);
2347 }
2348
2349
2355 @Override
2356 public MDRAction fetchByPrimaryKey(Serializable primaryKey) {
2357 MDRAction mdrAction = (MDRAction)EntityCacheUtil.getResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2358 MDRActionImpl.class, primaryKey);
2359
2360 if (mdrAction == _nullMDRAction) {
2361 return null;
2362 }
2363
2364 if (mdrAction == null) {
2365 Session session = null;
2366
2367 try {
2368 session = openSession();
2369
2370 mdrAction = (MDRAction)session.get(MDRActionImpl.class,
2371 primaryKey);
2372
2373 if (mdrAction != null) {
2374 cacheResult(mdrAction);
2375 }
2376 else {
2377 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2378 MDRActionImpl.class, primaryKey, _nullMDRAction);
2379 }
2380 }
2381 catch (Exception e) {
2382 EntityCacheUtil.removeResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2383 MDRActionImpl.class, primaryKey);
2384
2385 throw processException(e);
2386 }
2387 finally {
2388 closeSession(session);
2389 }
2390 }
2391
2392 return mdrAction;
2393 }
2394
2395
2401 @Override
2402 public MDRAction fetchByPrimaryKey(long actionId) {
2403 return fetchByPrimaryKey((Serializable)actionId);
2404 }
2405
2406 @Override
2407 public Map<Serializable, MDRAction> fetchByPrimaryKeys(
2408 Set<Serializable> primaryKeys) {
2409 if (primaryKeys.isEmpty()) {
2410 return Collections.emptyMap();
2411 }
2412
2413 Map<Serializable, MDRAction> map = new HashMap<Serializable, MDRAction>();
2414
2415 if (primaryKeys.size() == 1) {
2416 Iterator<Serializable> iterator = primaryKeys.iterator();
2417
2418 Serializable primaryKey = iterator.next();
2419
2420 MDRAction mdrAction = fetchByPrimaryKey(primaryKey);
2421
2422 if (mdrAction != null) {
2423 map.put(primaryKey, mdrAction);
2424 }
2425
2426 return map;
2427 }
2428
2429 Set<Serializable> uncachedPrimaryKeys = null;
2430
2431 for (Serializable primaryKey : primaryKeys) {
2432 MDRAction mdrAction = (MDRAction)EntityCacheUtil.getResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2433 MDRActionImpl.class, primaryKey);
2434
2435 if (mdrAction == null) {
2436 if (uncachedPrimaryKeys == null) {
2437 uncachedPrimaryKeys = new HashSet<Serializable>();
2438 }
2439
2440 uncachedPrimaryKeys.add(primaryKey);
2441 }
2442 else {
2443 map.put(primaryKey, mdrAction);
2444 }
2445 }
2446
2447 if (uncachedPrimaryKeys == null) {
2448 return map;
2449 }
2450
2451 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2452 1);
2453
2454 query.append(_SQL_SELECT_MDRACTION_WHERE_PKS_IN);
2455
2456 for (Serializable primaryKey : uncachedPrimaryKeys) {
2457 query.append(String.valueOf(primaryKey));
2458
2459 query.append(StringPool.COMMA);
2460 }
2461
2462 query.setIndex(query.index() - 1);
2463
2464 query.append(StringPool.CLOSE_PARENTHESIS);
2465
2466 String sql = query.toString();
2467
2468 Session session = null;
2469
2470 try {
2471 session = openSession();
2472
2473 Query q = session.createQuery(sql);
2474
2475 for (MDRAction mdrAction : (List<MDRAction>)q.list()) {
2476 map.put(mdrAction.getPrimaryKeyObj(), mdrAction);
2477
2478 cacheResult(mdrAction);
2479
2480 uncachedPrimaryKeys.remove(mdrAction.getPrimaryKeyObj());
2481 }
2482
2483 for (Serializable primaryKey : uncachedPrimaryKeys) {
2484 EntityCacheUtil.putResult(MDRActionModelImpl.ENTITY_CACHE_ENABLED,
2485 MDRActionImpl.class, primaryKey, _nullMDRAction);
2486 }
2487 }
2488 catch (Exception e) {
2489 throw processException(e);
2490 }
2491 finally {
2492 closeSession(session);
2493 }
2494
2495 return map;
2496 }
2497
2498
2503 @Override
2504 public List<MDRAction> findAll() {
2505 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2506 }
2507
2508
2519 @Override
2520 public List<MDRAction> findAll(int start, int end) {
2521 return findAll(start, end, null);
2522 }
2523
2524
2536 @Override
2537 public List<MDRAction> findAll(int start, int end,
2538 OrderByComparator<MDRAction> orderByComparator) {
2539 boolean pagination = true;
2540 FinderPath finderPath = null;
2541 Object[] finderArgs = null;
2542
2543 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2544 (orderByComparator == null)) {
2545 pagination = false;
2546 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2547 finderArgs = FINDER_ARGS_EMPTY;
2548 }
2549 else {
2550 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2551 finderArgs = new Object[] { start, end, orderByComparator };
2552 }
2553
2554 List<MDRAction> list = (List<MDRAction>)FinderCacheUtil.getResult(finderPath,
2555 finderArgs, this);
2556
2557 if (list == null) {
2558 StringBundler query = null;
2559 String sql = null;
2560
2561 if (orderByComparator != null) {
2562 query = new StringBundler(2 +
2563 (orderByComparator.getOrderByFields().length * 3));
2564
2565 query.append(_SQL_SELECT_MDRACTION);
2566
2567 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2568 orderByComparator);
2569
2570 sql = query.toString();
2571 }
2572 else {
2573 sql = _SQL_SELECT_MDRACTION;
2574
2575 if (pagination) {
2576 sql = sql.concat(MDRActionModelImpl.ORDER_BY_JPQL);
2577 }
2578 }
2579
2580 Session session = null;
2581
2582 try {
2583 session = openSession();
2584
2585 Query q = session.createQuery(sql);
2586
2587 if (!pagination) {
2588 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
2589 start, end, false);
2590
2591 Collections.sort(list);
2592
2593 list = Collections.unmodifiableList(list);
2594 }
2595 else {
2596 list = (List<MDRAction>)QueryUtil.list(q, getDialect(),
2597 start, end);
2598 }
2599
2600 cacheResult(list);
2601
2602 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2603 }
2604 catch (Exception e) {
2605 FinderCacheUtil.removeResult(finderPath, finderArgs);
2606
2607 throw processException(e);
2608 }
2609 finally {
2610 closeSession(session);
2611 }
2612 }
2613
2614 return list;
2615 }
2616
2617
2621 @Override
2622 public void removeAll() {
2623 for (MDRAction mdrAction : findAll()) {
2624 remove(mdrAction);
2625 }
2626 }
2627
2628
2633 @Override
2634 public int countAll() {
2635 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2636 FINDER_ARGS_EMPTY, this);
2637
2638 if (count == null) {
2639 Session session = null;
2640
2641 try {
2642 session = openSession();
2643
2644 Query q = session.createQuery(_SQL_COUNT_MDRACTION);
2645
2646 count = (Long)q.uniqueResult();
2647
2648 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2649 FINDER_ARGS_EMPTY, count);
2650 }
2651 catch (Exception e) {
2652 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2653 FINDER_ARGS_EMPTY);
2654
2655 throw processException(e);
2656 }
2657 finally {
2658 closeSession(session);
2659 }
2660 }
2661
2662 return count.intValue();
2663 }
2664
2665 @Override
2666 protected Set<String> getBadColumnNames() {
2667 return _badColumnNames;
2668 }
2669
2670
2673 public void afterPropertiesSet() {
2674 }
2675
2676 public void destroy() {
2677 EntityCacheUtil.removeCache(MDRActionImpl.class.getName());
2678 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2679 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2680 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2681 }
2682
2683 private static final String _SQL_SELECT_MDRACTION = "SELECT mdrAction FROM MDRAction mdrAction";
2684 private static final String _SQL_SELECT_MDRACTION_WHERE_PKS_IN = "SELECT mdrAction FROM MDRAction mdrAction WHERE actionId IN (";
2685 private static final String _SQL_SELECT_MDRACTION_WHERE = "SELECT mdrAction FROM MDRAction mdrAction WHERE ";
2686 private static final String _SQL_COUNT_MDRACTION = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction";
2687 private static final String _SQL_COUNT_MDRACTION_WHERE = "SELECT COUNT(mdrAction) FROM MDRAction mdrAction WHERE ";
2688 private static final String _ORDER_BY_ENTITY_ALIAS = "mdrAction.";
2689 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No MDRAction exists with the primary key ";
2690 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No MDRAction exists with the key {";
2691 private static final Log _log = LogFactoryUtil.getLog(MDRActionPersistenceImpl.class);
2692 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2693 "uuid", "type"
2694 });
2695 private static final MDRAction _nullMDRAction = new MDRActionImpl() {
2696 @Override
2697 public Object clone() {
2698 return this;
2699 }
2700
2701 @Override
2702 public CacheModel<MDRAction> toCacheModel() {
2703 return _nullMDRActionCacheModel;
2704 }
2705 };
2706
2707 private static final CacheModel<MDRAction> _nullMDRActionCacheModel = new CacheModel<MDRAction>() {
2708 @Override
2709 public MDRAction toEntityModel() {
2710 return _nullMDRAction;
2711 }
2712 };
2713 }