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