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