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